[epiphany] Remove referrer in ephy_web_application_is_uri_allowed () and use webapp url directly



commit 8b76f3f1e3099c4fd37d081488613cc802f13e8c
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Fri May 3 14:03:12 2019 +0200

    Remove referrer in ephy_web_application_is_uri_allowed () and use webapp url directly
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/558

 lib/ephy-web-app-utils.c |  6 +++---
 lib/ephy-web-app-utils.h |  2 +-
 src/ephy-window.c        | 19 ++-----------------
 3 files changed, 6 insertions(+), 21 deletions(-)
---
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index 63596f0b9..684b84a58 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -782,9 +782,9 @@ urls_have_same_origin (const char *a_url,
 }
 
 gboolean
-ephy_web_application_is_uri_allowed (const char *uri,
-                                     const char *referrer)
+ephy_web_application_is_uri_allowed (const char *uri)
 {
+  EphyWebApplication *webapp = ephy_web_application_for_profile_directory (ephy_profile_dir ());
   SoupURI *request_uri;
   char **urls;
   guint i;
@@ -793,7 +793,7 @@ ephy_web_application_is_uri_allowed (const char *uri,
   if (g_str_has_prefix (uri, "blob:") || g_str_has_prefix (uri, "data:"))
     return TRUE;
 
-  if (urls_have_same_origin (uri, referrer))
+  if (urls_have_same_origin (uri, webapp->url))
     return TRUE;
 
   if (g_strcmp0 (uri, "about:blank") == 0)
diff --git a/lib/ephy-web-app-utils.h b/lib/ephy-web-app-utils.h
index 3080f9970..1d436858c 100644
--- a/lib/ephy-web-app-utils.h
+++ b/lib/ephy-web-app-utils.h
@@ -67,7 +67,7 @@ void                ephy_web_application_free_application_list (GList *list);
 
 void                ephy_web_application_initialize_settings (const char *profile_directory);
 
-gboolean            ephy_web_application_is_uri_allowed (const char *uri, const char *referrer);
+gboolean            ephy_web_application_is_uri_allowed (const char *uri);
 
 gboolean            ephy_web_application_save (EphyWebApplication *app);
 
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 3ee503194..81a75977a 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1931,17 +1931,6 @@ web_view_ready_cb (WebKitWebView *web_view,
     g_signal_emit_by_name (parent_web_view, "new-window", web_view);
   }
 
-  if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION &&
-      !webkit_web_view_get_uri (web_view)) {
-    /* Wait until we have a valid URL to decide whether to show the window
-     * or load the URL in the default web browser
-     */
-    g_object_set_data_full (G_OBJECT (window), "referrer",
-                            g_strdup (webkit_web_view_get_uri (parent_web_view)),
-                            g_free);
-    return TRUE;
-  }
-
   gtk_widget_show (GTK_WIDGET (window));
 
   return TRUE;
@@ -2075,11 +2064,7 @@ decide_navigation_policy (WebKitWebView            *web_view,
 
   if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION) {
     if (!gtk_widget_is_visible (GTK_WIDGET (window))) {
-      char *referrer;
-
-      referrer = (char *)g_object_get_data (G_OBJECT (window), "referrer");
-
-      if (ephy_web_application_is_uri_allowed (uri, referrer)) {
+      if (ephy_web_application_is_uri_allowed (uri)) {
         gtk_widget_show (GTK_WIDGET (window));
       } else {
         /* We can't get here under flatpak because this code only
@@ -2098,7 +2083,7 @@ decide_navigation_policy (WebKitWebView            *web_view,
 
     if (navigation_type == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED ||
         (navigation_type == WEBKIT_NAVIGATION_TYPE_OTHER && webkit_navigation_action_is_user_gesture 
(navigation_action))) {
-      if (ephy_web_application_is_uri_allowed (uri, webkit_web_view_get_uri (web_view)))
+      if (ephy_web_application_is_uri_allowed (uri))
         return FALSE;
 
       /* We can't get here under flatpak because this code only


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