[epiphany] web-view: Store permissions for the correct host



commit 6f25bf4aa3f30ae3899dd437ff9c71691ee4b020
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Thu Dec 29 13:41:02 2016 -0600

    web-view: Store permissions for the correct host
    
    Permissions were being saved for the host corresponding to the page the
    web view is currently displaying, which might not be the same as the
    host that's actually shown in the permission request info bar if the
    user has navigated to a new page. This has been broken since
    EphyHostManager was introduced.

 embed/ephy-web-view.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 22d2359..60c2a56 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -683,6 +683,7 @@ icon_changed_cb (EphyWebView *view,
 typedef struct {
   EphyWebView *web_view;
   guint request_id;
+  char *host;
 } FormAuthRequestData;
 
 static void
@@ -704,10 +705,11 @@ form_auth_data_save_confirmation_response (GtkInfoBar          *info_bar,
 
     ephy_hosts_manager_set_permission_for_address (manager,
                                                    EPHY_HOST_PERMISSION_TYPE_SAVE_PASSWORD,
-                                                   ephy_web_view_get_address (data->web_view),
+                                                   data->host,
                                                    EPHY_HOST_PERMISSION_DENY);
   }
 
+  g_free (data->host);
   g_slice_free (FormAuthRequestData, data);
 }
 
@@ -736,6 +738,7 @@ form_auth_data_save_requested (EphyEmbedShell *shell,
   data = g_slice_new (FormAuthRequestData);
   data->web_view = web_view;
   data->request_id = request_id;
+  data->host = g_strdup (hostname);
   g_signal_connect (info_bar, "response",
                     G_CALLBACK (form_auth_data_save_confirmation_response),
                     data);
@@ -1272,6 +1275,7 @@ decide_policy_cb (WebKitWebView           *web_view,
 typedef struct {
   EphyWebView *web_view;
   WebKitPermissionRequest *request;
+  char *host;
 } PermissionRequestData;
 
 static void
@@ -1315,13 +1319,14 @@ decide_on_permission_request (GtkWidget               *info_bar,
 
     ephy_hosts_manager_set_permission_for_address (hosts_manager,
                                                    permission_type,
-                                                   address,
+                                                   data->host,
                                                    response == GTK_RESPONSE_YES ? EPHY_HOST_PERMISSION_ALLOW
                                                                                 : EPHY_HOST_PERMISSION_DENY);
   }
 
   gtk_widget_destroy (info_bar);
   g_object_unref (data->request);
+  g_free (data->host);
   g_slice_free (PermissionRequestData, data);
 }
 
@@ -1375,8 +1380,6 @@ show_permission_request_info_bar (WebKitWebView           *web_view,
     g_assert_not_reached ();
   }
 
-  g_free (host);
-
   label = gtk_label_new (NULL);
   gtk_label_set_markup (GTK_LABEL (label), message);
   gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
@@ -1392,6 +1395,7 @@ show_permission_request_info_bar (WebKitWebView           *web_view,
   data = g_new (PermissionRequestData, 1);
   data->web_view = EPHY_WEB_VIEW (web_view);
   data->request = g_object_ref (decision);
+  data->host = host;
 
   g_signal_connect (info_bar, "response",
                     G_CALLBACK (decide_on_permission_request),


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