1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 17:42:10 +01:00
falkonOfficial/src/lib/adblock/adblockmanager.h

97 lines
2.6 KiB
C
Raw Normal View History

2011-03-27 22:02:21 +02:00
/* ============================================================
* QupZilla - WebKit based browser
2014-01-11 16:11:42 +01:00
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
2011-03-27 22:02:21 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
2011-03-27 21:59:40 +02:00
#ifndef ADBLOCKMANAGER_H
#define ADBLOCKMANAGER_H
#include <QObject>
#include <QStringList>
#include <QPointer>
2011-03-27 21:59:40 +02:00
#include "qzcommon.h"
2011-03-27 21:59:40 +02:00
class QUrl;
class QNetworkReply;
class QNetworkRequest;
2011-03-27 21:59:40 +02:00
class AdBlockDialog;
class AdBlockCustomList;
2011-03-27 21:59:40 +02:00
class AdBlockSubscription;
class QUPZILLA_EXPORT AdBlockManager : public QObject
2011-03-27 21:59:40 +02:00
{
Q_OBJECT
public:
AdBlockManager(QObject* parent = 0);
~AdBlockManager();
2011-03-27 21:59:40 +02:00
void load();
void save();
bool isEnabled() const;
bool canRunOnScheme(const QString &scheme) const;
bool useLimitedEasyList() const;
void setUseLimitedEasyList(bool useLimited);
QString elementHidingRules() const;
QString elementHidingRulesForDomain(const QUrl &url) const;
AdBlockSubscription* subscriptionByName(const QString &name) const;
QList<AdBlockSubscription*> subscriptions() const;
QNetworkReply* block(const QNetworkRequest &request);
2011-03-27 21:59:40 +02:00
QStringList disabledRules() const;
void addDisabledRule(const QString &filter);
void removeDisabledRule(const QString &filter);
AdBlockSubscription* addSubscription(const QString &title, const QString &url);
bool removeSubscription(AdBlockSubscription* subscription);
AdBlockCustomList* customList() const;
static AdBlockManager* instance();
signals:
void enabledChanged(bool enabled);
2011-03-27 21:59:40 +02:00
public slots:
void setEnabled(bool enabled);
void showRule();
2011-03-27 21:59:40 +02:00
void updateAllSubscriptions();
AdBlockDialog* showDialog();
2011-03-27 21:59:40 +02:00
private:
inline bool canBeBlocked(const QUrl &url) const;
2011-03-27 21:59:40 +02:00
bool m_loaded;
bool m_enabled;
bool m_useLimitedEasyList;
QList<AdBlockSubscription*> m_subscriptions;
QStringList m_disabledRules;
QPointer<AdBlockDialog> m_adBlockDialog;
2011-03-27 21:59:40 +02:00
};
#endif // ADBLOCKMANAGER_H