From 05dbc6fb7d8833c183485ec0d846c151b6299c92 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 3 Feb 2017 19:24:40 +0100 Subject: option parsing --- src/webengine/blockerrule.h | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/webengine/blockerrule.h') diff --git a/src/webengine/blockerrule.h b/src/webengine/blockerrule.h index 95d82b7..df09d10 100644 --- a/src/webengine/blockerrule.h +++ b/src/webengine/blockerrule.h @@ -24,6 +24,7 @@ #include #include #include +#include class BlockerRule : public QObject { @@ -36,13 +37,33 @@ public: WildcardMatch }; + enum RuleOption { + script = 0, + image = 1, + stylesheet = 2, + object = 4, + xmlhttprequest = 8, + objectsubrequest = 16, + subdocument = 32, + ping = 64, + websocket = 128, + document = 256, + + elemhide = 512, + generichide = 1024, + genericblock = 2048, + + other = 4096 + }; + + Q_DECLARE_FLAGS(RuleOptions, RuleOption) + explicit BlockerRule(QString rule, QObject *parent = 0); - QString pattern() const; - QString domain() const; - bool match(const QUrl &url); + bool match(const QWebEngineUrlRequestInfo &info); bool isValid(); bool isException(); + QString toString() const; signals: @@ -52,10 +73,15 @@ private: // TODO: subclass QRegularExpression and move this there QString fromWildcardMatch(const QString &pattern); + QString m_rule; + RuleType m_type; bool m_exception = false; QString m_domain; QRegularExpression ruleExpression; + + RuleOptions m_blacklistOptions; + RuleOptions m_whitelistOptions; }; #endif // ADBLOCKRULE_H -- cgit v1.2.1