Exemple #1
0
        /// <summary>
        /// </summary>
        protected virtual void WebBrowserBeforeNavigateHandler(object sender, WebBrowserBeforeNavigateEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                e.Cancel = true;
                return;
            }

            if (_webBrowser.IsDisposed)
            {
                // we cancel all flows in disposed object and just do nothing, let object to close.
                // it just for safety.
                e.Cancel = true;
                return;
            }

            if (_key == Keys.Back)
            {
                //navigation is being done via back key. This needs to be disabled.
                _key     = Keys.None;
                e.Cancel = true;
            }

            if (string.IsNullOrEmpty(e.Url))
            {
                RequestContext.Logger.Verbose("[Legacy WebView] URL in BeforeNavigate is null or empty.");
                e.Cancel = true;
                return;
            }

            Uri url = new Uri(e.Url);

            // we cancel further processing, if we reached final URL.
            // Security issue: we prohibit navigation with auth code
            // if redirect URI is URN, then we prohibit navigation, to prevent random browser pop-up.
            e.Cancel = CheckForClosingUrl(url, e.PostData);

            // check if the URL scheme is of type browser-install://
            // this means we need to launch external browser
            if (url.Scheme.Equals("browser", StringComparison.OrdinalIgnoreCase))
            {
                Process.Start(url.AbsoluteUri.Replace("browser://", "https://"));
                e.Cancel = true;
            }

            if (!e.Cancel)
            {
                string urlDecode = CoreHelpers.UrlDecode(e.Url.ToString());
                RequestContext.Logger.VerbosePii(
                    string.Format(CultureInfo.InvariantCulture, "[Legacy WebView] Navigating to '{0}'.", urlDecode),
                    string.Empty);
            }
        }
            public void BeforeNavigate2(object pDisp, ref object url, ref object flags, ref object targetFrameName,
                                        ref object postData, ref object headers, ref bool cancel)
            {
                string urlString             = (url == null) ? string.Empty : ((string)url);
                int    flagsInt              = (flags == null) ? 0 : ((int)flags);
                string targetFrameNameString = (targetFrameName == null) ? string.Empty : ((string)targetFrameName);

                byte[] postDataBytes = (byte[])postData;
                string headersString = (headers == null) ? string.Empty : ((string)headers);

                WebBrowserBeforeNavigateEventArgs e = new WebBrowserBeforeNavigateEventArgs(urlString, postDataBytes,
                                                                                            headersString, flagsInt, targetFrameNameString, pDisp);

                parent.OnBeforeNavigate(e);
                cancel = e.Cancel;
            }
        /// <summary>
        /// </summary>
        protected override void WebBrowserBeforeNavigateHandler(object sender, WebBrowserBeforeNavigateEventArgs e)
        {
            if (null == timer)
            {
                timer = CreateStartedTimer(
                    () =>
                {
                    DateTime now = DateTime.Now;
                    if (now > navigationExpiry)
                    {
                        OnUserInteractionRequired();
                    }
                },
                    NavigationWaitMiliSecs);
            }

            // We don't timeout each individual navigation, only the time between individual navigations.
            // Reset the expiry time so that it isn't relevant until the next document complete.
            navigationExpiry = DateTime.MaxValue;

            base.WebBrowserBeforeNavigateHandler(sender, e);
        }
Exemple #4
0
#pragma warning restore 618

        protected virtual void OnBeforeNavigate(WebBrowserBeforeNavigateEventArgs e)
        {
            BeforeNavigate?.Invoke(this, e);
        }
 /// <summary>
 /// </summary>
 protected override void WebBrowserBeforeNavigateHandler(object sender, WebBrowserBeforeNavigateEventArgs e)
 {
     SetBrowserZoom();
     base.WebBrowserBeforeNavigateHandler(sender, e);
 }