From 0772cf8b98387b2b641ae29aeb1b459eef22d794 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 22 Mar 2017 22:59:07 +0100 Subject: Blocker fixes --- src/webengine/urlinterceptor.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/webengine/urlinterceptor.cpp') 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; } -- cgit v1.2.1