示例#1
0
        public CreateWindowEventArgs(
            CefFrame frame,
            string targetUrl,
            string targetFrameName,
            CefWindowOpenDisposition targetDisposition,
            bool userGesture,
            CefPopupFeatures popupFeatures,
            CefWindowInfo windowInfo,
            CefClient client,
            CefBrowserSettings settings,
            CefDictionaryValue extraInfo,
            bool noJavascriptAccess)
        {
            this.Frame             = frame;
            this.TargetUrl         = targetUrl;
            this.TargetFrameName   = targetFrameName;
            this.TargetDisposition = targetDisposition;
            this.UserGesture       = userGesture;
            this.PopupFeatures     = popupFeatures;
            this.Settings          = settings;

            this.WindowInfo         = windowInfo;
            this.Client             = client;
            this.ExtraInfo          = extraInfo;
            this.NoJavaScriptAccess = 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)
 {
     frame.LoadUrl(targetUrl);
     return(true);
 }
示例#3
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);
 }
        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);

            this.owner.OnBeforePopup(e);

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

            return(e.Handled);
        }
示例#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)
            {
                //settings.WebSecurity = CefState.Disabled;
                windowInfo.SetAsWindowless(IntPtr.Zero, false);
                var newBrowser = new Browser(false);

                client = newBrowser.CefClient;

                WaitForBrowser(newBrowser);

                return(false);
            }
示例#6
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);
        }
        private int on_before_popup(cef_life_span_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_string_t *target_url, cef_string_t *target_frame_name, CefWindowOpenDisposition target_disposition, int user_gesture, cef_popup_features_t *popupFeatures, cef_window_info_t *windowInfo, cef_client_t **client, cef_browser_settings_t *settings, int *no_javascript_access)
        {
            CheckSelf(self);

            var m_browser            = CefBrowser.FromNative(browser);
            var m_frame              = CefFrame.FromNative(frame);
            var m_targetUrl          = cef_string_t.ToString(target_url);
            var m_targetFrameName    = cef_string_t.ToString(target_frame_name);
            var m_userGesture        = user_gesture != 0;
            var m_popupFeatures      = new CefPopupFeatures(popupFeatures);
            var m_windowInfo         = CefWindowInfo.FromNative(windowInfo);
            var m_client             = CefClient.FromNative(*client);
            var m_settings           = new CefBrowserSettings(settings);
            var m_noJavascriptAccess = (*no_javascript_access) != 0;

            var o_client = m_client;
            var result   = OnBeforePopup(m_browser, m_frame, m_targetUrl, m_targetFrameName, target_disposition, m_userGesture, m_popupFeatures, m_windowInfo, ref m_client, m_settings, ref m_noJavascriptAccess);

            if ((object)o_client != m_client && m_client != null)
            {
                *client = m_client.ToNative();
            }

            *no_javascript_access = m_noJavascriptAccess ? 1 : 0;

            m_popupFeatures.Dispose();
            m_windowInfo.Dispose();
            m_settings.Dispose();

            return(result ? 1 : 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 (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);
            }
    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);
    }
示例#10
0
 public unsafe extern int OnOpenUrlFromTab(cef_browser_t *browser, cef_frame_t *frame, [Immutable] cef_string_t *target_url, CefWindowOpenDisposition target_disposition, int user_gesture);
示例#11
0
 /// <summary>
 /// Called on the UI thread before OnBeforeBrowse in certain limited cases
 /// where navigating a new or different browser might be desirable. This
 /// includes user-initiated navigation that might open in a special way (e.g.
 /// links clicked via middle-click or ctrl + left-click) and certain types of
 /// cross-origin navigation initiated from the renderer process (e.g.
 /// navigating the top-level frame to/from a file URL). The |browser| and
 /// |frame| values represent the source of the navigation. The
 /// |target_disposition| value indicates where the user intended to navigate
 /// the browser based on standard Chromium behaviors (e.g. current tab,
 /// new tab, etc). The |user_gesture| value will be true if the browser
 /// navigated via explicit user gesture (e.g. clicking a link) or false if it
 /// navigated automatically (e.g. via the DomContentLoaded event). Return true
 /// to cancel the navigation or false to allow the navigation to proceed in the
 /// source browser's top-level frame.
 /// </summary>
 protected virtual bool OnOpenUrlFromTab(CefBrowser browser, CefFrame frame, string targetUrl, CefWindowOpenDisposition targetDisposition, bool userGesture)
 {
     return(false);
 }
        /// <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;
        }
示例#13
0
 /// <summary>
 /// Called on the UI thread before a new popup browser is created. The
 /// |browser| and |frame| values represent the source of the popup request. The
 /// |target_url| and |target_frame_name| values indicate where the popup
 /// browser should navigate and may be NULL if not specified with the request.
 /// The |target_disposition| value indicates where the user intended to open
 /// the popup (e.g. current tab, new tab, etc). The |user_gesture| value will
 /// be true (1) if the popup was opened via explicit user gesture (e.g.
 /// clicking a link) or false (0) if the popup opened automatically (e.g. via
 /// the DomContentLoaded event). The |popupFeatures| structure contains
 /// additional information about the requested popup window. To allow creation
 /// of the popup browser optionally modify |windowInfo|, |client|, |settings|
 /// and |no_javascript_access| and return false (0). To cancel creation of the
 /// popup browser return true (1). The |client| and |settings| values will
 /// default to the source browser&apos;s values. If the |no_javascript_access| value
 /// is set to false (0) the new browser will not be scriptable and may not be
 /// hosted in the same renderer process as the source browser. Any
 /// modifications to |windowInfo| will be ignored if the parent browser is
 /// wrapped in a cef_browser_view_t. Popup browser creation will be canceled if
 /// the parent browser is destroyed before the popup browser creation completes
 /// (indicated by a call to OnAfterCreated for the popup browser). The
 /// |extra_info| parameter provides an opportunity to specify extra information
 /// specific to the created popup browser that will be passed to
 /// cef_render_process_handler_t::on_browser_created() in the render process.
 /// </summary>
 protected internal unsafe 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)
 {
     return(default);
示例#14
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);
        }
 private int on_before_popup(cef_life_span_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_string_t *target_url, cef_string_t *target_frame_name, CefWindowOpenDisposition target_disposition, int user_gesture, cef_popup_features_t *popupFeatures, cef_window_info_t *windowInfo, cef_client_t **client, cef_browser_settings_t *settings, int *no_javascript_access)
 {
     CheckSelf(self);
     throw new NotImplementedException(); // TODO: CefLifeSpanHandler.OnBeforePopup
 }
        /// <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 eventArgs = new BeforePopupEventArgs(
                frame,
                targetUrl,
                targetFrameName,
                popupFeatures,
                windowInfo,
                client,
                settings,
                noJavascriptAccess);

            this.mBrowser.InvokeAsyncIfPossible(() => this.mBrowser.OnBeforePopup(eventArgs));

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

            return(eventArgs.Handled);

            // return base.OnBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref 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);
        }
示例#18
0
 public unsafe int OnOpenUrlFromTab(cef_browser_t *browser, cef_frame_t *frame, [Immutable] cef_string_t *target_url, CefWindowOpenDisposition target_disposition, int user_gesture)
 {
     fixed(cef_request_handler_t *self = &this)
     {
         return(((delegate * unmanaged[Stdcall] < cef_request_handler_t *, cef_browser_t *, cef_frame_t *, cef_string_t *, CefWindowOpenDisposition, int, int >)on_open_urlfrom_tab)(self, browser, frame, target_url, target_disposition, user_gesture));
     }
 }
示例#19
0
        private int on_open_urlfrom_tab(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_string_t *target_url, CefWindowOpenDisposition target_disposition, int user_gesture)
        {
            CheckSelf(self);

            var m_browser     = CefBrowser.FromNative(browser);
            var m_frame       = CefFrame.FromNative(frame);
            var m_targetUrl   = cef_string_t.ToString(target_url);
            var m_userGesture = user_gesture != 0;

            var m_result = OnOpenUrlFromTab(m_browser, m_frame, m_targetUrl, target_disposition, m_userGesture);

            return(m_result ? 1 : 0);
        }
示例#20
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 OnOpenUrlFromTab(CefBrowser browser, CefFrame frame, string targetUrl, CefWindowOpenDisposition targetDisposition, bool userGesture)
 {
     return(base.OnOpenUrlFromTab(browser, frame, targetUrl, targetDisposition, userGesture));
 }
示例#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)
 {
     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));
 }
示例#23
0
 protected override bool OnOpenUrlFromTab(CefBrowser browser, CefFrame frame, string targetUrl, CefWindowOpenDisposition targetDisposition, bool userGesture)
 {
     return(Logic.OnOpenUrlFromTab(targetUrl, userGesture, LifeSpanHandler.ConvertTargetDisposition(targetDisposition)));
 }
示例#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 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);
        }
示例#25
0
 public unsafe int OnBeforePopup(cef_browser_t *browser, cef_frame_t *frame, [Immutable] cef_string_t *target_url, [Immutable] cef_string_t *target_frame_name, CefWindowOpenDisposition target_disposition, int user_gesture, [Immutable] cef_popup_features_t *popupFeatures, cef_window_info_t *windowInfo, cef_client_t **client, cef_browser_settings_t *settings, cef_dictionary_value_t **extra_info, int *no_javascript_access)
 {
     fixed(cef_life_span_handler_t *self = &this)
     {
         return(((delegate * unmanaged[Stdcall] < cef_life_span_handler_t *, cef_browser_t *, cef_frame_t *, cef_string_t *, cef_string_t *, CefWindowOpenDisposition, int, cef_popup_features_t *, cef_window_info_t *, cef_client_t **, cef_browser_settings_t *, cef_dictionary_value_t **, int *, int >)on_before_popup)(self, browser, frame, target_url, target_frame_name, target_disposition, user_gesture, popupFeatures, windowInfo, client, settings, extra_info, no_javascript_access));
     }
 }
示例#26
0
 public unsafe extern int OnBeforePopup(cef_browser_t *browser, cef_frame_t *frame, [Immutable] cef_string_t *target_url, [Immutable] cef_string_t *target_frame_name, CefWindowOpenDisposition target_disposition, int user_gesture, [Immutable] cef_popup_features_t *popupFeatures, cef_window_info_t *windowInfo, cef_client_t **client, cef_browser_settings_t *settings, cef_dictionary_value_t **extra_info, int *no_javascript_access);
示例#27
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);
        }
示例#28
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));
 }
 /// <summary>
 /// Called on the IO thread before a new popup browser is created. The
 /// |browser| and |frame| values represent the source of the popup request. The
 /// |target_url| and |target_frame_name| values indicate where the popup
 /// browser should navigate and may be empty if not specified with the request.
 /// The |target_disposition| value indicates where the user intended to open
 /// the popup (e.g. current tab, new tab, etc). The |user_gesture| 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). The |popupFeatures| structure contains additional
 /// information about the requested popup window. To allow creation of the
 /// popup browser optionally modify |windowInfo|, |client|, |settings| and
 /// |no_javascript_access| and return false. To cancel creation of the popup
 /// browser return true. The |client| and |settings| values will default to the
 /// source browser's values. If the |no_javascript_access| 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. Any modifications to
 /// |windowInfo| will be ignored if the parent browser is wrapped in a
 /// CefBrowserView.
 /// </summary>
 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 bool noJavascriptAccess)
 {
     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)
        {
            _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);
        }