Пример #1
0
 public CefBeforePopupEventArgs(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings)
 {
     this.parentBrowser = parentBrowser;
     this.popupFeatures = popupFeatures;
     this.windowInfo    = windowInfo;
     this.url           = url;
     this.client        = client;
     this.settings      = settings;
 }
 public CefBeforePopupEventArgs(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings)
 {
     this.parentBrowser = parentBrowser;
     this.popupFeatures = popupFeatures;
     this.windowInfo = windowInfo;
     this.url = url;
     this.client = client;
     this.settings = settings;
 }
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName,
                                              CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings,
                                              ref bool noJavascriptAccess)
        {
            var e = new CancelEventArgs();

            _core.NewWindow(targetUrl, e);
            return(e.Cancel);
        }
Пример #4
0
        public void OnBeforePopup(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings)
        {
            var handler = this.BeforePopup;

            if (handler != null)
            {
                handler(this.owner, new CefBeforePopupEventArgs(parentBrowser, popupFeatures, windowInfo, url, ref client, settings));
            }
        }
Пример #5
0
 protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl,
                                       string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture,
                                       CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings,
                                       ref bool noJavascriptAccess)
 {
     // Block a new popup window.
     // Instead just redirect the popup target to the current browser.
     browser.GetMainFrame().LoadUrl(targetUrl);
     return(true);
 }
Пример #6
0
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl,
                                              string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo,
                                              ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            var e = new BeforePopupEventArgs(targetUrl, targetFrameName,
                                             popupFeatures, windowInfo, client, noJavascriptAccess);

            _core.OnBeforePopup(e);
            client             = e.Client;
            noJavascriptAccess = e.NoJavascriptAccess;
            return(e.Cancel);
        }
Пример #7
0
		protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
		{
			var e = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings,
								 noJavascriptAccess);

			_core.InvokeIfRequired(() => _core.OnBeforePopup(e));

			client = e.Client;
			noJavascriptAccess = e.NoJavascriptAccess;

			return e.Handled;
		}
Пример #8
0
        protected override bool OnBeforePopup(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings)
        {
            #if DIAGNOSTICS
            Cef.Logger.Trace(LogTarget.CefLifeSpanHandler, "OnBeforePopup");
            #endif

            /*
             #if DEBUG
             *  string message = string.Format(
             *      "LifeSpanHandler:OnBeforePopup\n"
             + "               URL: {0}\n"
             + "                 X: {1}\n"
             + "                 Y: {2}\n"
             + "             Width: {3}\n"
             + "            Height: {4}\n"
             + "    MenuBarVisible: {5}\n"
             + "  StatusBarVisible: {6}\n"
             + "    ToolBarVisible: {7}\n"
             + "LocationBarVisible: {8}\n"
             + " ScrollbarsVisible: {9}\n"
             + "         Resizable: {10}\n"
             + "        Fullscreen: {11}\n"
             + "            Dialog: {12}\n",
             +      url,
             +      popupFeatures.X.HasValue ? popupFeatures.X.ToString() : "not set",
             +      popupFeatures.Y.HasValue ? popupFeatures.Y.ToString() : "not set",
             +      popupFeatures.Width.HasValue ? popupFeatures.Width.ToString() : "not set",
             +      popupFeatures.Height.HasValue ? popupFeatures.Height.ToString() : "not set",
             +      popupFeatures.MenuBarVisible,
             +      popupFeatures.StatusBarVisible,
             +      popupFeatures.ToolBarVisible,
             +      popupFeatures.LocationBarVisible,
             +      popupFeatures.ScrollbarsVisible,
             +      popupFeatures.Resizable,
             +      popupFeatures.Fullscreen,
             +      popupFeatures.Dialog
             +      );
             #endif
             */

            this.context.OnBeforePopup(parentBrowser, popupFeatures, windowInfo, url, ref client, settings);

            // TODO: create webview here
            // TODO: do not inherit browser settings for devtools
            client = CefWebClientFactory.Default.Create(new CefWebBrowserCore(null, this.context.Settings, url));

            // TODO: create new browsercontext for popup windows

            return(false);
        }
Пример #9
0
 public BeforePopupEventArgs(
     string targetUrl,
     string targetFrameName,
     CefPopupFeatures popupFeatures,
     CefWindowInfo windowInfo,
     CefClient client,
     bool noJavascriptAccess)
 {
     TargetUrl             = string.IsNullOrEmpty(targetUrl) ? "about:blank" : targetUrl;
     TargetFrameName       = string.IsNullOrEmpty(targetFrameName) ? Guid.NewGuid().ToString() : targetFrameName;
     PopupFeatures         = popupFeatures;
     WindowInfo            = windowInfo;
     Client                = client;
     NoJavascriptAccess    = noJavascriptAccess;
     NeedCustomPopupWindow = false;
     Cancel                = false;
 }
Пример #10
0
		public BeforePopupEventArgs(
			CefFrame frame,
			string targetUrl,
			string targetFrameName,
			CefPopupFeatures popupFeatures,
			CefWindowInfo windowInfo,
			CefClient client,
			CefBrowserSettings settings,
			bool noJavascriptAccess)
		{
			Frame = frame;
			TargetUrl = targetUrl;
			TargetFrameName = targetFrameName;
			PopupFeatures = popupFeatures;
			WindowInfo = windowInfo;
			Client = client;
			Settings = settings;
			NoJavascriptAccess = noJavascriptAccess;
		}
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BeforePopupEventArgs"/> class.
 /// </summary>
 /// <param name="frame">
 /// The frame.
 /// </param>
 /// <param name="targetUrl">
 /// The target url.
 /// </param>
 /// <param name="targetFrameName">
 /// The target frame name.
 /// </param>
 /// <param name="popupFeatures">
 /// The popup features.
 /// </param>
 /// <param name="windowInfo">
 /// The window info.
 /// </param>
 /// <param name="client">
 /// The client.
 /// </param>
 /// <param name="settings">
 /// The settings.
 /// </param>
 /// <param name="noJavascriptAccess">
 /// The no javascript access.
 /// </param>
 public BeforePopupEventArgs(
     CefFrame frame,
     string targetUrl,
     string targetFrameName,
     CefPopupFeatures popupFeatures,
     CefWindowInfo windowInfo,
     CefClient client,
     CefBrowserSettings settings,
     bool noJavascriptAccess)
 {
     this.Frame              = frame;
     this.TargetUrl          = targetUrl;
     this.TargetFrameName    = targetFrameName;
     this.PopupFeatures      = popupFeatures;
     this.WindowInfo         = windowInfo;
     this.Client             = client;
     this.Settings           = settings;
     this.NoJavascriptAccess = noJavascriptAccess;
 }
        /// <summary>
        /// Called on the UI thread before a new popup browser is created. To allow creation of the popup
        /// browser optionally modify <paramref name="windowInfo"/>, <paramref name="client"/>,
        /// <paramref name="settings"/> and <paramref name="noJavascriptAccess"/> and return false.
        /// To cancel creation of the popup browser return true. Popup browser creation will be canceled
        /// if the parent browser is destroyed before the popup browser creation completes (indicated by a
        /// call to <see cref="OnAfterCreated"/> for the popup browser).
        /// </summary>
        /// <param name="browser">A value represent the source browser of the popup request.</param>
        /// <param name="frame">A value represent the source frame of the popup request.</param>
        /// <param name="targetUrl">
        /// A value indicate where the popup browser should navigate and may be empty if not specified
        /// with the request.
        /// </param>
        /// <param name="targetFrameName">
        /// A value indicate where the popup browser should navigate and may be empty if not specified
        /// with the request.
        /// </param>
        /// <param name="targetDisposition">
        /// A value indicates where the user intended to open the popup (e.g. current tab, new tab, etc).
        /// </param>
        /// <param name="userGesture">
        /// A value will be true if the popup was opened via explicit user gesture (e.g. clicking a link)
        /// or false if the popup opened automatically (e.g. via the DomContentLoaded event).
        /// </param>
        /// <param name="popupFeatures">Additional information about the requested popup window.</param>
        /// <param name="windowInfo">The window information.</param>
        /// <param name="client"></param>
        /// <param name="settings">The browser settings, defaults to source browsers.</param>
        /// <param name="extraInfo">
        /// Provides an opportunity to specify extra information specific to the created popup browser that
        /// will be passed to <see cref="CefNetApplication.OnBrowserCreated"/> in the render process.
        /// </param>
        /// <param name="noJavascriptAccess">
        /// If the value is set to false the new browser will not be scriptable and may not be hosted in
        /// the same renderer process as the source browser.
        /// </param>
        /// <returns></returns>
        internal protected virtual bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition,
                                                      bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref int noJavascriptAccess)
        {
#if DEBUG
            if (!BrowserObject.IsSame(browser))
            {
                throw new InvalidOperationException();
            }
#endif
            var ea = new CreateWindowEventArgs(frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, null, settings, extraInfo, noJavascriptAccess != 0);
            WebView.RaiseCefCreateWindow(ea);
            extraInfo          = ea.ExtraInfo;
            noJavascriptAccess = ea.NoJavaScriptAccess ? 1 : 0;
            client             = ea.Client;
            if (!ea.Cancel)
            {
                (client as CefClientGlue)?.NotifyPopupBrowserCreating();
            }
            return(ea.Cancel);
        }
Пример #13
0
 internal BeforePopupEventArgs(
     CefFrame frame,
     string targetUrl,
     string targetFrameName,
     bool userGesture,
     CefPopupFeatures popupFeatures,
     CefWindowInfo windowInfo,
     CefClient client,
     CefBrowserSettings settings,
     bool noJavascriptAccess)
 {
     Frame              = frame;
     TargetUrl          = targetUrl;
     TargetFrameName    = targetFrameName;
     UserGesture        = userGesture;
     PopupFeatures      = popupFeatures;
     WindowInfo         = windowInfo;
     Client             = client;
     Settings           = settings;
     NoJavascriptAccess = noJavascriptAccess;
 }
Пример #14
0
 protected override bool OnBeforePopup(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings)
 {
     FRenderer.LoadURL(url);
     return(true);
 }
Пример #15
0
 protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
 {
     FRenderer.LoadUrl(targetUrl);
     return(true);
 }
Пример #16
0
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            bool res = false;

            if (!string.IsNullOrEmpty(targetUrl))
            {
                if (webBrowser.selfRequest != null)
                {
                    CefRequest req = CefRequest.Create();
                    req.FirstPartyForCookies = webBrowser.selfRequest.FirstPartyForCookies;
                    req.Options = webBrowser.selfRequest.Options;

                    /*CefPostData postData = CefPostData.Create();
                     * CefPostDataElement element = CefPostDataElement.Create();
                     * int index = targetUrl.IndexOf("?");
                     * string url = targetUrl.Substring(0, index);
                     * string data = targetUrl.Substring(index + 1);
                     * byte[] bytes = Encoding.UTF8.GetBytes(data);
                     * element.SetToBytes(bytes);
                     * postData.Add(element);
                     */
                    System.Collections.Specialized.NameValueCollection h = new System.Collections.Specialized.NameValueCollection();
                    h.Add("Content-Type", "application/x-www-form-urlencoded");
                    req.Set(targetUrl, webBrowser.selfRequest.Method, null, webBrowser.selfRequest.GetHeaderMap());
                    webBrowser.selfRequest = req;
                }
                //webBrowser.selfRequest.Set(targetUrl, webBrowser.selfRequest.Method, webBrowser.selfRequest.PostData, webBrowser.selfRequest.GetHeaderMap());
                res = webBrowser.OnNewWindow(targetUrl);
                if (res)
                {
                    return(res);
                }
            }
            res = base.OnBeforePopup(browser, frame, targetUrl, targetFrameName, popupFeatures, windowInfo, ref client, settings, ref noJavascriptAccess);
            return(res);
        }
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            var e = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings,
                                             noJavascriptAccess);

            _core.InvokeIfRequired(() => _core.OnBeforePopup(e));

            client             = e.Client;
            noJavascriptAccess = e.NoJavascriptAccess;

            return(e.Handled);
        }
            protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
            {
                if (UrlHelper.IsChromeInternalUrl(targetUrl))
                {
                    return(false);
                }

                if (Uri.IsWellFormedUriString(targetUrl, UriKind.RelativeOrAbsolute))
                {
                    var uri = new Uri(targetUrl);
                    if (!uri.IsAbsoluteUri)
                    {
                        // turning relative urls into full path to avoid that someone runs custom command lines
                        targetUrl = new Uri(new Uri(frame.Url), uri).AbsoluteUri;
                    }
                }
                else
                {
                    return(false); // if the url is not well formed let's use the browser to handle the things
                }

                try {
                    var popupOpening = OwnerWebView.PopupOpening;
                    if (popupOpening != null)
                    {
                        popupOpening(targetUrl);
                    }
                    else
                    {
                        UrlHelper.OpenInExternalBrowser(targetUrl);
                    }
                } catch {
                    // if we can't handle the command line let's continue the normal request with the popup
                    // with this, will not blow in the users face
                    return(false);
                }

                return(true);
            }
Пример #19
0
 protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref int noJavascriptAccess)
 {
     switch (targetDisposition)
     {
     case CefWindowOpenDisposition.NewForegroundTab:
     case CefWindowOpenDisposition.NewBackgroundTab:
     case CefWindowOpenDisposition.NewPopup:
     case CefWindowOpenDisposition.NewWindow:
         if (webView.OpenInBrowser)
         {
             BrowserOpen(targetUrl);
         }
         else
         {
             // 禁止创建新窗口,仅在当前窗口跳转
             browser.MainFrame.LoadUrl(targetUrl);
         }
         return(true);
     }
     return(base.OnBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref extraInfo, ref noJavascriptAccess));
 }
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
        {
            _browser.InvokeAsyncIfPossible(() => _browser.OnBeforePopup(new BeforePopupEventArgs(frame, targetUrl, targetFrameName)));

            var isUrlExternal = _config?.UrlSchemes?.IsUrlRegisteredExternalBrowserScheme(targetUrl);

            if (isUrlExternal.HasValue && isUrlExternal.Value)
            {
                BrowserLauncher.Open(_config.Platform, targetUrl);
                return(true);
            }

            var isUrlCommand = _config?.UrlSchemes?.IsUrlRegisteredCommandScheme(targetUrl);

            if (isUrlCommand.HasValue && isUrlCommand.Value)
            {
                _commandTaskRunner.RunAsync(targetUrl);
                return(true);
            }

            return(false);
        }
Пример #21
0
    protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
    {
        if (_browser is not null)
        {
            _browser.InvokeAsyncIfPossible(() => _browser.OnBeforePopup(new BeforePopupEventArgs(frame, targetUrl, targetFrameName)));
        }

        if (_config is not null)
        {
            var isUrlExternal = _config.UrlSchemes?.IsUrlRegisteredExternalBrowserScheme(targetUrl);
            if (isUrlExternal.HasValue && isUrlExternal.Value)
            {
                BrowserLauncher.Open(_config.Platform, targetUrl);
                return(true);
            }
        }

        // Sample: http://chromely.com/democontroller/showdevtools
        // Expected to execute controller route action without return value
        var route = _routeProvider.GetRoute(targetUrl);

        if (route is not null && !route.HasReturnValue)
        {
            _requestHandler.Execute(targetUrl);
            return(true);
        }

        return(false);
    }
Пример #22
0
            protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName,
                                                  CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures,
                                                  CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
            {
                //settings.WebSecurity = CefState.Disabled;
                windowInfo.SetAsWindowless(IntPtr.Zero, false);
                var newBrowser = new Browser(false);

                client = newBrowser.CefClient;

                WaitForBrowser(newBrowser);

                return(false);
            }
 protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName,
                                       CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures,
                                       CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo,
                                       ref bool noJavascriptAccess)
 {
     frame.LoadUrl(targetUrl);
     return(true);
 }
Пример #24
0
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            Browser father = CefUtil.GetBrowserFromCef(browser);

            father.GoToPage(targetUrl);
            return(true);
        }
Пример #25
0
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            var eventArgs = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings,
                                                     noJavascriptAccess);

            m_browser.InvokeAsyncIfPossible(() => m_browser.OnBeforePopup(eventArgs));

            client             = eventArgs.Client;
            noJavascriptAccess = eventArgs.NoJavascriptAccess;

            return(eventArgs.Handled);
        }
Пример #26
0
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            var e = new UIWebBrowser.BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings,
                                                          noJavascriptAccess);

            this.owner.OnBeforePopup(e);

            client             = e.Client;
            noJavascriptAccess = e.NoJavascriptAccess;

            return(e.Handled);
        }
Пример #27
0
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
        {
            var e = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, userGesture, popupFeatures, windowInfo, client, settings, noJavascriptAccess);

            _owner.InvokeIfRequired(() => _owner.OnBeforePopup(e));


            if (e.Handled == false)
            {
                if (popupFeatures.X.HasValue)
                {
                    windowInfo.X = popupFeatures.X.Value;
                }


                if (popupFeatures.Y.HasValue)
                {
                    windowInfo.Y = popupFeatures.Y.Value;
                }

                if (popupFeatures.Width.HasValue)
                {
                    windowInfo.Width = popupFeatures.Width.Value;
                }
                else
                {
                    windowInfo.Width = _owner.Width;
                }

                if (popupFeatures.Height.HasValue)
                {
                    windowInfo.Height = popupFeatures.Height.Value;
                }
                else
                {
                    windowInfo.Height = _owner.Height;
                }



                windowInfo.SetAsPopup(IntPtr.Zero, $"正在加载 - {_owner.Title}");

                client = new PopupBrowserClient(_owner);
            }


            return(e.Handled);
        }
        protected override bool OnBeforePopup(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings)
        {
            #if DIAGNOSTICS
            Cef.Logger.Trace(LogTarget.CefLifeSpanHandler, "OnBeforePopup");
            #endif

            /*
                #if DEBUG
                string message = string.Format(
                    "LifeSpanHandler:OnBeforePopup\n"
                    + "               URL: {0}\n"
                    + "                 X: {1}\n"
                    + "                 Y: {2}\n"
                    + "             Width: {3}\n"
                    + "            Height: {4}\n"
                    + "    MenuBarVisible: {5}\n"
                    + "  StatusBarVisible: {6}\n"
                    + "    ToolBarVisible: {7}\n"
                    + "LocationBarVisible: {8}\n"
                    + " ScrollbarsVisible: {9}\n"
                    + "         Resizable: {10}\n"
                    + "        Fullscreen: {11}\n"
                    + "            Dialog: {12}\n",
                    url,
                    popupFeatures.X.HasValue ? popupFeatures.X.ToString() : "not set",
                    popupFeatures.Y.HasValue ? popupFeatures.Y.ToString() : "not set",
                    popupFeatures.Width.HasValue ? popupFeatures.Width.ToString() : "not set",
                    popupFeatures.Height.HasValue ? popupFeatures.Height.ToString() : "not set",
                    popupFeatures.MenuBarVisible,
                    popupFeatures.StatusBarVisible,
                    popupFeatures.ToolBarVisible,
                    popupFeatures.LocationBarVisible,
                    popupFeatures.ScrollbarsVisible,
                    popupFeatures.Resizable,
                    popupFeatures.Fullscreen,
                    popupFeatures.Dialog
                    );
                #endif
                */

            this.context.OnBeforePopup(parentBrowser, popupFeatures, windowInfo, url, ref client, settings);

            // TODO: create webview here
            // TODO: do not inherit browser settings for devtools
            client = CefWebClientFactory.Default.Create(new CefWebBrowserCore(null, this.context.Settings, url));

            // TODO: create new browsercontext for popup windows

            return false;
        }
Пример #29
0
        /// <summary>
        /// The on before popup.
        /// </summary>
        /// <param name="browser">
        /// The browser.
        /// </param>
        /// <param name="frame">
        /// The frame.
        /// </param>
        /// <param name="targetUrl">
        /// The target url.
        /// </param>
        /// <param name="targetFrameName">
        /// The target frame name.
        /// </param>
        /// <param name="targetDisposition">
        /// The target disposition.
        /// </param>
        /// <param name="userGesture">
        /// The user gesture.
        /// </param>
        /// <param name="popupFeatures">
        /// The popup features.
        /// </param>
        /// <param name="windowInfo">
        /// The window info.
        /// </param>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="settings">
        /// The settings.
        /// </param>
        /// <param name="noJavascriptAccess">
        /// The no javascript access.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            var isUrlExternal = UrlSchemeProvider.IsUrlRegisteredExternal(targetUrl);

            if (isUrlExternal)
            {
                RegisteredExternalUrl.Launch(targetUrl);
            }

            return(true);
        }
        /// <summary>
        /// 弹出窗口事件
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="frame"></param>
        /// <param name="targetUrl"></param>
        /// <param name="targetFrameName"></param>
        /// <param name="targetDisposition"></param>
        /// <param name="userGesture"></param>
        /// <param name="popupFeatures"></param>
        /// <param name="windowInfo"></param>
        /// <param name="client"></param>
        /// <param name="settings"></param>
        /// <param name="noJavascriptAccess"></param>
        /// <returns></returns>
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            //无窗口模式 禁止打开弹窗
            return(true);
            //var e = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings,
            //                     noJavascriptAccess);

            /////*_core.InvokeIfRequired(() => _core.OnBeforePopup(e));*/

            ////client = e.Client;
            ////noJavascriptAccess = e.NoJavascriptAccess;
            ////无窗口模式 禁止打开弹窗
            ////直接在当前页面进行跳转
            //e.Frame.Browser.GetMainFrame().LoadUrl(e.TargetUrl);

            //e.Handled = true;
            //return e.Handled;
        }
Пример #31
0
 protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
 {
     if (_owner.PopupHandler != null)
     {
         return(_owner.PopupHandler.Invoke(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref noJavascriptAccess));
     }
     return(base.OnBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref noJavascriptAccess));
 }
Пример #32
0
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            var e = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings,
                                             noJavascriptAccess);

            _core.InvokeIfRequired(() => _core.OnBeforePopup(e));

            client             = e.Client;
            noJavascriptAccess = e.NoJavascriptAccess;
            //if (FileHelper1.read("//config//chromeconfig.txt")[0] == "true") {
            e.Handled = true;
            //}
            return(e.Handled);
            //  return true;//强制不弹出
        }
Пример #33
0
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
        {
            //  return base.OnBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref extraInfo, ref noJavascriptAccess);

            var e = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings, noJavascriptAccess);

            client             = e.Client;
            noJavascriptAccess = e.NoJavascriptAccess;
            _core.x            = windowInfo.X;
            _core.y            = windowInfo.Y;
            _core._width       = windowInfo.Width;
            _core._height      = windowInfo.Height;
            _core.InvokeIfRequired(() => _core.OnBeforePopup(e));
            return(e.Handled);
        }
Пример #34
0
        /// <summary>
        /// The on before popup.
        /// </summary>
        /// <param name="browser">
        /// The browser.
        /// </param>
        /// <param name="frame">
        /// The frame.
        /// </param>
        /// <param name="targetUrl">
        /// The target url.
        /// </param>
        /// <param name="targetFrameName">
        /// The target frame name.
        /// </param>
        /// <param name="targetDisposition">
        /// The target disposition.
        /// </param>
        /// <param name="userGesture">
        /// The user gesture.
        /// </param>
        /// <param name="popupFeatures">
        /// The popup features.
        /// </param>
        /// <param name="windowInfo">
        /// The window info.
        /// </param>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="settings">
        /// The settings.
        /// </param>
        /// <param name="noJavascriptAccess">
        /// The no javascript access.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            var isUrlExternal = _config?.UrlSchemes?.IsUrlRegisteredExternalScheme(targetUrl);

            if (isUrlExternal.HasValue && isUrlExternal.Value)
            {
                RegisteredExternalUrl.Launch(targetUrl);
            }

            var isUrlCommand = _config?.UrlSchemes?.IsUrlRegisteredCommandScheme(targetUrl);

            if (isUrlCommand.HasValue && isUrlCommand.Value)
            {
                _commandTaskRunner.RunAsync(targetUrl);
            }

            return(true);
        }
Пример #35
0
 public void OnBeforePopup(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, string url, ref CefClient client, CefBrowserSettings settings)
 {
     var handler = this.BeforePopup;
     if (handler != null)
     {
         handler(this.owner, new CefBeforePopupEventArgs(parentBrowser, popupFeatures, windowInfo, url, ref client, settings));
     }
 }