diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-03-22 22:59:07 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-03-22 22:59:07 +0100 |
commit | 0772cf8b98387b2b641ae29aeb1b459eef22d794 (patch) | |
tree | 9ee8048e85e1fc8a11a6e88b6d8829d5784d6a4c /src/webengine | |
parent | Profile saving and loading (diff) | |
download | smolbote-0772cf8b98387b2b641ae29aeb1b459eef22d794.tar.xz |
Blocker fixes
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/urlinterceptor.cpp | 20 | ||||
-rw-r--r-- | src/webengine/urlinterceptor.h | 4 |
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 |