aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gustavo.noronha@collabora.co.uk>2009-07-01 03:29:51 +0800
committerGustavo Noronha Silva <gns@gnome.org>2009-09-08 01:21:27 +0800
commit3d4053a5f71175970712897a298a7ce95d3dfaef (patch)
treec191c19c73d95a0d6c796aa13f9ff1b1437ce8ed /embed
parentdf54608c60a5e12b667620ba8ec87bac379259de (diff)
downloadgsoc2013-epiphany-3d4053a5f71175970712897a298a7ce95d3dfaef.tar
gsoc2013-epiphany-3d4053a5f71175970712897a298a7ce95d3dfaef.tar.gz
gsoc2013-epiphany-3d4053a5f71175970712897a298a7ce95d3dfaef.tar.bz2
gsoc2013-epiphany-3d4053a5f71175970712897a298a7ce95d3dfaef.tar.lz
gsoc2013-epiphany-3d4053a5f71175970712897a298a7ce95d3dfaef.tar.xz
gsoc2013-epiphany-3d4053a5f71175970712897a298a7ce95d3dfaef.tar.zst
gsoc2013-epiphany-3d4053a5f71175970712897a298a7ce95d3dfaef.zip
Re-adding basic ad blocking support
Bug #562762
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index f15fd1810..c024f7331 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -27,6 +27,7 @@
#include "downloader-view.h"
#include "eel-gconf-extensions.h"
+#include "ephy-adblock-manager.h"
#include "ephy-command-manager.h"
#include "ephy-debug.h"
#include "ephy-embed.h"
@@ -196,6 +197,29 @@ restore_zoom_level (EphyEmbed *embed,
}
static void
+resource_request_starting_cb (WebKitWebView *web_view,
+ WebKitWebFrame *web_frame,
+ WebKitWebResource *web_resource,
+ WebKitNetworkRequest *request,
+ WebKitNetworkResponse *response,
+ EphyEmbed *embed)
+{
+ EphyAdBlockManager *adblock_manager = EPHY_ADBLOCK_MANAGER(ephy_embed_shell_get_adblock_manager (embed_shell));
+ const char* uri = webkit_network_request_get_uri(request);
+
+ /* FIXME: How do we implement the other CHECK_TYPEs? Perhaps we
+ * should figure out a way of adding more information about what the
+ * resource is for to WebResource? */
+ if(!ephy_adblock_manager_should_load(adblock_manager, embed, uri,
+ AD_URI_CHECK_TYPE_OTHER)) {
+ g_signal_emit_by_name (EPHY_WEB_VIEW (web_view),
+ "content-blocked", uri);
+
+ webkit_network_request_set_uri(request, "about:blank");
+ }
+}
+
+static void
load_status_changed_cb (WebKitWebView *view,
GParamSpec *spec,
EphyEmbed *embed)
@@ -750,6 +774,7 @@ ephy_embed_constructed (GObject *object)
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::hovering-over-link", G_CALLBACK (hovering_over_link_cb), embed,
"signal::mime-type-policy-decision-requested", G_CALLBACK (mime_type_policy_decision_requested_cb), embed,
"signal::download-requested", G_CALLBACK (download_requested_cb), embed,