diff options
Diffstat (limited to 'src/webengine/urlinterceptor.cpp')
-rw-r--r-- | src/webengine/urlinterceptor.cpp | 33 |
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; } |