[epiphany/gnome-40] window: launch URLs whenever triggered by user gesture



commit ce013449d501aee57894db38f1764e33db3e7d27
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Mon Apr 19 10:54:56 2021 -0500

    window: launch URLs whenever triggered by user gesture
    
    Currently we check the default app for the URI scheme and call
    gtk_show_uri_on_window() only if the default app is not NULL and is not
    Epiphany. This fails under flatpak because there we cannot check the
    user's default apps. It is always NULL, so we bail out and refuse to
    launch any app for the URL. Oops.
    
    This code was originally added to prevent us from launching Epiphany in
    a recursive loop if it somehow gets registered as the default handler
    for a scheme that it doesn't actually support, as in #1053. In this
    case, we should only relaunch ourselves once because the second launch
    will be triggered by API request, when the new instance calls
    webkit_web_view_load_uri(). That's not a user gesture and will avoid the
    recursion.
    
    This change also prevents websites from opening URLs without user
    intervention.
    
    Thanks to Adrian Perez for proposing this solution!
    
    Fixes #1385
    
    Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/951>
    
    
    (cherry picked from commit 6c223bb8b3e75026eeecc61424e5a73649aca1f2)

 src/ephy-window.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index ab948eeff..c760d20c1 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2121,27 +2121,15 @@ decide_navigation_policy (WebKitWebView            *web_view,
   request = webkit_navigation_action_get_request (navigation_action);
   uri = webkit_uri_request_get_uri (request);
 
-  if (!ephy_embed_utils_address_has_web_scheme (uri)) {
-    g_autoptr (SoupURI) soup_uri = soup_uri_new (uri);
-
-    if (soup_uri) {
-      g_autoptr (GAppInfo) app_info = g_app_info_get_default_for_uri_scheme (soup_uri->scheme);
-
-      if (app_info && !g_str_has_prefix (g_app_info_get_id (app_info), "org.gnome.Epiphany")) {
-        g_autoptr (GError) error = NULL;
-
-        gtk_show_uri_on_window (GTK_WINDOW (window), uri, GDK_CURRENT_TIME, &error);
-
-        if (error) {
-          LOG ("failed to handle non web scheme: %s", error->message);
-          g_error_free (error);
-          return accept_navigation_policy_decision (window, decision, uri);
-        }
-      }
+  if (!ephy_embed_utils_address_has_web_scheme (uri) && webkit_navigation_action_is_user_gesture 
(navigation_action)) {
+    g_autoptr (GError) error = NULL;
+    gtk_show_uri_on_window (GTK_WINDOW (window), uri, GDK_CURRENT_TIME, &error);
+    if (error) {
+      LOG ("failed to handle non-web scheme: %s", error->message);
+      return accept_navigation_policy_decision (window, decision, uri);
     }
 
     webkit_policy_decision_ignore (decision);
-
     return TRUE;
   }
 


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