aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-05-25 20:59:43 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-05-25 20:59:43 +0200
commit1143429887f61d8b3c74a4c3a1fafca632eb4b87 (patch)
tree87e03b38241afb33c1e7dc70c299bfb824533429
parentMerged FilterRule into FilterNode (diff)
downloadsmolbote-1143429887f61d8b3c74a4c3a1fafca632eb4b87.tar.xz
Filter code refactoring
-rw-r--r--README.md4
-rw-r--r--smolbote.qbs24
-rw-r--r--src/filter/blockermanager.cpp (renamed from src/blocker/blockermanager.cpp)2
-rw-r--r--src/filter/blockermanager.h (renamed from src/blocker/blockermanager.h)0
-rw-r--r--src/filter/filter.cpp (renamed from src/blocker/filternode.cpp)113
-rw-r--r--src/filter/filter.h (renamed from src/blocker/filternode.h)21
-rw-r--r--src/filter/filtercollection.cpp (renamed from src/blocker/filtercollection.cpp)62
-rw-r--r--src/filter/filtercollection.h (renamed from src/blocker/filtercollection.h)4
-rw-r--r--src/filter/filtertree.cpp (renamed from src/blocker/filtertree.cpp)31
-rw-r--r--src/filter/filtertree.h (renamed from src/blocker/filtertree.h)8
-rw-r--r--src/filter/regexp.cpp (renamed from src/blocker/regexp.cpp)0
-rw-r--r--src/filter/regexp.h (renamed from src/blocker/regexp.h)0
-rw-r--r--src/filter/subscriptiondialog.ui (renamed from src/blocker/subscriptiondialog.ui)0
-rw-r--r--src/filter/subscriptionform.ui (renamed from src/blocker/subscriptionform.ui)0
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/webengine/urlinterceptor.cpp14
-rw-r--r--src/webengine/urlinterceptor.h2
17 files changed, 189 insertions, 98 deletions
diff --git a/README.md b/README.md
index a90bc75..c707401 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,8 @@ _yet another Qt browser_
### What is this and why should I care?
It is supposed to be:
-* minimal - without any additions outside its main purpose
-* configurable - in easy to find and edit text files
+* minimal - just a browser, not a platform
+* configurable - settings file in plain sight and plain text
### What's up with the name?!
It's a small boat.
diff --git a/smolbote.qbs b/smolbote.qbs
index 3015750..087249a 100644
--- a/smolbote.qbs
+++ b/smolbote.qbs
@@ -115,18 +115,18 @@ Project {
Group {
name: "Request Filter"
files: [
- "src/blocker/blockermanager.cpp",
- "src/blocker/blockermanager.h",
- "src/blocker/filternode.cpp",
- "src/blocker/filternode.h",
- "src/blocker/filtertree.cpp",
- "src/blocker/filtertree.h",
- "src/blocker/filtercollection.cpp",
- "src/blocker/filtercollection.h",
- "src/blocker/regexp.cpp",
- "src/blocker/regexp.h",
- "src/blocker/subscriptiondialog.ui",
- "src/blocker/subscriptionform.ui",
+ "src/filter/blockermanager.cpp",
+ "src/filter/blockermanager.h",
+ "src/filter/filter.cpp",
+ "src/filter/filter.h",
+ "src/filter/filtercollection.cpp",
+ "src/filter/filtercollection.h",
+ "src/filter/filtertree.cpp",
+ "src/filter/filtertree.h",
+ "src/filter/regexp.cpp",
+ "src/filter/regexp.h",
+ "src/filter/subscriptiondialog.ui",
+ "src/filter/subscriptionform.ui",
"src/webengine/urlinterceptor.cpp",
"src/webengine/urlinterceptor.h",
]
diff --git a/src/blocker/blockermanager.cpp b/src/filter/blockermanager.cpp
index ee30b65..90d99a9 100644
--- a/src/blocker/blockermanager.cpp
+++ b/src/filter/blockermanager.cpp
@@ -25,7 +25,7 @@
#include <QLabel>
#include <QListWidget>
-#include "blocker/filtercollection.h"
+#include "filtercollection.h"
BlockerManager::BlockerManager(QWidget *parent) :
QDialog(parent),
diff --git a/src/blocker/blockermanager.h b/src/filter/blockermanager.h
index cfa2110..cfa2110 100644
--- a/src/blocker/blockermanager.h
+++ b/src/filter/blockermanager.h
diff --git a/src/blocker/filternode.cpp b/src/filter/filter.cpp
index 67614ce..e0d01a9 100644
--- a/src/blocker/filternode.cpp
+++ b/src/filter/filter.cpp
@@ -18,9 +18,9 @@
**
******************************************************************************/
-#include "filternode.h"
+#include "filter.h"
-FilterNode::FilterNode(const QString &domain, const QString &request, ResourceRules rules, bool shouldBlock, FilterNode *parentItem)
+Filter::Filter(const QString &domain, const QString &request, ResourceRules rules, bool shouldBlock, Filter *parentItem)
{
m_parentItem = parentItem;
@@ -30,67 +30,73 @@ FilterNode::FilterNode(const QString &domain, const QString &request, ResourceRu
m_shouldBlock = shouldBlock;
m_valid = false;
-
-#ifdef DEBUG_VERBOSE
- qDebug("Created rule [%s] [%s]", qUtf8Printable(domain), qUtf8Printable(request));
-#endif
}
-FilterNode::~FilterNode()
+Filter::~Filter()
{
qDeleteAll(m_children);
}
-void FilterNode::enable()
+void Filter::enable()
{
m_valid = true;
}
-FilterNode *FilterNode::parentItem()
+Filter *Filter::parentItem()
{
return m_parentItem;
}
-void FilterNode::appendChild(FilterNode *child)
+void Filter::appendChild(Filter *child)
{
m_children.append(child);
}
-FilterNode *FilterNode::child(int row)
+Filter *Filter::child(int row)
{
return m_children.value(row);
}
-int FilterNode::childCount() const
+int Filter::childCount() const
{
return m_children.count();
}
-QString FilterNode::domain() const
+QString Filter::domain() const
{
return m_domainUrl.pattern();
}
-QString FilterNode::request() const
+QString Filter::request() const
{
return m_requestUrl.pattern();
}
-bool FilterNode::isBlocking()
+bool Filter::isBlocking()
{
return m_shouldBlock;
}
-int FilterNode::row() const
+QString Filter::allowedTypes() const
+{
+ return flags(m_rules.allowed);
+}
+
+QString Filter::blockedTypes() const
+{
+ return flags(m_rules.blocked);
+}
+
+int Filter::row() const
{
if(m_parentItem) {
- return m_parentItem->m_children.indexOf(const_cast<FilterNode*>(this));
+ return m_parentItem->m_children.indexOf(const_cast<Filter*>(this));
}
return 0;
}
-bool FilterNode::hasMatch(const QWebEngineUrlRequestInfo &info)
+bool Filter::hasMatch(const QWebEngineUrlRequestInfo &info)
{
if(m_domainUrl.hasMatch(info.firstPartyUrl().toString()) && m_requestUrl.hasMatch(info.requestUrl().toString())) {
return true;
@@ -99,7 +105,7 @@ bool FilterNode::hasMatch(const QWebEngineUrlRequestInfo &info)
}
}
-bool FilterNode::shouldBlock(const QWebEngineUrlRequestInfo &info)
+bool Filter::shouldBlock(const QWebEngineUrlRequestInfo &info)
{
if(!m_valid) {
return false;
@@ -118,7 +124,7 @@ bool FilterNode::shouldBlock(const QWebEngineUrlRequestInfo &info)
case QWebEngineUrlRequestInfo::ResourceTypeImage:
return testFlag(Image);
case QWebEngineUrlRequestInfo::ResourceTypeFontResource:
- return testFlag(FontResource);
+ return testFlag(Font);
case QWebEngineUrlRequestInfo::ResourceTypeSubResource:
return testFlag(SubResource);
case QWebEngineUrlRequestInfo::ResourceTypeObject:
@@ -151,12 +157,12 @@ bool FilterNode::shouldBlock(const QWebEngineUrlRequestInfo &info)
}
-bool FilterNode::isValid()
+bool Filter::isValid()
{
return m_valid;
}
-bool FilterNode::testFlag(ResourceType flag)
+bool Filter::testFlag(ResourceType flag)
{
if(m_rules.allowed.testFlag(flag)) {
return false;
@@ -166,3 +172,66 @@ bool FilterNode::testFlag(ResourceType flag)
return m_shouldBlock;
}
}
+
+QString Filter::flags(Resources f) const
+{
+ QStringList r;
+ if(f.testFlag(MainFrame)) {
+ r << QObject::tr("Main Frame");
+ }
+ if(f.testFlag(SubFrame)) {
+ r << QObject::tr("Sub Frame");
+ }
+ if(f.testFlag(Stylesheet)) {
+ r << QObject::tr("Stylesheet");
+ }
+ if(f.testFlag(Script)) {
+ r << QObject::tr("Script");
+ }
+ if(f.testFlag(Image)) {
+ r << QObject::tr("Image");
+ }
+ if(f.testFlag(Font)) {
+ r << QObject::tr("Font");
+ }
+ if(f.testFlag(SubResource)) {
+ r << QObject::tr("Sub Resource");
+ }
+ if(f.testFlag(Object)) {
+ r << QObject::tr("Object");
+ }
+ if(f.testFlag(Media)) {
+ r << QObject::tr("Media");
+ }
+ if(f.testFlag(Worker)) {
+ r << QObject::tr("Worker");
+ }
+ if(f.testFlag(SharedWorker)) {
+ r << QObject::tr("Shared Worker");
+ }
+ if(f.testFlag(Prefetch)) {
+ r << QObject::tr("Prefetch");
+ }
+ if(f.testFlag(Favicon)) {
+ r << QObject::tr("Favicon");
+ }
+ if(f.testFlag(Xhr)) {
+ r << QObject::tr("Xhr");
+ }
+ if(f.testFlag(Ping)) {
+ r << QObject::tr("Ping");
+ }
+ if(f.testFlag(ServiceWorker)) {
+ r << QObject::tr("Service Worker");
+ }
+ if(f.testFlag(CspReport)) {
+ r << QObject::tr("Csp Report");
+ }
+ if(f.testFlag(PluginResource)) {
+ r << QObject::tr("Plugin Resource");
+ }
+ if(f.testFlag(Unknown)) {
+ r << QObject::tr("Unknown");
+ }
+ return r.join(',');
+}
diff --git a/src/blocker/filternode.h b/src/filter/filter.h
index e580383..37604fe 100644
--- a/src/blocker/filternode.h
+++ b/src/filter/filter.h
@@ -27,7 +27,7 @@
#include "regexp.h"
#include <QWebEngineUrlRequestInfo>
-class FilterNode
+class Filter
{
public:
@@ -38,7 +38,7 @@ public:
Stylesheet = 4,
Script = 8,
Image = 16,
- FontResource = 32,
+ Font = 32,
SubResource = 64,
Object = 128,
Media = 256,
@@ -60,22 +60,24 @@ public:
Resources blocked;
};
- explicit FilterNode(const QString &domain, const QString &request, ResourceRules rules, bool shouldBlock, FilterNode *parentItem = 0);
- ~FilterNode();
+ explicit Filter(const QString &domain, const QString &request, ResourceRules rules, bool shouldBlock, Filter *parentItem = 0);
+ ~Filter();
void enable();
- FilterNode *parentItem();
+ Filter *parentItem();
// children
- void appendChild(FilterNode *child);
- FilterNode *child(int row);
+ void appendChild(Filter *child);
+ Filter *child(int row);
int childCount() const;
// data
QString domain() const;
QString request() const;
bool isBlocking();
+ QString allowedTypes() const;
+ QString blockedTypes() const;
int row() const;
@@ -87,9 +89,10 @@ public:
private:
bool testFlag(ResourceType flag);
+ QString flags(Resources f) const;
- FilterNode *m_parentItem;
- QList<FilterNode*> m_children;
+ Filter *m_parentItem;
+ QList<Filter*> m_children;
RegExp m_domainUrl;
RegExp m_requestUrl;
diff --git a/src/blocker/filtercollection.cpp b/src/filter/filtercollection.cpp
index 935776c..7b07606 100644
--- a/src/blocker/filtercollection.cpp
+++ b/src/filter/filtercollection.cpp
@@ -34,7 +34,7 @@
#include <QTreeView>
#include "filtertree.h"
-#include "filternode.h"
+#include "filter.h"
FilterCollection::FilterCollection(const QString path, QWidget *parent) :
QWidget(parent),
@@ -56,9 +56,7 @@ FilterCollection::FilterCollection(const QString path, QWidget *parent) :
}
QJsonDocument filters(QJsonDocument::fromJson(filterFile.readAll()));
- load(filters.object());
-
- qDebug("Added %i rules", m_filters->columnCount());
+ qDebug("Added %i rules", load(filters.object()));
}
FilterCollection::~FilterCollection()
@@ -80,7 +78,7 @@ FilterCollection::MatchResult FilterCollection::match(QWebEngineUrlRequestInfo &
{
MatchResult result;
- for(FilterNode *rule : m_filters->filters(info.firstPartyUrl().toString())) {
+ for(Filter *rule : m_filters->filters(info.firstPartyUrl().toString())) {
if(rule->isValid()) {
result.match = rule->hasMatch(info);
if(result.match) {
@@ -99,63 +97,73 @@ FilterCollection::MatchResult FilterCollection::match(QWebEngineUrlRequestInfo &
return result;
}
-void FilterCollection::load(const QJsonObject &json)
+/**
+ * Load rules from JSON object
+ * @param json
+ */
+int FilterCollection::load(const QJsonObject &json)
{
+ int number = 0;
+
ui->title->setText(json["name"].toString());
ui->homepage->setText(json["url"].toString());
for(QJsonValue v : json["rules"].toArray()) {
+ ++number;
+
QJsonObject obj = v.toObject();
- FilterNode::ResourceRules r;
+ Filter::ResourceRules r;
r.allowed = parseJsonRules(obj["allowTypes"]);
r.blocked = parseJsonRules(obj["blockTypes"]);
m_filters->addFilter(obj["firstPartyUrl"].toString(), obj["requestUrl"].toString(), r, obj["shouldBlock"].toBool());
}
+
+ return number;
}
-FilterNode::Resources FilterCollection::parseJsonRules(const QJsonValue &obj)
+Filter::Resources FilterCollection::parseJsonRules(const QJsonValue &obj)
{
- FilterNode::Resources res;
+ Filter::Resources res;
for(QJsonValue v : obj.toArray()) {
QString t = v.toString();
if(t == "MainFrame") {
- res.setFlag(FilterNode::ResourceType::MainFrame);
+ res.setFlag(Filter::ResourceType::MainFrame);
} else if(t == "SubFrame") {
- res.setFlag(FilterNode::ResourceType::SubFrame);
+ res.setFlag(Filter::ResourceType::SubFrame);
} else if(t == "Stylesheet") {
- res.setFlag(FilterNode::ResourceType::Stylesheet);
+ res.setFlag(Filter::ResourceType::Stylesheet);
} else if(t == "Script") {
- res.setFlag(FilterNode::ResourceType::Script);
+ res.setFlag(Filter::ResourceType::Script);
} else if(t == "Image") {
- res.setFlag(FilterNode::ResourceType::Image);
+ res.setFlag(Filter::ResourceType::Image);
} else if(t == "FontResource") {
- res.setFlag(FilterNode::ResourceType::FontResource);
+ res.setFlag(Filter::ResourceType::Font);
} else if(t == "SubResource") {
- res.setFlag(FilterNode::ResourceType::SubResource);
+ res.setFlag(Filter::ResourceType::SubResource);
} else if(t == "Object") {
- res.setFlag(FilterNode::ResourceType::Object);
+ res.setFlag(Filter::ResourceType::Object);
} else if(t == "Media") {
- res.setFlag(FilterNode::ResourceType::Media);
+ res.setFlag(Filter::ResourceType::Media);
} else if(t == "Worker") {
- res.setFlag(FilterNode::ResourceType::Worker);
+ res.setFlag(Filter::ResourceType::Worker);
} else if(t == "SharedWorker") {
- res.setFlag(FilterNode::ResourceType::SharedWorker);
+ res.setFlag(Filter::ResourceType::SharedWorker);
} else if(t == "Prefetch") {
- res.setFlag(FilterNode::ResourceType::Prefetch);
+ res.setFlag(Filter::ResourceType::Prefetch);
} else if(t == "Favicon") {
- res.setFlag(FilterNode::ResourceType::Favicon);
+ res.setFlag(Filter::ResourceType::Favicon);
} else if(t == "Xhr") {
- res.setFlag(FilterNode::ResourceType::Xhr);
+ res.setFlag(Filter::ResourceType::Xhr);
} else if(t == "Ping") {
- res.setFlag(FilterNode::ResourceType::Ping);
+ res.setFlag(Filter::ResourceType::Ping);
} else if(t == "ServiceWorker") {
- res.setFlag(FilterNode::ResourceType::ServiceWorker);
+ res.setFlag(Filter::ResourceType::ServiceWorker);
} else if(t == "CspWorker") {
- res.setFlag(FilterNode::ResourceType::CspReport);
+ res.setFlag(Filter::ResourceType::CspReport);
} else if(t == "PluginResource") {
- res.setFlag(FilterNode::ResourceType::PluginResource);
+ res.setFlag(Filter::ResourceType::PluginResource);
}
}
diff --git a/src/blocker/filtercollection.h b/src/filter/filtercollection.h
index 4059ff1..c39fb0a 100644
--- a/src/blocker/filtercollection.h
+++ b/src/filter/filtercollection.h
@@ -47,10 +47,10 @@ public:
MatchResult match(QWebEngineUrlRequestInfo &info);
private slots:
- void load(const QJsonObject &json);
+ int load(const QJsonObject &json);
private:
- FilterNode::Resources parseJsonRules(const QJsonValue &obj);
+ Filter::Resources parseJsonRules(const QJsonValue &obj);
Ui::SubscriptionForm *ui;
diff --git a/src/blocker/filtertree.cpp b/src/filter/filtertree.cpp
index e264015..b71c2a3 100644
--- a/src/blocker/filtertree.cpp
+++ b/src/filter/filtertree.cpp
@@ -23,7 +23,7 @@
FilterTree::FilterTree(QObject *parent) :
QAbstractItemModel(parent)
{
- rootItem = new FilterNode("", "", FilterNode::ResourceRules(), false);
+ rootItem = new Filter("", "", Filter::ResourceRules(), false);
}
FilterTree::~FilterTree()
@@ -37,14 +37,14 @@ QModelIndex FilterTree::index(int row, int column, const QModelIndex &parent) co
return QModelIndex();
}
- FilterNode *parentItem;
+ Filter *parentItem;
if(!parent.isValid()) {
parentItem = rootItem;
} else {
- parentItem = static_cast<FilterNode*>(parent.internalPointer());
+ parentItem = static_cast<Filter*>(parent.internalPointer());
}
- FilterNode *childItem = parentItem->child(row);
+ Filter *childItem = parentItem->child(row);
if(childItem) {
return createIndex(row, column, childItem);
} else {
@@ -58,8 +58,8 @@ QModelIndex FilterTree::parent(const QModelIndex &index) const
return QModelIndex();
}
- FilterNode *childItem = static_cast<FilterNode*>(index.internalPointer());
- FilterNode *parentItem = childItem->parentItem();
+ Filter *childItem = static_cast<Filter*>(index.internalPointer());
+ Filter *parentItem = childItem->parentItem();
if(parentItem == rootItem) {
return QModelIndex();
@@ -70,7 +70,7 @@ QModelIndex FilterTree::parent(const QModelIndex &index) const
int FilterTree::rowCount(const QModelIndex &parent) const
{
- FilterNode *parentItem;
+ Filter *parentItem;
if(parent.column() > 0) {
return 0;
}
@@ -78,7 +78,7 @@ int FilterTree::rowCount(const QModelIndex &parent) const
if(!parent.isValid()) {
parentItem = rootItem;
} else {
- parentItem = static_cast<FilterNode*>(parent.internalPointer());
+ parentItem = static_cast<Filter*>(parent.internalPointer());
}
return parentItem->childCount();
@@ -86,6 +86,7 @@ int FilterTree::rowCount(const QModelIndex &parent) const
int FilterTree::columnCount(const QModelIndex &parent) const
{
+ Q_UNUSED(parent)
return 5;
}
@@ -99,7 +100,7 @@ QVariant FilterTree::data(const QModelIndex &index, int role) const
return QVariant();
}
- FilterNode *n = static_cast<FilterNode*>(index.internalPointer());
+ Filter *n = static_cast<Filter*>(index.internalPointer());
switch (index.column()) {
case 0: // domain
return QVariant(n->domain());
@@ -108,9 +109,9 @@ QVariant FilterTree::data(const QModelIndex &index, int role) const
case 2: // should block
return QVariant(n->isBlocking() ? "true" : "false");
case 3: // allowed types
- return QVariant("---");
+ return QVariant(n->allowedTypes());
case 4: // blocked types
- return QVariant("---");
+ return QVariant(n->blockedTypes());
default:
return QVariant();
}
@@ -142,17 +143,17 @@ QVariant FilterTree::headerData(int section, Qt::Orientation orientation, int ro
}
}
-FilterNode *FilterTree::addFilter(const QString &domain, const QString &request, FilterNode::ResourceRules rules, bool shouldBlock)
+Filter *FilterTree::addFilter(const QString &domain, const QString &request, Filter::ResourceRules rules, bool shouldBlock)
{
- FilterNode *node = new FilterNode(domain, request, rules, shouldBlock, rootItem);
+ Filter *node = new Filter(domain, request, rules, shouldBlock, rootItem);
node->enable();
rootItem->appendChild(node);
return node;
}
-QVector<FilterNode*> FilterTree::filters(const QString &domain)
+QVector<Filter*> FilterTree::filters(const QString &domain)
{
- QVector<FilterNode*> nodes;
+ QVector<Filter*> nodes;
for(int i = 0; i < rootItem->childCount(); ++i) {
nodes.append(rootItem->child(i));
}
diff --git a/src/blocker/filtertree.h b/src/filter/filtertree.h
index 0bae0e0..161b199 100644
--- a/src/blocker/filtertree.h
+++ b/src/filter/filtertree.h
@@ -24,7 +24,7 @@
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
-#include "filternode.h"
+#include "filter.h"
class FilterTree : public QAbstractItemModel
{
@@ -41,11 +41,11 @@ public:
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
- FilterNode *addFilter(const QString &domain, const QString &request, FilterNode::ResourceRules rules, bool shouldBlock);
- QVector<FilterNode*> filters(const QString &domain = "");
+ Filter *addFilter(const QString &domain, const QString &request, Filter::ResourceRules rules, bool shouldBlock);
+ QVector<Filter*> filters(const QString &domain = "");
private:
- FilterNode *rootItem;
+ Filter *rootItem;
};
#endif // FILTERTREE_H
diff --git a/src/blocker/regexp.cpp b/src/filter/regexp.cpp
index 1f3c449..1f3c449 100644
--- a/src/blocker/regexp.cpp
+++ b/src/filter/regexp.cpp
diff --git a/src/blocker/regexp.h b/src/filter/regexp.h
index 86cedfd..86cedfd 100644
--- a/src/blocker/regexp.h
+++ b/src/filter/regexp.h
diff --git a/src/blocker/subscriptiondialog.ui b/src/filter/subscriptiondialog.ui
index 7a63cc9..7a63cc9 100644
--- a/src/blocker/subscriptiondialog.ui
+++ b/src/filter/subscriptiondialog.ui
diff --git a/src/blocker/subscriptionform.ui b/src/filter/subscriptionform.ui
index 0a20582..0a20582 100644
--- a/src/blocker/subscriptionform.ui
+++ b/src/filter/subscriptionform.ui
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 059da02..ed54461 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -29,7 +29,7 @@
#include <QUrl>
#include "widgets/webviewtabbar.h"
#include "webengine/urlinterceptor.h"
-#include "blocker/blockermanager.h"
+#include "filter/blockermanager.h"
#include "widgets/loadingbar.h"
namespace Ui {
diff --git a/src/webengine/urlinterceptor.cpp b/src/webengine/urlinterceptor.cpp
index da2925c..3ffcb44 100644
--- a/src/webengine/urlinterceptor.cpp
+++ b/src/webengine/urlinterceptor.cpp
@@ -19,7 +19,11 @@
******************************************************************************/
#include "urlinterceptor.h"
-#include "blocker/filtercollection.h"
+#include "filter/filtercollection.h"
+
+#ifdef DEBUG_VERBOSE
+#include <QTime>
+#endif
UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) :
QWebEngineUrlRequestInterceptor(parent)
@@ -29,7 +33,9 @@ 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();
#endif
for(auto s : m_manager->subscriptions()) {
@@ -37,11 +43,15 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
if(r.match) {
info.block(r.block);
#ifdef DEBUG_VERBOSE
- qDebug(">> matched [%s] [%s]", r.block ? "blocked" : "allowed", qUtf8Printable(r.pattern));
+ qDebug(">> matched [%s] [%s] in %i ms", r.block ? "blocked" : "allowed", qUtf8Printable(r.pattern), time.elapsed());
#endif
return;
}
}
+
+#ifdef DEBUG_VERBOSE
+ qDebug(">> passed in %i ms", time.elapsed());
+#endif
}
void UrlRequestInterceptor::setSubscription(BlockerManager *manager)
diff --git a/src/webengine/urlinterceptor.h b/src/webengine/urlinterceptor.h
index 65f2ce0..acd076a 100644
--- a/src/webengine/urlinterceptor.h
+++ b/src/webengine/urlinterceptor.h
@@ -22,7 +22,7 @@
#define ADBLOCKINTERCEPTOR_H
#include <QWebEngineUrlRequestInterceptor>
-#include "blocker/blockermanager.h"
+#include "filter/blockermanager.h"
class UrlRequestInterceptor : public QWebEngineUrlRequestInterceptor
{