51#include <QStringMatcher>
52#include <QRegularExpression>
57class QWebEngineUrlRequestInfo;
74 QString filter()
const;
75 void setFilter(
const QString &filter);
77 bool isCssRule()
const;
78 QString cssSelector()
const;
80 bool isUnsupportedRule()
const;
82 bool isDocument()
const;
83 bool isElemhide()
const;
84 bool isGenerichide()
const;
86 bool isDomainRestricted()
const;
87 bool isException()
const;
89 bool isComment()
const;
90 bool isEnabled()
const;
91 void setEnabled(
bool enabled);
94 bool isInternalDisabled()
const;
96 bool urlMatch(
const QUrl &url)
const;
97 bool networkMatch(
const QWebEngineUrlRequestInfo &request,
const QString &domain,
const QString &encodedUrl)
const;
99 bool matchDomain(
const QString &domain)
const;
100 bool matchThirdParty(
const QWebEngineUrlRequestInfo &request)
const;
102 bool matchType(
const QWebEngineUrlRequestInfo &request)
const;
105 bool stringMatch(
const QString &domain,
const QString &encodedUrl)
const;
106 bool isMatchingDomain(
const QString &domain,
const QString &filter)
const;
107 bool isMatchingRegExpStrings(
const QString &url)
const;
108 QStringList parseRegExpFilter(
const QString &filter)
const;
115 StringEndsMatchRule = 3,
116 StringContainsMatchRule = 4,
117 MatchAllUrlsRule = 5,
125 DomainRestrictedOption = 1,
126 ThirdPartyOption = 1 << 1,
128 ObjectOption = 1 << 2,
129 SubdocumentOption = 1 << 3,
130 XMLHttpRequestOption = 1 << 4,
131 ImageOption = 1 << 5,
132 ScriptOption = 1 << 6,
133 StyleSheetOption = 1 << 7,
134 ObjectSubrequestOption = 1 << 8,
136 MediaOption = 1 << 10,
137 FontOption = 1 << 11,
138 OtherOption = 1 << 12,
139 TypeOptions = ObjectOption
141 | XMLHttpRequestOption
145 | ObjectSubrequestOption
151 PopupOption = 1 << 13,
154 DocumentOption = 1 << 20,
155 ElementHideOption = 1 << 21,
156 GenericHideOption = 1 << 22,
157 GenericBlockOption = 1 << 23,
160 Q_DECLARE_FLAGS(RuleOptions, RuleOption)
162 inline bool hasOption(
const RuleOption &opt)
const;
163 inline bool hasException(
const RuleOption &opt)
const;
165 inline void setOption(
const RuleOption &opt);
166 inline void setException(
const RuleOption &opt,
bool on);
169 void parseDomains(
const QString &domains,
const QChar &separator);
170 bool filterIsOnlyDomain(
const QString &filter)
const;
171 bool filterIsOnlyEndsMatch(
const QString &filter)
const;
172 QString createRegExpFromFilter(
const QString &filter)
const;
173 QList<QStringMatcher> createStringMatchers(
const QStringList &filters)
const;
178 RuleOptions m_options;
179 RuleOptions m_exceptions;
184 QString m_matchString;
186 Qt::CaseSensitivity m_caseSensitivity;
190 bool m_isInternalDisabled;
192 QStringList m_allowedDomains;
193 QStringList m_blockedDomains;
196 QRegularExpression regExp;
197 QList<QStringMatcher> matchers;