aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/urlinterceptor.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-01-27 17:14:49 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-01-27 17:14:49 +0100
commited7430d2352b3f87991f68fbc0acfe4dbae39b56 (patch)
treebd6d9d0c3c0f6e66131f581bed978c49febada7f /src/webengine/urlinterceptor.cpp
parentBlocker UI (diff)
downloadsmolbote-ed7430d2352b3f87991f68fbc0acfe4dbae39b56.tar.xz
URL blocking whitelist
Diffstat (limited to 'src/webengine/urlinterceptor.cpp')
-rw-r--r--src/webengine/urlinterceptor.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/webengine/urlinterceptor.cpp b/src/webengine/urlinterceptor.cpp
index 87879a5..2bd50b8 100644
--- a/src/webengine/urlinterceptor.cpp
+++ b/src/webengine/urlinterceptor.cpp
@@ -1,19 +1,32 @@
#include "urlinterceptor.h"
-AdBlockInterceptor::AdBlockInterceptor(QObject *parent) :
+UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) :
QWebEngineUrlRequestInterceptor(parent)
{
}
-void AdBlockInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
+void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{
-// bool blocked = false;
-// for(AdBlockRule *rule : m_urlBlacklist) {
-// if(rule->match(info.requestUrl())) {
-// info.block(true);
-// blocked = true;
-// }
-// }
+ for(BlockerRule *rule : m_sub->urlWhitelist()) {
+ if(rule->match(info.requestUrl())) {
+ qDebug("OK %s", qUtf8Printable(info.requestUrl().toString()));
+ return;
+ }
+ }
- qDebug("%i %i %s %s", info.navigationType(), info.resourceType(), qUtf8Printable(info.requestMethod()), qUtf8Printable(info.requestUrl().toString()));
+ for(BlockerRule *rule : m_sub->urlBlacklist()) {
+ if(rule->match(info.requestUrl())) {
+ info.block(true);
+ qDebug(" %s", qUtf8Printable(info.requestUrl().toString()));
+ return;
+ }
+ }
+
+ qDebug("OK %s", qUtf8Printable(info.requestUrl().toString()));
+
+}
+
+void UrlRequestInterceptor::setSubscription(BlockerSubscription *subscription)
+{
+ m_sub = subscription;
}