diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/blocker/blockermanager.cpp (renamed from src/forms/blockerdialog.cpp) | 37 | ||||
-rw-r--r-- | src/blocker/blockermanager.h (renamed from src/forms/blockerdialog.h) | 9 | ||||
-rw-r--r-- | src/blocker/blockerrule.cpp (renamed from src/webengine/blockerrule.cpp) | 63 | ||||
-rw-r--r-- | src/blocker/blockerrule.h (renamed from src/webengine/blockerrule.h) | 7 | ||||
-rw-r--r-- | src/blocker/blockersubscription.cpp (renamed from src/webengine/blockersubscription.cpp) | 113 | ||||
-rw-r--r-- | src/blocker/blockersubscription.h (renamed from src/webengine/blockersubscription.h) | 50 | ||||
-rw-r--r-- | src/blocker/regexp.cpp (renamed from src/webengine/regexp.cpp) | 2 | ||||
-rw-r--r-- | src/blocker/regexp.h (renamed from src/webengine/regexp.h) | 3 | ||||
-rw-r--r-- | src/blocker/subscriptiondialog.ui | 67 | ||||
-rw-r--r-- | src/blocker/subscriptionform.ui (renamed from src/forms/blockerdialog.ui) | 51 | ||||
-rw-r--r-- | src/browser.cpp | 7 | ||||
-rw-r--r-- | src/browser.h | 4 | ||||
-rw-r--r-- | src/mainwindow.cpp | 6 | ||||
-rw-r--r-- | src/mainwindow.h | 4 | ||||
-rw-r--r-- | src/mainwindow.ui | 20 | ||||
-rw-r--r-- | src/webengine/urlinterceptor.cpp | 23 | ||||
-rw-r--r-- | src/webengine/urlinterceptor.h | 6 |
17 files changed, 214 insertions, 258 deletions
diff --git a/src/forms/blockerdialog.cpp b/src/blocker/blockermanager.cpp index 9c6bd0a..3dd516c 100644 --- a/src/forms/blockerdialog.cpp +++ b/src/blocker/blockermanager.cpp @@ -18,47 +18,28 @@ ** ******************************************************************************/ -#include "blockerdialog.h" -#include "ui_blockerdialog.h" +#include "blockermanager.h" +#include "ui_subscriptiondialog.h" #include "browser.h" #include <QLabel> #include <QListWidget> -BlockerDialog::BlockerDialog(QWidget *parent) : +#include "blocker/blockersubscription.h" + +BlockerManager::BlockerManager(QWidget *parent) : QDialog(parent), ui(new Ui::UrlInterceptorDialog) { ui->setupUi(this); - m_subscription = new BlockerSubscription(this); - QString sublocation = sSettings->value("blocker.path").toString(); - if(!sublocation.isEmpty()) { - m_subscription->loadFromFile(sublocation); - } - - ui->title->setText(m_subscription->title()); - ui->homepage->setText(m_subscription->homepage()); - ui->license->setText(m_subscription->license()); - ui->version->setText(m_subscription->version()); - ui->lastModified->setText(m_subscription->lastModified().toString()); - ui->expires->setText(m_subscription->expires().toString()); - - // show subscription items - for(BlockerRule *rule : m_subscription->urlBlacklist()) { - ui->blacklist_listWidget->addItem(rule->toString()); - } - for(BlockerRule *rule : m_subscription->urlWhitelist()) { - ui->whitelist_listWidget->addItem(rule->toString()); + for(QString listUrl : sSettings->value("blocker.subscriptions").toStringList()) { + BlockerSubscription *sub = new BlockerSubscription(listUrl, this); + ui->tabWidget->addTab(sub, sub->name()); } } -BlockerDialog::~BlockerDialog() +BlockerManager::~BlockerManager() { delete ui; } - -BlockerSubscription* BlockerDialog::subscription() -{ - return m_subscription; -} diff --git a/src/forms/blockerdialog.h b/src/blocker/blockermanager.h index 6970795..eb5e04e 100644 --- a/src/forms/blockerdialog.h +++ b/src/blocker/blockermanager.h @@ -22,24 +22,21 @@ #define URLINTERCEPTORDIALOG_H #include <QDialog> -#include "webengine/blockersubscription.h" namespace Ui { class UrlInterceptorDialog; } -class BlockerDialog : public QDialog +class BlockerManager : public QDialog { Q_OBJECT public: - explicit BlockerDialog(QWidget *parent = 0); - ~BlockerDialog(); - BlockerSubscription *subscription(); + explicit BlockerManager(QWidget *parent = 0); + ~BlockerManager(); private: Ui::UrlInterceptorDialog *ui; - BlockerSubscription *m_subscription; }; #endif // URLINTERCEPTORDIALOG_H diff --git a/src/webengine/blockerrule.cpp b/src/blocker/blockerrule.cpp index 79669b9..1c118e2 100644 --- a/src/webengine/blockerrule.cpp +++ b/src/blocker/blockerrule.cpp @@ -32,13 +32,13 @@ BlockerRule::BlockerRule(QString rule, QObject *parent) : // Empty rule or comment if(pattern.trimmed().isEmpty() || pattern.startsWith("!")) { - m_type = RuleType::Invalid; + m_valid = false; return; } // Ignore element hiding rules for now if(pattern.contains("##") || pattern.contains("#@#")) { - m_type = RuleType::Invalid; + m_valid = false; return; } @@ -96,7 +96,7 @@ BlockerRule::BlockerRule(QString rule, QObject *parent) : // Regular expression if(rule.startsWith("/") && rule.endsWith("/")) { - m_type = RuleType::RegularExpressionMatch; + m_valid = true; ruleExpression.setPattern(pattern); return; } @@ -118,40 +118,39 @@ BlockerRule::BlockerRule(QString rule, QObject *parent) : // Regular rule ruleExpression.setWildcardPattern(pattern); - m_type = RuleType::RegularExpressionMatch; + m_valid = true; } bool BlockerRule::match(const QWebEngineUrlRequestInfo &info) { - switch (m_type) { - case RuleType::Invalid: - break; + if(!m_valid) { + return false; + } - case RuleType::RegularExpressionMatch: - if(domainExpression.match(info.requestUrl().host())) { - if(ruleExpression.match(info.requestUrl().toString())) { - if(matchOptions(info, m_whitelistOptions)) { - return false; - } - if(matchOptions(info, m_blacklistOptions)) { - return true; - } - return true; - } + // if both domain and rule match + if(domainExpression.match(info.requestUrl().host()) && ruleExpression.match(info.requestUrl().toString())) { + + // option explicitly allows + if(matchOptions(info, m_whitelistOptions)) { + return false; } - break; + + // option explicitly bans + if(matchOptions(info, m_blacklistOptions)) { + return true; + } + + // no options, but both domain and rule match --> rule matches + return true; } + // domain and/or rule do not match return false; } bool BlockerRule::isValid() { - if(m_type == RuleType::Invalid) { - return false; - } else { - return true; - } + return m_valid; } bool BlockerRule::isException() { @@ -170,41 +169,41 @@ bool BlockerRule::matchOptions(const QWebEngineUrlRequestInfo &info, const RuleO return false; } - bool ret = false; + bool hasOption = false; switch (info.resourceType()) { case QWebEngineUrlRequestInfo::ResourceTypeScript: if(options.testFlag(RuleOption::script)) { - ret = true; + hasOption = true; } break; case QWebEngineUrlRequestInfo::ResourceTypeImage: if(options.testFlag(RuleOption::image)) { - ret = true; + hasOption = true; } break; case QWebEngineUrlRequestInfo::ResourceTypeStylesheet: if(options.testFlag(RuleOption::stylesheet)) { - ret = true; + hasOption = true; } break; case QWebEngineUrlRequestInfo::ResourceTypeObject: if(options.testFlag(RuleOption::object)) { - ret = true; + hasOption = true; } break; case QWebEngineUrlRequestInfo::ResourceTypePluginResource: if(options.testFlag(RuleOption::objectsubrequest)) { - ret = true; + hasOption = true; } break; case QWebEngineUrlRequestInfo::ResourceTypeSubFrame: if(options.testFlag(RuleOption::subdocument)) { - ret = true; + hasOption = true; } break; default: break; } - return ret; + return hasOption; } diff --git a/src/webengine/blockerrule.h b/src/blocker/blockerrule.h index bdb2eb9..0981514 100644 --- a/src/webengine/blockerrule.h +++ b/src/blocker/blockerrule.h @@ -30,11 +30,6 @@ class BlockerRule : public QObject { Q_OBJECT public: - enum RuleType { - Invalid, - RegularExpressionMatch - }; - enum RuleOption { script = 1, image = 2, @@ -70,7 +65,7 @@ public slots: private: bool matchOptions(const QWebEngineUrlRequestInfo &info, const RuleOptions &options); - RuleType m_type; + bool m_valid; bool m_exception = false; QStringList hostsBlacklist; QStringList hostsWhitelist; diff --git a/src/webengine/blockersubscription.cpp b/src/blocker/blockersubscription.cpp index 40d3e9f..02def48 100644 --- a/src/webengine/blockersubscription.cpp +++ b/src/blocker/blockersubscription.cpp @@ -19,29 +19,59 @@ ******************************************************************************/ #include "blockersubscription.h" +#include "ui_subscriptionform.h" +#include "browser.h" #include <QFile> -#include <QTextStream> +#include <QNetworkRequest> +#include <QNetworkReply> -BlockerSubscription::BlockerSubscription(QObject *parent) : - QObject(parent) +BlockerSubscription::BlockerSubscription(const QString url, QWidget *parent) : + QWidget(parent), + ui(new Ui::SubscriptionForm) { + ui->setupUi(this); + QUrl _url = QUrl::fromUserInput(url); + m_name = _url.fileName(); + + if(!sSettings->value("blocker.path").toString().isEmpty()) { + QString cacheName = sSettings->value("blocker.path").toString() + m_name; + QFile *cache = new QFile(cacheName); + if(cache->exists()) { + load(cache); + } + + } else { + + // no cache path specified - pull the subscription + QNetworkRequest request; + request.setUrl(QUrl::fromUserInput(url)); + + QNetworkReply *reply = sNetwork->get(request); + connect(reply, &QNetworkReply::finished, [this, reply]() { + this->load(reply); + }); + } } -int BlockerSubscription::loadFromFile(const QString &file) +BlockerSubscription::~BlockerSubscription() { - QFile subfile(file); - if(!subfile.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug("Cannot open subscription: %s", qUtf8Printable(file)); - return -1; - } + delete ui; +} + +QString BlockerSubscription::name() const +{ + return m_name; +} - QTextStream subscription(&subfile); +void BlockerSubscription::load(QIODevice *dev) +{ + QTextStream subscription(dev); QString header = subscription.readLine(); - if(header != "[Adblock Plus 2.0]") { - qDebug("Invalid format of subscription: %s", qUtf8Printable(file)); - return -1; + if(!header.startsWith("[Adblock Plus")) { + qDebug("Invalid format of subscription: %s", qUtf8Printable(m_name)); + return; } // clear all lists @@ -63,7 +93,9 @@ int BlockerSubscription::loadFromFile(const QString &file) if(rule->isValid()) { if(rule->isException()) { m_urlWhitelist.append(rule); + ui->whitelist_listWidget->addItem(rule->toString()); } else { + ui->blacklist_listWidget->addItem(rule->toString()); m_urlBlacklist.append(rule); } } @@ -72,74 +104,35 @@ int BlockerSubscription::loadFromFile(const QString &file) } } - qDebug("Loaded %i/%i rules from subscription %s", m_urlBlacklist.count() + m_urlWhitelist.count(), rules, qUtf8Printable(file)); - return rules; -} - -const QString BlockerSubscription::title() -{ - return m_title; -} - -const QString BlockerSubscription::homepage() -{ - return m_homepage; + qDebug("Loaded %i/%i rules from subscription %s", m_urlBlacklist.count() + m_urlWhitelist.count(), rules, qUtf8Printable(m_name)); + dev->deleteLater(); } -const QString BlockerSubscription::license() -{ - return m_license; -} - -const QString BlockerSubscription::version() -{ - return m_version; -} - -const QDateTime BlockerSubscription::lastModified() -{ - return m_lastModified; -} - -const QDateTime BlockerSubscription::expires() -{ - return m_expires; -} - -const QList<BlockerRule*> BlockerSubscription::urlBlacklist() -{ - return m_urlBlacklist; -} - -const QList<BlockerRule*> BlockerSubscription::urlWhitelist() -{ - return m_urlWhitelist; -} void BlockerSubscription::parseComment(const QString &line) { if(line.startsWith("! Title: ")) { - m_title = line.right(line.length() - 9); + ui->title->setText(line.right(line.length() - 9)); return; } if(line.startsWith("! Homepage: ")) { - m_homepage = line.right(line.length() - 12); + ui->homepage->setText(line.right(line.length() - 12)); return; } if(line.startsWith("! Licence: ")) { - m_license = line.right(line.length() - 11); + ui->license->setText(line.right(line.length() - 11)); return; } if(line.startsWith("! Version: ")) { - m_version = line.right(line.length() - 11); + ui->version->setText(line.right(line.length() - 11)); return; } if(line.startsWith("! Last modified: ")) { - m_lastModified = QDateTime::fromString(line.right(line.length() - 17), Qt::RFC2822Date); + ui->lastModified->setText(line.right(line.length() - 17)); return; } if(line.startsWith("! Expires: ")) { - m_expires = m_lastModified.addDays(line.right(line.length() - 11).left(2).toInt()); + ui->expires->setText(line.right(line.length() - 11).left(2)); return; } } diff --git a/src/webengine/blockersubscription.h b/src/blocker/blockersubscription.h index b8e3b9a..fddb93d 100644 --- a/src/webengine/blockersubscription.h +++ b/src/blocker/blockersubscription.h @@ -18,50 +18,38 @@ ** ******************************************************************************/ -#ifndef URLINTERCEPTORSUBSCRIPTION_H -#define URLINTERCEPTORSUBSCRIPTION_H +#ifndef SUBSCRIPTIONFORM_H +#define SUBSCRIPTIONFORM_H -#include <QObject> -#include <QDateTime> -#include "blockerrule.h" +#include <QWidget> +#include "blocker/blockerrule.h" -class BlockerSubscription : public QObject +namespace Ui { +class SubscriptionForm; +} + +class BlockerSubscription : public QWidget { Q_OBJECT -public: - explicit BlockerSubscription(QObject *parent = 0); - - int loadFromFile(const QString &file); - - const QString title(); - const QString homepage(); - const QString license(); - const QString version(); - const QDateTime lastModified(); - const QDateTime expires(); - const QList<BlockerRule*> urlBlacklist(); - const QList<BlockerRule*> urlWhitelist(); +public: + explicit BlockerSubscription(const QString url, QWidget *parent = 0); + ~BlockerSubscription(); -signals: + QString name() const; -public slots: +private slots: + void load(QIODevice *dev); private: void parseComment(const QString &line); - QString m_title; - QString m_homepage; - QString m_license; - - QString m_version; - QDateTime m_lastModified; - QDateTime m_expires; + Ui::SubscriptionForm *ui; + QString m_name; QList<BlockerRule*> m_urlWhitelist; // exception rules QList<BlockerRule*> m_urlBlacklist; // block rules - // element exceptions - // element blocking + }; -#endif // URLINTERCEPTORSUBSCRIPTION_H +#endif // SUBSCRIPTIONFORM_H diff --git a/src/webengine/regexp.cpp b/src/blocker/regexp.cpp index 4a5878a..a8dff79 100644 --- a/src/webengine/regexp.cpp +++ b/src/blocker/regexp.cpp @@ -27,9 +27,11 @@ RegExp::RegExp() : bool RegExp::match(const QString &subject, int offset, MatchType matchType, MatchOptions matchOptions) const { + // Empty matches all if(pattern().isEmpty()) { return true; } + return QRegularExpression::match(subject, offset, matchType, matchOptions).hasMatch(); } diff --git a/src/webengine/regexp.h b/src/blocker/regexp.h index d66a98d..16827ad 100644 --- a/src/webengine/regexp.h +++ b/src/blocker/regexp.h @@ -23,6 +23,9 @@ #include <QRegularExpression> +/*! + * Regular Expression class for AdBlockPlus filters + */ class RegExp : public QRegularExpression { public: diff --git a/src/blocker/subscriptiondialog.ui b/src/blocker/subscriptiondialog.ui new file mode 100644 index 0000000..7a63cc9 --- /dev/null +++ b/src/blocker/subscriptiondialog.ui @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UrlInterceptorDialog</class> + <widget class="QDialog" name="UrlInterceptorDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>640</width> + <height>480</height> + </rect> + </property> + <property name="windowTitle"> + <string>Blocker</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTabWidget" name="tabWidget"/> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Close</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>UrlInterceptorDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>UrlInterceptorDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/forms/blockerdialog.ui b/src/blocker/subscriptionform.ui index a84dac8..703fb6d 100644 --- a/src/forms/blockerdialog.ui +++ b/src/blocker/subscriptionform.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>UrlInterceptorDialog</class> - <widget class="QDialog" name="UrlInterceptorDialog"> + <class>SubscriptionForm</class> + <widget class="QWidget" name="SubscriptionForm"> <property name="geometry"> <rect> <x>0</x> @@ -11,7 +11,7 @@ </rect> </property> <property name="windowTitle"> - <string>Blocker</string> + <string>Form</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> @@ -142,51 +142,8 @@ </widget> </widget> </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> </layout> </widget> <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>UrlInterceptorDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>UrlInterceptorDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> + <connections/> </ui> diff --git a/src/browser.cpp b/src/browser.cpp index 4b49cbe..4697ac5 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -37,6 +37,7 @@ Browser::~Browser() qDeleteAll(m_windows); m_windows.clear(); + delete m_networkAccessManager; delete m_bookmarksManager; delete m_downloadManager; } @@ -88,6 +89,7 @@ bool Browser::preLaunch(QStringList urls) } } + m_networkAccessManager = new QNetworkAccessManager(); m_bookmarksManager = new BookmarksDialog; m_downloadManager = new DownloadDialog; @@ -106,6 +108,11 @@ Settings *Browser::settings() return m_settings; } +QNetworkAccessManager *Browser::network() +{ + return m_networkAccessManager; +} + BookmarksDialog *Browser::bookmarks() { return m_bookmarksManager; diff --git a/src/browser.h b/src/browser.h index 0a6702f..aa7c605 100644 --- a/src/browser.h +++ b/src/browser.h @@ -27,8 +27,10 @@ #include "forms/downloaddialog.h" #include <QLocalServer> #include "settings.h" +#include <QNetworkAccessManager> #define sSettings Browser::instance()->settings() +#define sNetwork Browser::instance()->network() class MainWindow; class Browser : public QApplication @@ -45,6 +47,7 @@ public: static Browser *instance(); Settings *settings(); + QNetworkAccessManager *network(); BookmarksDialog *bookmarks(); DownloadDialog *downloads(); @@ -62,6 +65,7 @@ private: Settings *m_settings; QLocalServer *m_localServer; QVector<MainWindow*> m_windows; + QNetworkAccessManager *m_networkAccessManager; BookmarksDialog *m_bookmarksManager; DownloadDialog *m_downloadManager; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 18c1e14..f455fae 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -30,7 +30,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : QMainWindow(parent), - blocklistManager(new BlockerDialog(this)), + blocklistManager(new BlockerManager(this)), ui(new Ui::MainWindow), navigationToolBar(new QToolBar(tr("Navigation"), this)), tabToolBar(new QToolBar(tr("Tab bar"), this)), @@ -62,7 +62,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : QAction *bookmarksAction = toolsMenu->addAction(tr("Bookmarks"), Browser::instance()->bookmarks(), SLOT(show())); bookmarksAction->setShortcut(QKeySequence(sSettings->value("bookmarks.dialogShortcut").toString())); toolsMenu->addSeparator(); - toolsMenu->addAction(tr("Blocker"), blocklistManager, SLOT(show())); + toolsMenu->addAction(tr("Blocker"), blocklistManager, SLOT(show()), QKeySequence::fromString(sSettings->value("blocker.shortcut").toString())); // Profile menu QMenu *profileMenu = new QMenu(tr("Profile"), menuBar); @@ -181,7 +181,7 @@ void MainWindow::loadProfile(const QString &name) } UrlRequestInterceptor *interceptor = new UrlRequestInterceptor(this); - interceptor->setSubscription(blocklistManager->subscription()); + interceptor->setSubscription(blocklistManager); m_profile->setRequestInterceptor(interceptor); connect(m_profile, SIGNAL(downloadRequested(QWebEngineDownloadItem*)), Browser::instance()->downloads(), SLOT(addDownload(QWebEngineDownloadItem*))); } diff --git a/src/mainwindow.h b/src/mainwindow.h index afc5537..da2b429 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -30,7 +30,7 @@ #include <QUrl> #include "widgets/webviewtabbar.h" #include "webengine/urlinterceptor.h" -#include "forms/blockerdialog.h" +#include "blocker/blockermanager.h" #include "widgets/loadingbar.h" namespace Ui { @@ -67,7 +67,7 @@ private slots: void handleTitleUpdated(const QString &title); private: - BlockerDialog *blocklistManager; + BlockerManager *blocklistManager; WebEngineProfile *m_profile = nullptr; // ui diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 24266d7..46f241a 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -15,26 +15,6 @@ </property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QStatusBar" name="statusBar"/>
- <action name="actionNew_Window">
- <property name="text">
- <string>New Window</string>
- </property>
- </action>
- <action name="actionNew_Tab">
- <property name="text">
- <string>New Tab</string>
- </property>
- </action>
- <action name="actionOpen">
- <property name="text">
- <string>Open</string>
- </property>
- </action>
- <action name="actionQuit">
- <property name="text">
- <string>Quit</string>
- </property>
- </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
diff --git a/src/webengine/urlinterceptor.cpp b/src/webengine/urlinterceptor.cpp index 9352af6..3c6a56e 100644 --- a/src/webengine/urlinterceptor.cpp +++ b/src/webengine/urlinterceptor.cpp @@ -27,27 +27,10 @@ UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) : void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) { - for(BlockerRule *rule : m_sub->urlWhitelist()) { - if(rule->match(info)) { - qDebug("OK %i %s", info.resourceType(), qUtf8Printable(info.requestUrl().toString())); - return; - } - } - - for(BlockerRule *rule : m_sub->urlBlacklist()) { - if(rule->match(info)) { - info.block(true); - qDebug(" %i %s", info.resourceType(), qUtf8Printable(info.requestUrl().toString())); - return; - } - } - - // rule is neither in whitelist nor blacklist - qDebug("OK %i %s", info.resourceType(), qUtf8Printable(info.requestUrl().toString())); - + // } -void UrlRequestInterceptor::setSubscription(BlockerSubscription *subscription) +void UrlRequestInterceptor::setSubscription(BlockerManager *subscription) { - m_sub = subscription; + m_blocker = subscription; } diff --git a/src/webengine/urlinterceptor.h b/src/webengine/urlinterceptor.h index 0f9fe65..00fe666 100644 --- a/src/webengine/urlinterceptor.h +++ b/src/webengine/urlinterceptor.h @@ -22,7 +22,7 @@ #define ADBLOCKINTERCEPTOR_H #include <QWebEngineUrlRequestInterceptor> -#include "blockersubscription.h" +#include "blocker/blockermanager.h" class UrlRequestInterceptor : public QWebEngineUrlRequestInterceptor { @@ -31,14 +31,14 @@ public: explicit UrlRequestInterceptor(QObject *parent = 0); void interceptRequest(QWebEngineUrlRequestInfo &info); - void setSubscription(BlockerSubscription *subscription); + void setSubscription(BlockerManager *subscription); signals: public slots: private: - BlockerSubscription *m_sub; + BlockerManager *m_blocker; }; #endif // ADBLOCKINTERCEPTOR_H |