diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-16 22:09:58 +0300 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-21 20:14:57 +0300 |
commit | 908ab1e805d98cd79a36ba6bda3c3a9c8d0a99ca (patch) | |
tree | cda8739eba52457b605c38f7d71489f5556d0b26 /staging/adblock/rule.h | |
parent | Add some Options tests (diff) | |
download | smolbote-908ab1e805d98cd79a36ba6bda3c3a9c8d0a99ca.tar.xz |
Parse type options into std::bitset
Diffstat (limited to 'staging/adblock/rule.h')
-rw-r--r-- | staging/adblock/rule.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/staging/adblock/rule.h b/staging/adblock/rule.h index 0dbff21..26a8249 100644 --- a/staging/adblock/rule.h +++ b/staging/adblock/rule.h @@ -17,11 +17,22 @@ namespace AdblockPlus { +static const QString defaultUrl; + class Rule { public: virtual ~Rule() = default; - virtual bool hasMatch(const QStringRef &) const = 0; + /** + * requestUrl: requested URL + * initiatorUrl: URL of document that initiated navigation + * firstPartyUrl: URL of the page that issued the request + */ + virtual bool hasMatch(const QStringRef &requestUrl, + const QStringRef &initiatorUrl = QStringRef(&defaultUrl), + const QStringRef &firstPartyUrl = QStringRef(&defaultUrl), + QWebEngineUrlRequestInfo::ResourceType resourceType = QWebEngineUrlRequestInfo::ResourceTypeMainFrame) const = 0; + bool shouldRedirect() const { return options.redirect; @@ -72,7 +83,10 @@ public: MatcherRule &operator=(MatcherRule &&) = delete; ~MatcherRule() = default; - bool hasMatch(const QStringRef &url) const override + bool hasMatch(const QStringRef &url, + const QStringRef &initiatorUrl = QStringRef(&defaultUrl), + const QStringRef &firstPartyUrl = QStringRef(&defaultUrl), + QWebEngineUrlRequestInfo::ResourceType resourceType = QWebEngineUrlRequestInfo::ResourceTypeMainFrame) const override { const auto index = matcher.indexIn(url); if(index == -1) { @@ -123,7 +137,10 @@ public: RegexRule &operator=(RegexRule &&) = delete; ~RegexRule() = default; - bool hasMatch(const QStringRef &url) const override + bool hasMatch(const QStringRef &url, + const QStringRef &initiatorUrl = QStringRef(&defaultUrl), + const QStringRef &firstPartyUrl = QStringRef(&defaultUrl), + QWebEngineUrlRequestInfo::ResourceType resourceType = QWebEngineUrlRequestInfo::ResourceTypeMainFrame) const override { const auto match = regex.match(url); return match.hasMatch(); |