From e25c011d5db32104ccdb3e8949082345efdba805 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 11 Dec 2017 18:16:50 +0100 Subject: Simple filterlist --- src/browser.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/browser.cpp') diff --git a/src/browser.cpp b/src/browser.cpp index 354b179..82972dd 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -21,6 +21,7 @@ #include "browser.h" #include #include +#include "webengine/urlinterceptor.h" #include "mainwindow.h" #include #include @@ -39,8 +40,12 @@ Browser::Browser(int &argc, char *argv[]) : Browser::~Browser() { + // TODO: fix crash here // qDeleteAll(m_windows); // m_windows.clear(); + +// qDeleteAll(m_profiles); +// m_profiles.clear(); } void Browser::setConfiguration(std::shared_ptr &config) @@ -49,6 +54,8 @@ void Browser::setConfiguration(std::shared_ptr &config) m_bookmarksManager = std::make_shared(QString::fromStdString(m_config->value("bookmarks.path").value())); m_downloadManager = std::make_shared(QString::fromStdString(m_config->value("downloads.path").value())); + m_urlRequestInterceptor = std::make_shared(QString::fromStdString(m_config->value("browser.filterPath").value())); + } void Browser::loadProfiles() @@ -66,11 +73,15 @@ void Browser::loadProfiles() const QStringList profileList = profileDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for(const QString &name : profileList) { - m_profiles.insert(name, new WebEngineProfile(name, profileDir.absoluteFilePath(name), this)); + WebEngineProfile *profile = new WebEngineProfile(name, profileDir.absoluteFilePath(name), this); + profile->setRequestInterceptor(m_urlRequestInterceptor.get()); + m_profiles.insert(name, profile); } // Also add the Off-the-record profile - m_profiles.insert("", new WebEngineProfile(this)); + WebEngineProfile *otr = new WebEngineProfile(this); + otr->setRequestInterceptor(m_urlRequestInterceptor.get()); + m_profiles.insert("", otr); // set default profile m_defaultProfile = m_profiles[QString::fromStdString(m_config->value("browser.profile").value())]; -- cgit v1.2.1