aboutsummaryrefslogtreecommitdiff
path: root/staging/adblock/rule.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-04-16 22:09:58 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-04-21 20:14:57 +0300
commit908ab1e805d98cd79a36ba6bda3c3a9c8d0a99ca (patch)
treecda8739eba52457b605c38f7d71489f5556d0b26 /staging/adblock/rule.h
parentAdd some Options tests (diff)
downloadsmolbote-908ab1e805d98cd79a36ba6bda3c3a9c8d0a99ca.tar.xz
Parse type options into std::bitset
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();