Exemplo n.º 1
0
 async void OnWebMessageReceived(WWebView sender, Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e)
 {
     if (Element.OnThisPlatform().IsJavaScriptAlertEnabled())
     {
         await new global::Windows.UI.Popups.MessageDialog(e.TryGetWebMessageAsString()).ShowAsync();
     }
 }
Exemplo n.º 2
0
        void OnNavigationStarted(WWebView sender, Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs e)
        {
            // TODO WINUI3
            //Uri uri = e.Uri;

            //if (uri != null)
            //{
            Uri uri;

            if (Uri.TryCreate(e.Uri, UriKind.Absolute, out uri) && uri != null)
            {
                var args = new WebNavigatingEventArgs(_eventState, new UrlWebViewSource {
                    Url = uri.AbsoluteUri
                }, uri.AbsoluteUri);

                WebViewController.SendNavigating(args);
                e.Cancel = args.Cancel;

                // reset in this case because this is the last event we will get
                if (args.Cancel)
                {
                    _eventState = WebNavigationEvent.NewPage;
                }
            }
        }
Exemplo n.º 3
0
        void NavigationFailed(WWebView sender, Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
        {
            Uri uri = sender.Source;

            if (uri != null)
            {
                SendNavigated(new UrlWebViewSource {
                    Url = uri.AbsoluteUri
                }, _eventState, WebNavigationResult.Failure);
            }
        }
Exemplo n.º 4
0
 void OnNavigationCompleted(WWebView sender, Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
 {
     if (e.IsSuccess)
     {
         NavigationSucceeded(sender, e);
     }
     else
     {
         NavigationFailed(sender, e);
     }
 }
Exemplo n.º 5
0
 void TearDown(WWebView webView)
 {
     if (webView == null)
     {
         return;
     }
     webView.NavigationStarting  -= OnNavigationStarted;
     webView.NavigationCompleted -= OnNavigationCompleted;
     webView.CoreProcessFailed   -= OnCoreProcessFailed;
     webView.WebMessageReceived  -= OnWebMessageReceived;
 }
Exemplo n.º 6
0
        void Connect(WWebView webView)
        {
            if (webView == null)
            {
                return;
            }

            webView.CoreProcessFailed   += OnCoreProcessFailed;
            webView.WebMessageReceived  += OnWebMessageReceived;
            webView.NavigationStarting  += OnNavigationStarted;
            webView.NavigationCompleted += OnNavigationCompleted;
        }
Exemplo n.º 7
0
        void Connect(WWebView webView)
        {
            if (webView == null)
            {
                return;
            }

            // TODO WINUI3
            //webView.SeparateProcessLost += OnSeparateProcessLost;
            //webView.NavigationFailed += OnNavigationFailed;
            //webView.ScriptNotify += OnScriptNotify;
            webView.NavigationStarting  += OnNavigationStarted;
            webView.NavigationCompleted += OnNavigationCompleted;
        }
Exemplo n.º 8
0
        void TearDown(WWebView webView)
        {
            if (webView == null)
            {
                return;
            }
            webView.NavigationStarting  -= OnNavigationStarted;
            webView.NavigationCompleted -= OnNavigationCompleted;

            // TODO WINUI3
            //	webView.SeparateProcessLost -= OnSeparateProcessLost;
            //webView.NavigationFailed -= OnNavigationFailed;
            //webView.ScriptNotify -= OnScriptNotify;
        }
Exemplo n.º 9
0
        async void NavigationSucceeded(WWebView sender, Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
        {
            // TODO WINUI3
            //if (e.Uri != null)
            //	SendNavigated(new UrlWebViewSource { Url = e.Uri.AbsoluteUri }, _eventState, WebNavigationResult.Success);
            Uri uri = sender.Source;

            if (uri != null)
            {
                SendNavigated(new UrlWebViewSource {
                    Url = uri.AbsoluteUri
                }, _eventState, WebNavigationResult.Success);
            }

            UpdateCanGoBackForward();

            if (Element.OnThisPlatform().IsJavaScriptAlertEnabled())
            {
                await Control.ExecuteScriptAsync("window.alert = function(message){ window.external.notify(message); };");
            }
        }
Exemplo n.º 10
0
 void OnCoreProcessFailed(WWebView sender, Web.WebView2.Core.CoreWebView2ProcessFailedEventArgs args)
 {
     UpdateExecutionMode();
 }