예제 #1
0
        private void Webview_CreateWindow(object sender, CreateWindowEventArgs e)
        {
            TabControl tabs = this.FindTabControl();

            if (tabs == null)
            {
                e.Cancel = true;
                return;
            }

            var webview = new CustomWebView((CustomWebView)this.WebView);

            e.WindowInfo.SetAsWindowless(IntPtr.Zero);
            e.Client = webview.Client;
            OnCreateWindow(webview);
        }
        /// <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);
        }
예제 #3
0
        private void Webview_CreateWindow(object sender, CreateWindowEventArgs e)
        {
            if (PopupHandlingDisabled)
            {
                return;
            }

            TabControl tabs = this.FindTabControl();

            if (tabs == null)
            {
                e.Cancel = true;
                return;
            }

            var avaloniaWindow = this.GetVisualRoot() as Window;

            if (avaloniaWindow == null)
            {
                throw new InvalidOperationException("Window not found!");
            }

            var webview = new CustomWebView((WebView)this.WebView);

            IPlatformHandle platformHandle = avaloniaWindow.PlatformImpl.Handle;

            if (platformHandle is IMacOSTopLevelPlatformHandle macOSHandle)
            {
                e.WindowInfo.SetAsWindowless(macOSHandle.GetNSWindowRetained());
            }
            else
            {
                e.WindowInfo.SetAsWindowless(platformHandle.Handle);
            }

            e.Client = webview.Client;
            OnCreateWindow(webview);
        }
예제 #4
0
        private void Webview_CreateWindow(object sender, CreateWindowEventArgs e)
        {
            TabControl tabs = this.FindTabControl();

            if (tabs == null)
            {
                e.Cancel = true;
                return;
            }

            var wpfwindow = System.Windows.Window.GetWindow(this);

            if (wpfwindow == null)
            {
                throw new InvalidOperationException("Window not found!");
            }

            var webview = new CustomWebView((WebView)this.WebView);

            e.WindowInfo.SetAsWindowless(new WindowInteropHelper(wpfwindow).Handle);
            e.Client = webview.Client;
            OnCreateWindow(webview);
        }
예제 #5
0
        private void Webview_CreateWindow(object sender, CreateWindowEventArgs e)
        {
            TabControl tabs = this.FindTabControl();

            if (tabs == null)
            {
                e.Cancel = true;
                return;
            }

            var webview = new CustomWebView((CustomWebView)this.WebView);

            if (webview.WindowlessRenderingEnabled)
            {
                e.WindowInfo.SetAsWindowless(webview.Handle);
            }
            else
            {
                e.WindowInfo.SetAsDisabledChild(webview.Handle);
            }
            e.Client = webview.Client;
            OnCreateWindow(webview);
        }
예제 #6
0
 protected virtual void OnCreateWindow(CreateWindowEventArgs e)
 {
     CreateWindow?.Invoke(this, e);
 }
예제 #7
0
 void IChromiumWebViewPrivate.RaiseCefCreateWindow(CreateWindowEventArgs e)
 {
     RaiseCrossThreadEvent(OnCreateWindow, e, true);
 }