[epiphany/gnome-3-18] web-view: limit permission request info bars
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-18] web-view: limit permission request info bars
- Date: Sat, 10 Sep 2016 21:50:09 +0000 (UTC)
commit 2b8ac84b471a872f022a6c383c710f134c240096
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Aug 7 22:04:19 2016 -0500
web-view: limit permission request info bars
Else a web page can fill the browser window with unlimited notification
permission requests. Limit ourselves to one info bar per permission
request type, same as we already limit ourselves to one password info
bar.
https://bugzilla.gnome.org/show_bug.cgi?id=764593
embed/ephy-web-view.c | 59 +++++++++++++++++++++++++++++++++++-------------
1 files changed, 43 insertions(+), 16 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index ba07fbd..d651a3a 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -95,6 +95,8 @@ struct _EphyWebViewPrivate {
GSList *hidden_popups;
GSList *shown_popups;
+ GtkWidget *geolocation_info_bar;
+ GtkWidget *notification_info_bar;
GtkWidget *password_info_bar;
EphyHistoryService *history_service;
@@ -478,6 +480,26 @@ ephy_web_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
return GTK_WIDGET_CLASS (ephy_web_view_parent_class)->button_press_event (widget, event);
}
+static void
+ephy_web_view_track_info_bar (GtkWidget *new_info_bar,
+ GtkWidget **tracked_info_bar)
+{
+ g_assert (GTK_IS_INFO_BAR (new_info_bar));
+ g_assert (tracked_info_bar);
+ g_assert (!*tracked_info_bar || GTK_IS_INFO_BAR (*tracked_info_bar));
+
+ /* We track info bars so we only ever show one of a kind. */
+ if (*tracked_info_bar) {
+ g_object_remove_weak_pointer (G_OBJECT (*tracked_info_bar),
+ (gpointer *)tracked_info_bar);
+ gtk_widget_destroy (*tracked_info_bar);
+ }
+
+ *tracked_info_bar = new_info_bar;
+ g_object_add_weak_pointer (G_OBJECT (new_info_bar),
+ (gpointer *)tracked_info_bar);
+}
+
static GtkWidget *
ephy_web_view_create_form_auth_save_confirmation_info_bar (EphyWebView *web_view,
const char *hostname,
@@ -513,20 +535,11 @@ ephy_web_view_create_form_auth_save_confirmation_info_bar (EphyWebView *web_view
gtk_container_add (GTK_CONTAINER (content_area), label);
gtk_widget_show (label);
+ ephy_web_view_track_info_bar (info_bar, &web_view->priv->password_info_bar);
+
ephy_embed_add_top_widget (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
info_bar, FALSE);
- if (web_view->priv->password_info_bar) {
- g_object_remove_weak_pointer (G_OBJECT (web_view->priv->password_info_bar),
- (gpointer *)&web_view->priv->password_info_bar);
- gtk_widget_destroy (web_view->priv->password_info_bar);
- }
-
- /* We track the info_bar, so we only ever show one */
- web_view->priv->password_info_bar = info_bar;
- g_object_add_weak_pointer (G_OBJECT (info_bar),
- (gpointer *)&web_view->priv->password_info_bar);
-
return info_bar;
}
@@ -754,11 +767,20 @@ ephy_web_view_dispose (GObject *object)
priv->web_extension = NULL;
}
- if (priv->password_info_bar)
- {
- g_object_remove_weak_pointer (G_OBJECT (priv->password_info_bar), (gpointer
*)&priv->password_info_bar);
- priv->password_info_bar = NULL;
- }
+ if (priv->geolocation_info_bar) {
+ g_object_remove_weak_pointer (G_OBJECT (priv->geolocation_info_bar), (gpointer
*)&priv->geolocation_info_bar);
+ priv->geolocation_info_bar = NULL;
+ }
+
+ if (priv->notification_info_bar) {
+ g_object_remove_weak_pointer (G_OBJECT (priv->notification_info_bar), (gpointer
*)&priv->notification_info_bar);
+ priv->notification_info_bar = NULL;
+ }
+
+ if (priv->password_info_bar) {
+ g_object_remove_weak_pointer (G_OBJECT (priv->password_info_bar), (gpointer *)&priv->password_info_bar);
+ priv->password_info_bar = NULL;
+ }
g_signal_handlers_disconnect_by_func (priv->history_service,
ephy_web_view_history_cleared_cb,
@@ -1475,6 +1497,11 @@ permission_request_cb (WebKitWebView *web_view,
G_CALLBACK (decide_on_permission_request),
g_object_ref (decision));
+ if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST (decision))
+ ephy_web_view_track_info_bar (info_bar, &EPHY_WEB_VIEW (web_view)->priv->geolocation_info_bar);
+ else
+ ephy_web_view_track_info_bar (info_bar, &EPHY_WEB_VIEW (web_view)->priv->notification_info_bar);
+
ephy_embed_add_top_widget (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
info_bar, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]