コード例 #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;
        }
コード例 #2
0
 private void SetCurrentUrl(object sender, DecisionHandlerDelegate e)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         Element.CurrentUrl = e.Uri;
     });
 }
コード例 #3
0
 private void stringContent_OnNavigationStarted(object sender, DecisionHandlerDelegate e)
 {
     if (e.Uri.Contains("bbc.co.uk"))
     {
         e.OffloadOntoDevice = true;
     }
 }
コード例 #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));
        }
コード例 #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();
                });
            }
        }
コード例 #6
0
        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;
            });
        }
コード例 #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);
        }
コード例 #8
0
 private void FormsWebView_OnNavigationStarted(object sender, DecisionHandlerDelegate e)
 {
     System.Diagnostics.Debug.WriteLine("Navigation has started");
 }