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>
|
2012-07-01 20:11:37 +02:00
|
|
|
#include <QStringList>
|
2012-12-20 14:45:35 +01:00
|
|
|
#include <QPointer>
|
2011-03-27 21:59:40 +02:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include "qz_namespace.h"
|
|
|
|
|
2011-03-27 21:59:40 +02:00
|
|
|
class QUrl;
|
2012-06-15 17:03:37 +02:00
|
|
|
class QNetworkReply;
|
|
|
|
class QNetworkRequest;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2011-03-27 21:59:40 +02:00
|
|
|
class AdBlockDialog;
|
2012-08-09 19:02:25 +02:00
|
|
|
class AdBlockCustomList;
|
2011-03-27 21:59:40 +02:00
|
|
|
class AdBlockSubscription;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-02-19 22:12:32 +01:00
|
|
|
class QUPZILLA_EXPORT AdBlockManager : public QObject
|
2011-03-27 21:59:40 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2011-11-06 17:01:23 +01:00
|
|
|
AdBlockManager(QObject* parent = 0);
|
2013-02-26 10:42:48 +01:00
|
|
|
~AdBlockManager();
|
|
|
|
|
2012-06-24 23:46:32 +02:00
|
|
|
static AdBlockManager* instance();
|
2011-03-27 21:59:40 +02:00
|
|
|
|
|
|
|
void load();
|
|
|
|
void save();
|
|
|
|
|
2013-05-05 00:14:42 +02:00
|
|
|
bool isEnabled() const;
|
2012-07-04 10:08:55 +02:00
|
|
|
bool canRunOnScheme(const QString &scheme) const;
|
2012-06-25 16:07:25 +02:00
|
|
|
|
2013-11-03 16:04:38 +01:00
|
|
|
bool useLimitedEasyList() const;
|
|
|
|
void setUseLimitedEasyList(bool useLimited);
|
|
|
|
|
2012-06-25 16:07:25 +02:00
|
|
|
QString elementHidingRules() const;
|
2012-07-04 16:00:53 +02:00
|
|
|
QString elementHidingRulesForDomain(const QUrl &url) const;
|
2012-06-15 17:03:37 +02:00
|
|
|
|
2012-07-01 18:13:49 +02:00
|
|
|
AdBlockSubscription* subscriptionByName(const QString &name) const;
|
2012-06-24 23:46:32 +02:00
|
|
|
QList<AdBlockSubscription*> subscriptions() const;
|
2012-06-25 16:07:25 +02:00
|
|
|
|
2012-06-15 17:03:37 +02:00
|
|
|
QNetworkReply* block(const QNetworkRequest &request);
|
2011-03-27 21:59:40 +02:00
|
|
|
|
2012-07-01 20:11:37 +02:00
|
|
|
QStringList disabledRules() const;
|
|
|
|
void addDisabledRule(const QString &filter);
|
|
|
|
void removeDisabledRule(const QString &filter);
|
|
|
|
|
2012-06-24 23:46:32 +02:00
|
|
|
AdBlockSubscription* addSubscription(const QString &title, const QString &url);
|
|
|
|
bool removeSubscription(AdBlockSubscription* subscription);
|
|
|
|
|
2012-08-09 19:02:25 +02:00
|
|
|
AdBlockCustomList* customList() const;
|
|
|
|
|
2011-03-27 21:59:40 +02:00
|
|
|
public slots:
|
|
|
|
void setEnabled(bool enabled);
|
2011-03-29 20:30:05 +02:00
|
|
|
void showRule();
|
2011-03-27 21:59:40 +02:00
|
|
|
|
2012-06-24 23:46:32 +02:00
|
|
|
void updateAllSubscriptions();
|
2011-12-28 19:28:34 +01:00
|
|
|
|
2012-06-24 23:46:32 +02:00
|
|
|
AdBlockDialog* showDialog();
|
2012-06-15 17:03:37 +02:00
|
|
|
|
2011-03-27 21:59:40 +02:00
|
|
|
private:
|
2012-07-08 00:15:03 +02:00
|
|
|
inline bool canBeBlocked(const QUrl &url) const;
|
2011-03-27 21:59:40 +02:00
|
|
|
static AdBlockManager* s_adBlockManager;
|
|
|
|
|
|
|
|
bool m_loaded;
|
|
|
|
bool m_enabled;
|
2013-11-03 16:04:38 +01:00
|
|
|
bool m_useLimitedEasyList;
|
2012-06-24 23:46:32 +02:00
|
|
|
|
2012-06-15 17:03:37 +02:00
|
|
|
QList<AdBlockSubscription*> m_subscriptions;
|
2012-07-01 20:11:37 +02:00
|
|
|
QStringList m_disabledRules;
|
|
|
|
|
2012-12-20 14:45:35 +01:00
|
|
|
QPointer<AdBlockDialog> m_adBlockDialog;
|
2011-03-27 21:59:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ADBLOCKMANAGER_H
|
|
|
|
|