aboutsummaryrefslogtreecommitdiff
path: root/staging/adblock/rule.h
diff options
context:
space:
mode:
Diffstat (limited to 'staging/adblock/rule.h')
-rw-r--r--staging/adblock/rule.h23
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();