public override void OnPageStarted(global::Android.Webkit.WebView view, string url, Bitmap favicon)
        {
            if (_renderer?.Element == null || url == HybridWebViewRenderer.AssetBaseUrl)
            {
                return;
            }

            var args = new WebNavigatingEventArgs(WebNavigationEvent.NewPage, new UrlWebViewSource {
                Url = url
            }, url);

            _renderer.ElementController.SendNavigating(args);
            _navigationResult = WebNavigationResult.Success;

            _renderer.UpdateCanGoBackForward();

            if (args.Cancel)
            {
                _renderer.Control.StopLoading();
            }
            else
            {
                base.OnPageStarted(view, url, favicon);
            }
        }
        public override void OnPageStarted(AWebView view, string url, Bitmap favicon)
        {
            if (view is null)
            {
                throw new ArgumentNullException(nameof(view));
            }

            if (_renderer?.Element == null || _webView == null || string.IsNullOrWhiteSpace(url) || url == WebViewRenderer.AssetBaseUrl)
            {
                return;
            }

            _renderer.SyncNativeCookiesToElement(url);
            var cancel = false;

            if (!url.Equals(_renderer.UrlCanceled, StringComparison.OrdinalIgnoreCase))
            {
                cancel = SendNavigatingCanceled(url);
            }

            _renderer.UrlCanceled = null;

            if (cancel)
            {
                _navigationResult = WebNavigationResult.Cancel;
                view.StopLoading();
            }
            else
            {
                _navigationResult = WebNavigationResult.Success;
                base.OnPageStarted(view, url, favicon);
                _webView.HandleNavigationStarting(new Uri(url));
            }
        }
			public override void OnReceivedError(AWebView view, IWebResourceRequest request, WebResourceError error)
			{
				_navigationResult = WebNavigationResult.Failure;
				if (error.ErrorCode == ClientError.Timeout)
					_navigationResult = WebNavigationResult.Timeout;
				base.OnReceivedError(view, request, error);
			}
Esempio n. 4
0
        public override void OnPageStarted(WebView?view, string?url, Bitmap?favicon)
        {
            if (_handler?.VirtualView == null || url == WebViewHandler.AssetBaseUrl)
            {
                return;
            }

            // TODO: Sync Cookies

            var cancel = false;

            if (!GetValidUrl(url).Equals(_handler.UrlCanceled, StringComparison.OrdinalIgnoreCase))
            {
                cancel = NavigatingCanceled(url);
            }

            _handler.UrlCanceled = null;

            if (cancel)
            {
                _navigationResult = WebNavigationResult.Cancel;
                view?.StopLoading();
            }
            else
            {
                _navigationResult = WebNavigationResult.Success;
                base.OnPageStarted(view, url, favicon);
            }
        }
        public override void OnPageStarted(WView view, string url, Bitmap favicon)
        {
            if (_renderer == null || string.IsNullOrWhiteSpace(url) || url == WebViewRenderer.AssetBaseUrl)
            {
                return;
            }

            var cancel = false;

            if (!url.Equals(_renderer.UrlCanceled, StringComparison.OrdinalIgnoreCase))
            {
                cancel = SendNavigatingCanceled(url);
            }
            _renderer.UrlCanceled = null;

            if (cancel)
            {
                _navigationResult = WebNavigationResult.Cancel;
                view.StopLoading();
            }
            else
            {
                _navigationResult = WebNavigationResult.Success;
                base.OnPageStarted(view, url, favicon);
            }
        }
			public override void OnReceivedError(AWebView view, ClientError errorCode, string description, string failingUrl)
			{
				_navigationResult = WebNavigationResult.Failure;
				if (errorCode == ClientError.Timeout)
					_navigationResult = WebNavigationResult.Timeout;
#pragma warning disable 618
				base.OnReceivedError(view, errorCode, description, failingUrl);
#pragma warning restore 618
			}
Esempio n. 7
0
        void SendNavigated(UrlWebViewSource source, WebNavigationEvent evnt, WebNavigationResult result)
        {
            _isUpdating = true;
            ((IElementController)Element).SetValueFromRenderer(WebView.SourceProperty, source);
            _isUpdating = false;

            Element.SendNavigated(new WebNavigatedEventArgs(evnt, source, source.Url, result));

            UpdateCanGoBackForward();
            _eventState = WebNavigationEvent.NewPage;
        }
Esempio n. 8
0
 public override void OnReceivedError(WView view, IWebResourceRequest request, WebResourceError error)
 {
     if (request.Url.ToString() == _renderer?.Control.Url)
     {
         _navigationResult = WebNavigationResult.Failure;
         if (error.ErrorCode == ClientError.Timeout)
         {
             _navigationResult = WebNavigationResult.Timeout;
         }
     }
     base.OnReceivedError(view, request, error);
 }
			public override bool ShouldOverrideUrlLoading(AWebView view, string url)
			{
				if (_renderer.Element == null)
					return true;

				var args = new WebNavigatingEventArgs(WebNavigationEvent.NewPage, new UrlWebViewSource { Url = url }, url);

				_renderer.ElementController.SendNavigating(args);
				_navigationResult = WebNavigationResult.Success;

				_renderer.UpdateCanGoBackForward();
				return args.Cancel;
			}
Esempio n. 10
0
        public override void OnReceivedError(WebView?view, IWebResourceRequest?request, WebResourceError?error)
        {
            if (request != null && request.Url?.ToString() == _handler?.PlatformView.Url)
            {
                _navigationResult = WebNavigationResult.Failure;

                if (error?.ErrorCode == ClientError.Timeout)
                {
                    _navigationResult = WebNavigationResult.Timeout;
                }
            }

            base.OnReceivedError(view, request, error);
        }
        public override void OnReceivedError(AWebView view, IWebResourceRequest request, WebResourceError error)
        {
            if (error is null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            _navigationResult = WebNavigationResult.Failure;
            if (error.ErrorCode == ClientError.Timeout)
            {
                _navigationResult = WebNavigationResult.Timeout;
            }

            base.OnReceivedError(view, request, error);
        }
Esempio n. 12
0
        public override void OnPageStarted(WView view, string url, Bitmap favicon)
        {
            if (_renderer == null || string.IsNullOrWhiteSpace(url) || url == WebViewRenderer.AssetBaseUrl)
            {
                return;
            }

            if (_renderer?.Element?.ShouldManageCookies == true)
            {
                var cookieManager = CookieManager.Instance;
                cookieManager.SetAcceptCookie(true);
                cookieManager.RemoveAllCookie();
                var cookies = _renderer.Element.Cookies?.GetCookies(new System.Uri(url));
                for (var i = 0; i < (cookies?.Count ?? -1); i++)
                {
                    string cookieValue  = cookies[i].Value;
                    string cookieDomain = cookies[i].Domain;
                    string cookieName   = cookies[i].Name;
                    cookieManager.SetCookie(cookieDomain, cookieName + "=" + cookieValue);
                }
            }

            var cancel = false;

            if (!url.Equals(_renderer.UrlCanceled, StringComparison.OrdinalIgnoreCase))
            {
                cancel = SendNavigatingCanceled(url);
            }
            _renderer.UrlCanceled = null;

            if (cancel)
            {
                _navigationResult = WebNavigationResult.Cancel;
                view.StopLoading();
            }
            else
            {
                _navigationResult = WebNavigationResult.Success;
                base.OnPageStarted(view, url, favicon);
            }
        }
Esempio n. 13
0
 public WebNavigatedEventArgs(WebNavigationEvent navigationEvent, WebViewSource source, string url, WebNavigationResult result) : base(navigationEvent, source, url)
 {
     Result = result;
 }
Esempio n. 14
0
        public MauiWebViewClient(WebViewHandler handler)
        {
            _handler = handler ?? throw new ArgumentNullException("handler");

            _navigationResult = WebNavigationResult.Success;
        }
Esempio n. 15
0
 public void Navigated(WebNavigationEvent evnt, string url, WebNavigationResult result)
 {
 }
Esempio n. 16
0
		public WebNavigatedEventArgs(WebNavigationEvent navigationEvent, WebViewSource source, string url, WebNavigationResult result) : base(navigationEvent, source, url)
		{
			Result = result;
		}