aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/EphyContentPolicy.cpp
diff options
context:
space:
mode:
authorJean-François Rameau <jframeau@cvs.gnome.org>2005-12-20 05:33:41 +0800
committerJean-François Rameau <jframeau@src.gnome.org>2005-12-20 05:33:41 +0800
commit75b2ce17335253696b6e064e093af57902a7d39c (patch)
tree154e37415e375ecd7a83aa266fad30fd04c68733 /embed/mozilla/EphyContentPolicy.cpp
parent44f5c62d3fa80ae1db96104c51a3af7b44540354 (diff)
downloadgsoc2013-epiphany-75b2ce17335253696b6e064e093af57902a7d39c.tar
gsoc2013-epiphany-75b2ce17335253696b6e064e093af57902a7d39c.tar.gz
gsoc2013-epiphany-75b2ce17335253696b6e064e093af57902a7d39c.tar.bz2
gsoc2013-epiphany-75b2ce17335253696b6e064e093af57902a7d39c.tar.lz
gsoc2013-epiphany-75b2ce17335253696b6e064e093af57902a7d39c.tar.xz
gsoc2013-epiphany-75b2ce17335253696b6e064e093af57902a7d39c.tar.zst
gsoc2013-epiphany-75b2ce17335253696b6e064e093af57902a7d39c.zip
Add some code so ad blocking should be more easy. Based on the fact that
2005-12-19 Jean-François Rameau <jframeau@cvs.gnome.org> * embed/Makefile.am: * embed/ephy-adblock-manager.c: * embed/ephy-adblock-manager.h: * embed/ephy-embed-shell.c: (ephy_embed_shell_finalize): * embed/ephy-embed-shell.h: * embed/mozilla/EphyContentPolicy.cpp: (EphyContentPolicy::ShouldLoad): * lib/Makefile.am: * lib/ephy-adblock.h: * lib/ephy-adblock.c: * src/ephy-shell.c: (ephy_shell_get_extensions_manager): Add some code so ad blocking should be more easy. Based on the fact that Epiphany already has its own content policy component (EphyContentPolicy). The new design adds: - an interface, EphyAdBlock - a manager, EphyAdBlockManager, pointing to a blocker (possibly no one).
Diffstat (limited to 'embed/mozilla/EphyContentPolicy.cpp')
-rw-r--r--embed/mozilla/EphyContentPolicy.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/embed/mozilla/EphyContentPolicy.cpp b/embed/mozilla/EphyContentPolicy.cpp
index c2277b761..aedcc8aac 100644
--- a/embed/mozilla/EphyContentPolicy.cpp
+++ b/embed/mozilla/EphyContentPolicy.cpp
@@ -28,6 +28,7 @@
#include "ephy-embed-shell.h"
#include "ephy-embed-single.h"
#include "eel-gconf-extensions.h"
+#include "ephy-adblock-manager.h"
#include "ephy-debug.h"
#include <nsCOMPtr.h>
@@ -76,17 +77,33 @@ EphyContentPolicy::ShouldLoad(PRUint32 aContentType,
*aDecision = nsIContentPolicy::ACCEPT;
- PRBool isHttp = PR_FALSE, isHttps = PR_FALSE;
- aContentLocation->SchemeIs ("http", &isHttp);
- aContentLocation->SchemeIs ("https", &isHttps);
- if (isHttp || isHttps) return NS_OK;
-
/* We have to always allow these, else forms and scrollbars break */
PRBool isChrome = PR_FALSE, isResource = PR_FALSE;
aContentLocation->SchemeIs ("chrome", &isChrome);
aContentLocation->SchemeIs ("resource", &isResource);
if (isChrome || isResource) return NS_OK;
+ PRBool isHttps = PR_FALSE;
+ aContentLocation->SchemeIs ("https", &isHttps);
+ if (isHttps) return NS_OK;
+
+ /* is this url allowed ? */
+ nsEmbedCString spec;
+ aContentLocation->GetSpec(spec);
+
+ EphyAdBlockManager *adblock_manager =
+ EPHY_ADBLOCK_MANAGER (ephy_embed_shell_get_adblock_manager (embed_shell));
+
+ if (!ephy_adblock_manager_should_load (adblock_manager, spec.get (), AdUriCheckType(aContentType)))
+ {
+ *aDecision = nsIContentPolicy::REJECT_REQUEST;
+ return NS_OK;
+ }
+
+ PRBool isHttp = PR_FALSE;
+ aContentLocation->SchemeIs ("http", &isHttp);
+ if (isHttp) return NS_OK;
+
nsEmbedCString contentSpec;
aContentLocation->GetSpec (contentSpec);
if (strcmp (contentSpec.get(), "about:blank") == 0) return NS_OK;
@@ -155,7 +172,6 @@ NS_IMETHODIMP EphyContentPolicy::ShouldLoad(PRInt32 aContentType,
{
*_retval = PR_FALSE;
}
-
return NS_OK;
}