From 9089047b0f5fac8a394ef0b4c8822ce5c7483212 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 5 Aug 2017 15:05:22 +0200 Subject: Changed the filter format --- src/webengine/urlinterceptor.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/webengine/urlinterceptor.cpp') diff --git a/src/webengine/urlinterceptor.cpp b/src/webengine/urlinterceptor.cpp index 3ffcb44..19bc64f 100644 --- a/src/webengine/urlinterceptor.cpp +++ b/src/webengine/urlinterceptor.cpp @@ -21,10 +21,6 @@ #include "urlinterceptor.h" #include "filter/filtercollection.h" -#ifdef DEBUG_VERBOSE -#include -#endif - UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) : QWebEngineUrlRequestInterceptor(parent) { @@ -33,25 +29,18 @@ UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) : void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) { #ifdef DEBUG_VERBOSE - QTime time; - qDebug("%s --> [%i] %s", qUtf8Printable(info.firstPartyUrl().toString()), info.resourceType(), qUtf8Printable(info.requestUrl().toString())); - time.start(); + qDebug("%s -[%i]-> %s", qUtf8Printable(info.firstPartyUrl().toString()), info.resourceType(), qUtf8Printable(info.requestUrl().toString())); #endif - for(auto s : m_manager->subscriptions()) { - FilterCollection::MatchResult r = s->match(info); - if(r.match) { - info.block(r.block); + bool shouldBlock = s->match(info); + if(shouldBlock) { + info.block(true); #ifdef DEBUG_VERBOSE - qDebug(">> matched [%s] [%s] in %i ms", r.block ? "blocked" : "allowed", qUtf8Printable(r.pattern), time.elapsed()); + qDebug(">> blocked"); #endif return; } } - -#ifdef DEBUG_VERBOSE - qDebug(">> passed in %i ms", time.elapsed()); -#endif } void UrlRequestInterceptor::setSubscription(BlockerManager *manager) -- cgit v1.2.1