Ejemplo n.º 1
0
        private void LoadCallback(IntPtr webview, WebKitLoadEvent type, IntPtr userdata)
        {
            if (type == WebKitLoadEvent.Started)
            {
                loadEventHandled = false;
            }

            // this callback gets called in this order:
            // Started: initially defined URL
            // Redirected (optional, multiple): new URL to which the redirect points
            // Committed: final URL that gets loaded, either initial URL or same as last redirect URL
            // Finished: same URL as committed, page has fully loaded
            if (type == WebKitLoadEvent.Started || type == WebKitLoadEvent.Redirected)
            {
                string url  = GLibString.FromPointer(WebKit.GetCurrentUri(webview));
                var    args = new NavigatingEventArgs(new Uri(url));
                Navigating?.Invoke(this, args);
                if (args.Cancel)
                {
                    WebKit.StopLoading(webview);
                }
            }
            else if (type == WebKitLoadEvent.Finished && !loadEventHandled)
            {
                if (EnableDevTools)
                {
                    ShowDevTools();
                }

                loadEventHandled = true;
            }
        }
Ejemplo n.º 2
0
 private bool LoadFailedCallback(IntPtr webview, WebKitLoadEvent type, IntPtr failingUrl, IntPtr error, IntPtr userdata)
 {
     // this event is called when there is an error, immediately afterwards the LoadCallback is called with state Finished.
     // to indicate that there was an error and the PageLoaded event has been invoked, the loadEventHandled variable is set to true.
     loadEventHandled = true;
     return(false);
 }
Ejemplo n.º 3
0
        private bool LoadFailedCallback(IntPtr webview, WebKitLoadEvent type, IntPtr failingUrl, IntPtr error, IntPtr userdata)
        {
            // this event is called when there is an error, immediately afterwards the LoadCallback is called with state Finished.
            // to indicate that there was an error and the PageLoaded event has been invoked, the loadEventHandled variable is set to true.
            loadEventHandled = true;
            string url = GLibString.FromPointer(failingUrl);

            PageLoaded?.Invoke(this, new PageLoadEventArgs(new Uri(url), false));

            return(false);
        }
Ejemplo n.º 4
0
        private async void LoadCallback(IntPtr webview, WebKitLoadEvent type, IntPtr userdata)
        {
            if (type == WebKitLoadEvent.Started)
            {
                loadEventHandled = false;
            }
            else if (type == WebKitLoadEvent.Finished && !loadEventHandled)
            {
                if (config.EnableScriptInterface)
                {
                    string initScript = Resources.GetInitScript("Linux");
                    await ExecuteScriptAsync(initScript);
                }

                loadEventHandled = true;
                PageLoaded?.Invoke(this, PageLoadEventArgs.Successful);
            }
        }