aboutsummaryrefslogtreecommitdiff
path: root/lib/web/urlfilter/adblockrule.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/web/urlfilter/adblockrule.h')
-rw-r--r--lib/web/urlfilter/adblockrule.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/web/urlfilter/adblockrule.h b/lib/web/urlfilter/adblockrule.h
new file mode 100644
index 0000000..e1cabae
--- /dev/null
+++ b/lib/web/urlfilter/adblockrule.h
@@ -0,0 +1,43 @@
+#ifndef ADBLOCKRULE_H
+#define ADBLOCKRULE_H
+
+#include <QObject>
+#include <QString>
+#include <QRegularExpression>
+#include <QUrl>
+#include <QWebEngineUrlRequestInfo>
+
+class AdBlockRule
+{
+public:
+
+ enum MatchType {
+ InvalidMatch,
+ RegularExpressionMatch,
+ StringContains,
+ StringStartsWith,
+ StringEndsWith,
+ StringEquals,
+ DomainMatch
+ };
+
+ AdBlockRule(const QString &filter);
+
+ bool isEnabled() const;
+ bool shouldBlock(const QUrl &url) const;
+
+private:
+ Q_DISABLE_COPY(AdBlockRule)
+
+ bool m_isEnabled = false;
+ bool m_isException = false;
+
+ MatchType matchType = InvalidMatch;
+ QHash<QWebEngineUrlRequestInfo::ResourceType, bool> m_resourceTypeOptions;
+
+ QString match;
+ QRegularExpression regexp;
+ QStringMatcher matcher;
+};
+
+#endif // ADBLOCKRULE_H