aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/org.gnome.epiphany.gschema.xml5
-rw-r--r--embed/ephy-embed.c34
-rw-r--r--lib/ephy-prefs.h1
3 files changed, 39 insertions, 1 deletions
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index 7437c85f4..f97681e40 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -189,6 +189,11 @@
<summary>Do Not Track</summary>
<description>Whether to tell websites that we do not wish to be tracked. Please note that web pages are not forced to follow this setting.</description>
</key>
+ <key type="b" name="enable-adblock">
+ <default>false</default>
+ <summary>Enable Adblock</summary>
+ <description>Whether to block the embedded advertisements that web pages might want to show.</description>
+ </key>
</schema>
<schema path="/org/gnome/epiphany/state/" id="org.gnome.Epiphany.state">
<key type="s" name="open-dir">
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index cd1174884..c6c757954 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -96,6 +96,8 @@ struct _EphyEmbedPrivate
gulong status_handler_id;
gulong progress_update_handler_id;
+
+ gulong adblock_handler_id;
};
enum
@@ -408,6 +410,11 @@ ephy_embed_dispose (GObject *object)
priv->fullscreen_message_id = 0;
}
+ if (priv->adblock_handler_id) {
+ g_signal_handler_disconnect (priv->web_view, priv->adblock_handler_id);
+ priv->adblock_handler_id = 0;
+ }
+
G_OBJECT_CLASS (ephy_embed_parent_class)->dispose (object);
}
@@ -824,6 +831,26 @@ progress_update (EphyWebView *view, GParamSpec *pspec, EphyEmbed *embed)
(loading || progress == 1.0) ? progress : 0.0);
}
+#ifndef HAVE_WEBKIT2
+static void
+setup_adblock (GSettings *settings,
+ char *key,
+ EphyEmbed *embed)
+{
+ EphyEmbedPrivate *priv = embed->priv;
+ EphyWebView *web_view = ephy_embed_get_web_view (embed);
+
+ if (g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_ADBLOCK) &&
+ priv->adblock_handler_id == 0) {
+ priv->adblock_handler_id = g_signal_connect (web_view, "resource_request_starting",
+ G_CALLBACK (resource_request_starting_cb), embed);
+ } else if (priv->adblock_handler_id) {
+ g_signal_handler_disconnect (web_view, priv->adblock_handler_id);
+ priv->adblock_handler_id = 0;
+ }
+}
+#endif
+
static void
ephy_embed_constructed (GObject *object)
{
@@ -919,11 +946,16 @@ ephy_embed_constructed (GObject *object)
#else
g_object_connect (web_view,
"signal::notify::load-status", G_CALLBACK (load_status_changed_cb), embed,
- "signal::resource-request-starting", G_CALLBACK (resource_request_starting_cb), embed,
"signal::download-requested", G_CALLBACK (download_requested_cb), embed,
"signal::entering-fullscreen", G_CALLBACK (entering_fullscreen_cb), embed,
"signal::leaving-fullscreen", G_CALLBACK (leaving_fullscreen_cb), embed,
NULL);
+
+ g_signal_connect (EPHY_SETTINGS_WEB,
+ "changed::" EPHY_PREFS_WEB_ENABLE_ADBLOCK,
+ G_CALLBACK (setup_adblock), embed);
+
+ setup_adblock (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_ADBLOCK, embed);
#endif
priv->status_handler_id = g_signal_connect (web_view, "notify::status-message",
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index a5b182d50..ccc7238d8 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -108,6 +108,7 @@ typedef enum
#define EPHY_PREFS_WEB_IMAGE_ANIMATION_MODE "image-animation-mode"
#define EPHY_PREFS_WEB_DEFAULT_ENCODING "default-encoding"
#define EPHY_PREFS_WEB_DO_NOT_TRACK "do-not-track"
+#define EPHY_PREFS_WEB_ENABLE_ADBLOCK "enable-adblock"
#define EPHY_PREFS_SCHEMA "org.gnome.Epiphany"
#define EPHY_PREFS_USER_AGENT "user-agent"