[epiphany] embed: Ignore beforeunload events



commit 08eb12b3bb538f96b23bc2ac7bf21e360b085b4d
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Tue Jan 19 09:52:01 2016 +0100

    embed: Ignore beforeunload events
    
    At least until we properly support them. Connect to WebKitWebView::script-dialog
    to always confirm we want to leave the page and stop the signal
    propagation.

 embed/ephy-web-view.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 5075efb..dabffa4 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2102,6 +2102,23 @@ zoom_changed_cb (WebKitWebView *web_view,
   }
 }
 
+#if WEBKIT_CHECK_VERSION(2, 11, 3)
+static gboolean
+script_dialog_cb (WebKitWebView *web_view,
+                  WebKitScriptDialog *dialog)
+{
+  if (webkit_script_dialog_get_dialog_type (dialog) != WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM)
+    return FALSE;
+
+  /* Ignore beforeunload events for now until we properly support webkit_web_view_try_close()
+   * See https://bugzilla.gnome.org/show_bug.cgi?id=722032.
+   */
+  webkit_script_dialog_confirm_set_confirmed (dialog, TRUE);
+
+  return TRUE;
+}
+#endif
+
 static void
 ephy_web_view_init (EphyWebView *web_view)
 {
@@ -2166,6 +2183,12 @@ ephy_web_view_init (EphyWebView *web_view)
                     G_CALLBACK (icon_changed_cb),
                     NULL);
 
+#if WEBKIT_CHECK_VERSION(2, 11, 3)
+  g_signal_connect (web_view, "script-dialog",
+                    G_CALLBACK (script_dialog_cb),
+                    NULL);
+#endif
+
   g_signal_connect (web_view, "new-window",
                     G_CALLBACK (new_window_cb),
                     NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]