Beispiel #1
0
        private void FormsWebView_OnNavigationStarted(object sender, DecisionHandlerDelegate e)
        {
            System.Diagnostics.Debug.WriteLine("Navigation has started");
            System.Diagnostics.Debug.WriteLine($"Will cancel: {ViewModel.IsCancelled}");

            e.Cancel = ViewModel.IsCancelled;
        }
 private void SetCurrentUrl(object sender, DecisionHandlerDelegate e)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         Element.CurrentUrl = e.Uri;
     });
 }
 private void stringContent_OnNavigationStarted(object sender, DecisionHandlerDelegate e)
 {
     if (e.Uri.Contains("bbc.co.uk"))
     {
         e.OffloadOntoDevice = true;
     }
 }
Beispiel #4
0
        public override WebResourceResponse ShouldInterceptRequest(Android.Webkit.WebView view,
                                                                   IWebResourceRequest request)
        {
            if (Reference == null || !Reference.TryGetTarget(out FormsWebViewRenderer renderer))
            {
                goto EndShouldInterceptRequest;
            }
            if (renderer.Element == null)
            {
                goto EndShouldInterceptRequest;
            }

            var url = request.Url.ToString();
            DecisionHandlerDelegate response = renderer.Element.HandleNavigationStartRequest(url);

            if (response.Cancel || response.OffloadOntoDevice)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    if (response.OffloadOntoDevice)
                    {
                        AttemptToHandleCustomUrlScheme(view, url);
                    }

                    view.StopLoading();
                });
            }

EndShouldInterceptRequest:
            return(base.ShouldInterceptRequest(view, request));
        }
Beispiel #5
0
        private void CheckResponseValidity(Android.Webkit.WebView view, string url)
        {
            if (Reference == null || !Reference.TryGetTarget(out FormsWebViewRenderer renderer))
            {
                return;
            }
            if (renderer.Element == null)
            {
                return;
            }

            DecisionHandlerDelegate response = renderer.Element.HandleNavigationStartRequest(url);

            if (response.Cancel || response.OffloadOntoDevice)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    if (response.OffloadOntoDevice)
                    {
                        AttemptToHandleCustomUrlScheme(view, url);
                    }

                    view.StopLoading();
                });
            }
        }
        private void SetCurrentUrl(object sender, DecisionHandlerDelegate e)
        {
            if (Element == null || Control == null || Control.Disposed)
            {
                return;
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                if (Element == null || Control == null || Control.Disposed)
                {
                    return;
                }

                Element.CurrentUrl = Control.Url;
            });
        }
Beispiel #7
0
        private void LoadFromString()
        {
            if (Element == null || Control == null || Element.Source == null)
            {
                return;
            }

            // Check cancellation
            DecisionHandlerDelegate handler = Element.HandleNavigationStartRequest(Element.Source);

            if (handler.Cancel)
            {
                return;
            }

            // Load
            Control.LoadDataWithBaseURL(Element.BaseUrl ?? BaseUrl, Element.Source, MimeType, EncodingType, HistoryUri);
        }
Beispiel #8
0
 private void FormsWebView_OnNavigationStarted(object sender, DecisionHandlerDelegate e)
 {
     System.Diagnostics.Debug.WriteLine("Navigation has started");
 }