Falkon Develop
Cross-platform Qt-based web browser
adblockmatcher.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2014-2017 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#ifndef ADBLOCKMATCHER_H
19#define ADBLOCKMATCHER_H
20
21#include <QUrl>
22#include <QObject>
23
24#include "qzcommon.h"
25#include "adblocksearchtree.h"
26
27class QWebEngineUrlRequestInfo;
28
29class AdBlockManager;
30
31class FALKON_EXPORT AdBlockMatcher : public QObject
32{
33 Q_OBJECT
34
35public:
36 explicit AdBlockMatcher(AdBlockManager* manager);
38
39 const AdBlockRule* match(const QWebEngineUrlRequestInfo &request, const QString &urlDomain, const QString &urlString) const;
40
41 bool adBlockDisabledForUrl(const QUrl &url) const;
42 bool elemHideDisabledForUrl(const QUrl &url) const;
43 bool genericElemHideDisabledForUrl(const QUrl &url) const;
44
45 QString elementHidingRules() const;
46 QString elementHidingRulesForDomain(const QString &domain) const;
47
48public Q_SLOTS:
49 void update();
50 void clear();
51
52private:
53 AdBlockManager* m_manager;
54
55 QVector<AdBlockRule*> m_createdRules;
56 QVector<const AdBlockRule*> m_networkExceptionRules;
57 QVector<const AdBlockRule*> m_networkBlockRules;
58 QVector<const AdBlockRule*> m_domainRestrictedCssRules;
59 QVector<const AdBlockRule*> m_documentRules;
60 QVector<const AdBlockRule*> m_elemhideRules;
61 QVector<const AdBlockRule*> m_generichideRules;
62
63 QString m_elementHidingRules;
64 AdBlockSearchTree m_networkBlockTree;
65 AdBlockSearchTree m_networkExceptionTree;
66};
67
68#endif // ADBLOCKMATCHER_H
#define FALKON_EXPORT
Definition: qzcommon.h:28