From 908ab1e805d98cd79a36ba6bda3c3a9c8d0a99ca Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 16 Apr 2020 22:09:58 +0300 Subject: Parse type options into std::bitset --- staging/adblock/rule.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'staging/adblock/rule.h') 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(); -- cgit v1.2.1