aboutsummaryrefslogtreecommitdiff
path: root/src/webengine
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/urlinterceptor.cpp20
-rw-r--r--src/webengine/urlinterceptor.h4
2 files changed, 19 insertions, 5 deletions
diff --git a/src/webengine/urlinterceptor.cpp b/src/webengine/urlinterceptor.cpp
index 3c6a56e..94bfffa 100644
--- a/src/webengine/urlinterceptor.cpp
+++ b/src/webengine/urlinterceptor.cpp
@@ -19,6 +19,7 @@
******************************************************************************/
#include "urlinterceptor.h"
+#include "blocker/blockersubscription.h"
UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) :
QWebEngineUrlRequestInterceptor(parent)
@@ -27,10 +28,23 @@ UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) :
void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{
- //
+#ifdef DEBUG_VERBOSE
+ qDebug("%s", qUtf8Printable(info.requestUrl().toString()));
+#endif
+
+ for(BlockerSubscription *s : m_manager->subscriptions()) {
+ BlockerSubscription::MatchResult r = s->match(info);
+ if(r.match) {
+ info.block(r.block);
+#ifdef DEBUG_VERBOSE
+ qDebug("+--> matched [%s] [%s]", r.block ? "blocked" : "allowed", qUtf8Printable(r.pattern));
+#endif
+ return;
+ }
+ }
}
-void UrlRequestInterceptor::setSubscription(BlockerManager *subscription)
+void UrlRequestInterceptor::setSubscription(BlockerManager *manager)
{
- m_blocker = subscription;
+ m_manager = manager;
}
diff --git a/src/webengine/urlinterceptor.h b/src/webengine/urlinterceptor.h
index 00fe666..2e5d6bf 100644
--- a/src/webengine/urlinterceptor.h
+++ b/src/webengine/urlinterceptor.h
@@ -31,14 +31,14 @@ public:
explicit UrlRequestInterceptor(QObject *parent = 0);
void interceptRequest(QWebEngineUrlRequestInfo &info);
- void setSubscription(BlockerManager *subscription);
+ void setSubscription(BlockerManager *manager);
signals:
public slots:
private:
- BlockerManager *m_blocker;
+ BlockerManager *m_manager;
};
#endif // ADBLOCKINTERCEPTOR_H