aboutsummaryrefslogtreecommitdiff
path: root/src/blocker/blockerrule.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/blocker/blockerrule.h')
-rw-r--r--src/blocker/blockerrule.h75
1 files changed, 43 insertions, 32 deletions
diff --git a/src/blocker/blockerrule.h b/src/blocker/blockerrule.h
index a98f699..758366d 100644
--- a/src/blocker/blockerrule.h
+++ b/src/blocker/blockerrule.h
@@ -31,30 +31,48 @@ class BlockerRule : public QObject
Q_OBJECT
public:
- // https://adblockplus.org/en/filters#options
- enum RuleOption {
- script = 1,
- image = 2,
- stylesheet = 4,
- object = 8,
- xmlhttprequest = 16,
- objectsubrequest = 32,
- subdocument = 64,
- ping = 128,
- websocket = 256,
- document = 512,
- elemhide = 1024,
- generichide = 2048,
- genericblock = 4096,
- other = 8192
+ enum TypeState {
+ Allow = 1,
+ Deny = 2,
+ None = 0
};
- Q_DECLARE_FLAGS(RuleOptions, RuleOption)
- explicit BlockerRule(QString rule, QObject *parent = 0);
+ struct NavigationType {
+ TypeState link;
+ TypeState typed;
+ TypeState form;
+ TypeState history;
+ TypeState reload;
+ TypeState other;
+ };
+
+ struct ResourceType {
+ TypeState MainFrame;
+ TypeState SubFrame;
+ TypeState Stylesheet;
+ TypeState Script;
+ TypeState FontResource;
+ TypeState SubResource;
+ TypeState Object;
+ TypeState Media;
+ TypeState Worker;
+ TypeState SharedWorker;
+ TypeState Prefetch;
+ TypeState Favicon;
+ TypeState Xhr;
+ TypeState Ping;
+ TypeState ServiceWorker;
+ TypeState CspWorker;
+ TypeState PluginResource;
+ TypeState Unknown;
+ };
+
+ explicit BlockerRule(RegExp firstPartyUrl, RegExp requestUrl, NavigationType nav, ResourceType res, bool shouldBlock, QObject *parent = 0);
bool match(const QWebEngineUrlRequestInfo &info);
+
bool isValid();
- bool isException();
+
QString filter() const;
signals:
@@ -62,22 +80,15 @@ signals:
public slots:
private:
- void parseOption(const QString &opt);
- bool matchOptions(const QWebEngineUrlRequestInfo &info, const RuleOptions &options);
-
- QString m_filter;
+ RegExp m_firstPartyUrl;
+ RegExp m_requestUrl;
- bool m_valid;
- bool m_exception = false;
- bool m_elementRule;
+ NavigationType m_navRules;
+ ResourceType m_resRules;
- QStringList hostsBlacklist;
- QStringList hostsWhitelist;
- RegExp domainExpression;
- RegExp ruleExpression;
+ bool m_valid = false;
+ bool m_shouldBlock;
- RuleOptions m_blacklistOptions;
- RuleOptions m_whitelistOptions;
};
#endif // ADBLOCKRULE_H