Esempio n. 1
0
        protected override CefReturnValue OnBeforeResourceLoad(CefBrowser browser, CefFrame frame, CefRequest request, CefRequestCallback callback)
        {
            var sc = DI.Get <CloudServiceClientBase>();

            if (request.Url.StartsWith(sc.ApiBaseUrl, StringComparison.OrdinalIgnoreCase))
            {
                var conn_helper = DI.Get <IApiConnectionPlatformHelper>();
                request.SetHeaderByName(Headers.Request.AppVersion, sc.Settings.AppVersionStr, true);
                if (webView.IsSecurity)
                {
                    if (webView.Aes == null)
                    {
                        webView.Aes = AESUtils.Create();
                    }
                    var skey_bytes = webView.Aes.ToParamsByteArray();
                    var skey_str   = conn_helper.RSA.EncryptToString(skey_bytes);
                    request.SetHeaderByName(Headers.Request.SecurityKey, skey_str, true);
                }
                Func <Task <JWTEntity?> > getAuthTokenAsync = () => conn_helper.Auth.GetAuthTokenAsync().AsTask();
                var authToken       = getAuthTokenAsync.RunSync();
                var authHeaderValue = conn_helper.GetAuthenticationHeaderValue(authToken);
                if (authHeaderValue != null)
                {
                    var authHeaderValueStr = authHeaderValue.ToString();
                    request.SetHeaderByName("Authorization", authHeaderValueStr, true);
                }
            }
            var returnValue = base.OnBeforeResourceLoad(browser, frame, request, callback);

            return(returnValue);
        }
Esempio n. 2
0
        private void HandleLoadFromString(object sender, EventArgs e)
        {
            if (!CefCommandLine.Global.HasSwitch("disable-site-isolation-trials"))
            {
                // info:
                // https://magpcss.org/ceforum/viewtopic.php?f=6&t=17176&p=43706
                // https://bitbucket.org/chromiumembedded/cef/issues/2586
                MessageBox.Show("This test only works with --disable-site-isolation-trials.");
            }

            var view = SelectedView as CustomWebView;

            if (view is null)
            {
                return;
            }

            Guid sourceKey = Guid.NewGuid();

            view.AddSource(sourceKey, new StringSource("Hello, world!", "text/html"));
            var request = new CefRequest();

            request.Url = "http://example.com";
            request.SetReferrer("https://www.google.com/", CefReferrerPolicy.NeverClearReferrer);
            request.SetHeaderByName("CefNet-Source", sourceKey.ToString(), false);             // see CustomWebViewGlue.GetResourceHandler()
            SelectedView?.GetMainFrame().LoadRequest(request);
        }
Esempio n. 3
0
        protected override CefReturnValue OnBeforeResourceLoad(CefBrowser browser, CefFrame frame, CefRequest request, CefRequestCallback callback)
        {
            var sc = DI.Get <CloudServiceClientBase>();

            if (request.Url.StartsWith(sc.ApiBaseUrl, StringComparison.OrdinalIgnoreCase))
            {
                request.SetHeaderByName(Headers.Request.AppVersion, sc.Settings.AppVersionStr, true);
            }
            var returnValue = base.OnBeforeResourceLoad(browser, frame, request, callback);

            return(returnValue);
        }
Esempio n. 4
0
        protected override CefReturnValue OnBeforeResourceLoad(CefBrowser browser, CefFrame frame, CefRequest request, CefRequestCallback callback)
        {
            var sc = DI.Get <CloudServiceClientBase>();

            if (request.Url.StartsWith(sc.ApiBaseUrl, StringComparison.OrdinalIgnoreCase))
            {
                request.SetHeaderByName(Headers.Request.AppVersion, sc.Settings.AppVersionStr, true);
                if (webView.IsSecurity)
                {
                    if (webView.Aes == null)
                    {
                        webView.Aes = AESUtils.Create();
                    }
                    var skey_bytes  = webView.Aes.ToParamsByteArray();
                    var conn_helper = DI.Get <IApiConnectionPlatformHelper>();
                    var skey_str    = conn_helper.RSA.EncryptToString(skey_bytes);
                    request.SetHeaderByName(Headers.Request.SecurityKey, skey_str, true);
                }
            }
            var returnValue = base.OnBeforeResourceLoad(browser, frame, request, callback);

            return(returnValue);
        }
Esempio n. 5
0
        private void HandleLoadFromString(object sender, EventArgs e)
        {
            var view = SelectedView as CustomWebView;

            if (view is null)
            {
                return;
            }

            Guid sourceKey = Guid.NewGuid();

            view.AddSource(sourceKey, new StringSource("Hello, world!", "text/html"));
            var request = new CefRequest();

            request.Url = "http://example.com";
            request.SetReferrer("https://www.google.com/", CefReferrerPolicy.NeverClearReferrer);
            request.SetHeaderByName("CefNet-Source", sourceKey.ToString(), false);             // see CustomWebViewGlue.GetResourceHandler()
            SelectedView?.GetMainFrame().LoadRequest(request);
        }