From 4d05c1105af23d8a5d851e254de77fdf6c4a802a Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 5 Oct 2015 22:03:53 +0200 Subject: [PATCH] Bring back support for managing cookies --- src/lib/app/mainapplication.cpp | 20 +-- src/lib/cookies/cookiejar.cpp | 162 +++----------------- src/lib/cookies/cookiejar.h | 23 +-- src/lib/cookies/cookiemanager.cpp | 230 ++++++++++++----------------- src/lib/cookies/cookiemanager.h | 17 ++- src/lib/cookies/cookiemanager.ui | 119 +++++---------- src/lib/network/networkmanager.cpp | 4 + src/lib/other/clearprivatedata.cpp | 2 +- 8 files changed, 178 insertions(+), 399 deletions(-) diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index cf5059d12..9ab570457 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -243,6 +243,16 @@ MainApplication::MainApplication(int &argc, char** argv) setQuitOnLastWindowClosed(true); #endif + QSettings::setDefaultFormat(QSettings::IniFormat); + QDesktopServices::setUrlHandler("http", this, "addNewTab"); + QDesktopServices::setUrlHandler("ftp", this, "addNewTab"); + + ProfileManager profileManager; + profileManager.initConfigDir(); + profileManager.initCurrentProfile(startProfile); + + Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini")); + m_webProfile = isPrivate() ? new QWebEngineProfile(this) : QWebEngineProfile::defaultProfile(); connect(m_webProfile, &QWebEngineProfile::downloadRequested, this, &MainApplication::downloadRequested); @@ -257,16 +267,6 @@ MainApplication::MainApplication(int &argc, char** argv) script.setSourceCode(Scripts::setupWebChannel()); m_webProfile->scripts()->insert(script); - QSettings::setDefaultFormat(QSettings::IniFormat); - QDesktopServices::setUrlHandler("http", this, "addNewTab"); - QDesktopServices::setUrlHandler("ftp", this, "addNewTab"); - - ProfileManager profileManager; - profileManager.initConfigDir(); - profileManager.initCurrentProfile(startProfile); - - Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini")); - m_autoSaver = new AutoSaver(this); connect(m_autoSaver, SIGNAL(save()), this, SLOT(saveSession())); diff --git a/src/lib/cookies/cookiejar.cpp b/src/lib/cookies/cookiejar.cpp index ab75f3a7f..6473d51e0 100644 --- a/src/lib/cookies/cookiejar.cpp +++ b/src/lib/cookies/cookiejar.cpp @@ -29,19 +29,9 @@ //#define COOKIE_DEBUG CookieJar::CookieJar(QObject* parent) - : QNetworkCookieJar(parent) - , m_autoSaver(0) + : QWebEngineCookieStoreClient(parent) { - m_autoSaver = new AutoSaver(this); - connect(m_autoSaver, SIGNAL(save()), this, SLOT(saveCookies())); - loadSettings(); - restoreCookies(); -} - -CookieJar::~CookieJar() -{ - m_autoSaver->saveIfNecessary(); } void CookieJar::loadSettings() @@ -49,28 +39,11 @@ void CookieJar::loadSettings() Settings settings; settings.beginGroup("Cookie-Settings"); m_allowCookies = settings.value("allowCookies", true).toBool(); - m_allowThirdParty = settings.value("allowThirdPartyCookies", 0).toInt(); + m_filterThirdParty = settings.value("filterThirdPartyCookies", false).toBool(); m_filterTrackingCookie = settings.value("filterTrackingCookie", false).toBool(); - m_deleteOnClose = settings.value("deleteCookiesOnClose", false).toBool(); m_whitelist = settings.value("whitelist", QStringList()).toStringList(); m_blacklist = settings.value("blacklist", QStringList()).toStringList(); settings.endGroup(); - -#if QTWEBENGINE_DISABLED - switch (m_allowThirdParty) { - case 0: - QWebSettings::defaultSettings()->setThirdPartyCookiePolicy(QWebSettings::AlwaysAllowThirdPartyCookies); - break; - - case 1: - QWebSettings::defaultSettings()->setThirdPartyCookiePolicy(QWebSettings::AlwaysBlockThirdPartyCookies); - break; - - case 2: - QWebSettings::defaultSettings()->setThirdPartyCookiePolicy(QWebSettings::AllowThirdPartyWithExistingCookies); - break; - } -#endif } void CookieJar::setAllowCookies(bool allow) @@ -78,126 +51,17 @@ void CookieJar::setAllowCookies(bool allow) m_allowCookies = allow; } -bool CookieJar::setCookiesFromUrl(const QList &cookieList, const QUrl &url) +bool CookieJar::acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource) { - QList newList; + const QList cookies = QNetworkCookie::parseCookies(cookieLine); + Q_ASSERT(cookies.size() == 1); - foreach (QNetworkCookie cookie, cookieList) { - // If cookie domain is empty, set it to url.host() - if (cookie.domain().isEmpty()) { - cookie.setDomain(url.host()); - } - - if (!rejectCookie(url.host(), cookie)) { - newList.append(cookie); - } - } - - bool added = QNetworkCookieJar::setCookiesFromUrl(newList, url); - - if (added) { - m_autoSaver->changeOcurred(); - } - - return added; + QNetworkCookie cookie = cookies.first(); + return !rejectCookie(firstPartyUrl.host(), cookie, cookieSource.host()); } -QList CookieJar::allCookies() const +bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie, const QString &cookieDomain) const { - return QNetworkCookieJar::allCookies(); -} - -void CookieJar::setAllCookies(const QList &cookieList) -{ - m_autoSaver->changeOcurred(); - QNetworkCookieJar::setAllCookies(cookieList); -} - -void CookieJar::clearCookies() -{ - setAllCookies(QList()); -} - -void CookieJar::restoreCookies() -{ - if (mApp->isPrivate()) { - return; - } - - const QString cookiesFile = DataPaths::currentProfilePath() + QLatin1String("/cookies.dat"); - QDateTime now = QDateTime::currentDateTime(); - - QList restoredCookies; - QFile file(cookiesFile); - file.open(QIODevice::ReadOnly); - QDataStream stream(&file); - int count; - - stream >> count; - for (int i = 0; i < count; i++) { - QByteArray rawForm; - stream >> rawForm; - const QList &cookieList = QNetworkCookie::parseCookies(rawForm); - if (cookieList.isEmpty()) { - continue; - } - - const QNetworkCookie cookie = cookieList.at(0); - - if (cookie.expirationDate() < now) { - continue; - } - restoredCookies.append(cookie); - } - - file.close(); - QNetworkCookieJar::setAllCookies(restoredCookies); -} - -void CookieJar::saveCookies() -{ - if (mApp->isPrivate()) { - return; - } - - QList cookies = allCookies(); - - if (m_deleteOnClose) { - // If we are deleting cookies on close, save only whitelisted cookies - cookies.clear(); - QList aCookies = allCookies(); - - foreach (const QNetworkCookie &cookie, aCookies) { - if (listMatchesDomain(m_whitelist, cookie.domain())) { - cookies.append(cookie); - } - } - } - - QFile file(DataPaths::currentProfilePath() + QLatin1String("/cookies.dat")); - file.open(QIODevice::WriteOnly); - QDataStream stream(&file); - int count = cookies.count(); - - stream << count; - for (int i = 0; i < count; i++) { - const QNetworkCookie cookie = cookies.at(i); - - if (cookie.isSessionCookie()) { - continue; - } - stream << cookie.toRawForm(); - } - - file.close(); -} - -bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie) const -{ - Q_UNUSED(domain) - - const QString cookieDomain = cookie.domain(); - if (!m_allowCookies) { bool result = listMatchesDomain(m_whitelist, cookieDomain); if (!result) { @@ -218,6 +82,16 @@ bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie } } + if (m_filterThirdParty) { + bool result = matchDomain(cookieDomain, domain); + if (!result) { +#ifdef COOKIE_DEBUG + qDebug() << "purged for domain mismatch" << cookie << cookieDomain << domain; +#endif + return true; + } + } + if (m_filterTrackingCookie && cookie.name().startsWith("__utm")) { #ifdef COOKIE_DEBUG qDebug() << "purged as tracking " << cookie; diff --git a/src/lib/cookies/cookiejar.h b/src/lib/cookies/cookiejar.h index db63e010a..f0e74815d 100644 --- a/src/lib/cookies/cookiejar.h +++ b/src/lib/cookies/cookiejar.h @@ -20,50 +20,37 @@ #include #include -#include +#include #include "qzcommon.h" class AutoSaver; -class QUPZILLA_EXPORT CookieJar : public QNetworkCookieJar +class QUPZILLA_EXPORT CookieJar : public QWebEngineCookieStoreClient { Q_OBJECT public: explicit CookieJar(QObject* parent = 0); - ~CookieJar(); void loadSettings(); void setAllowCookies(bool allow); - bool setCookiesFromUrl(const QList &cookieList, const QUrl &url); - - QList allCookies() const; - void setAllCookies(const QList &cookieList); - - void clearCookies(); - void restoreCookies(); - -private slots: - void saveCookies(); + bool acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource) Q_DECL_OVERRIDE; protected: bool matchDomain(QString cookieDomain, QString siteDomain) const; bool listMatchesDomain(const QStringList &list, const QString &cookieDomain) const; private: - bool rejectCookie(const QString &domain, const QNetworkCookie &cookie) const; + bool rejectCookie(const QString &domain, const QNetworkCookie &cookie, const QString &cookieDomain) const; bool m_allowCookies; bool m_filterTrackingCookie; - int m_allowThirdParty; - bool m_deleteOnClose; + bool m_filterThirdParty; QStringList m_whitelist; QStringList m_blacklist; - - AutoSaver* m_autoSaver; }; #endif // COOKIEJAR_H diff --git a/src/lib/cookies/cookiemanager.cpp b/src/lib/cookies/cookiemanager.cpp index 7444d8677..c8c0542da 100644 --- a/src/lib/cookies/cookiemanager.cpp +++ b/src/lib/cookies/cookiemanager.cpp @@ -35,7 +35,6 @@ CookieManager::CookieManager() : QWidget() , ui(new Ui::CookieManager) - , m_refreshCookieJar(true) { setAttribute(Qt::WA_DeleteOnClose); @@ -53,8 +52,7 @@ CookieManager::CookieManager() // Stored Cookies connect(ui->cookieTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); connect(ui->removeAll, SIGNAL(clicked()), this, SLOT(removeAll())); - connect(ui->removeOne, SIGNAL(clicked()), this, SLOT(removeCookie())); - connect(ui->blockDomain, SIGNAL(clicked()), this, SLOT(blockCurrentHostAndRemoveCookie())); + connect(ui->removeOne, SIGNAL(clicked()), this, SLOT(remove())); connect(ui->close, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close())); connect(ui->close2, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close())); connect(ui->close3, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close())); @@ -70,16 +68,12 @@ CookieManager::CookieManager() Settings settings; settings.beginGroup("Cookie-Settings"); ui->saveCookies->setChecked(settings.value("allowCookies", true).toBool()); - if (!ui->saveCookies->isChecked()) { - ui->deleteCookiesOnClose->setEnabled(false); - } - ui->deleteCookiesOnClose->setChecked(settings.value("deleteCookiesOnClose", false).toBool()); - ui->allowThirdPartyCookies->setCurrentIndex(settings.value("allowThirdPartyCookies", 0).toInt()); + ui->filter3rdParty->setChecked(settings.value("filterThirdPartyCookies", false).toBool()); ui->filterTracking->setChecked(settings.value("filterTrackingCookie", false).toBool()); + ui->whiteList->addItems(settings.value("whitelist", QStringList()).toStringList()); + ui->blackList->addItems(settings.value("blacklist", QStringList()).toStringList()); settings.endGroup(); - connect(ui->saveCookies, SIGNAL(toggled(bool)), this, SLOT(saveCookiesChanged(bool))); - ui->search->setPlaceholderText(tr("Search")); ui->cookieTree->setDefaultItemShowMode(TreeWidget::ItemsCollapsed); ui->cookieTree->sortItems(0, Qt::AscendingOrder); @@ -89,9 +83,19 @@ CookieManager::CookieManager() QShortcut* removeShortcut = new QShortcut(QKeySequence("Del"), this); connect(removeShortcut, SIGNAL(activated()), this, SLOT(deletePressed())); - QzTools::setWmClass("Cookies", this); + connect(ui->search, SIGNAL(textChanged(QString)), this, SLOT(filterString(QString))); + connect (mApp->cookieJar(), &CookieJar::cookieAdded, this, &CookieManager::addCookie); + connect (mApp->cookieJar(), &CookieJar::cookieRemoved, this, &CookieManager::removeCookie); - refreshTable(); + // Load cookies + mApp->cookieJar()->getAllCookies([this](const QByteArray &res) { + const QList &allCookies = QNetworkCookie::parseCookies(res); + foreach (const QNetworkCookie &cookie, allCookies) { + addCookie(cookie); + } + }); + + QzTools::setWmClass("Cookies", this); } void CookieManager::removeAll() @@ -102,56 +106,31 @@ void CookieManager::removeAll() return; } - QList emptyList; - mApp->cookieJar()->setAllCookies(emptyList); + mApp->cookieJar()->deleteAllCookies(); + + m_itemHash.clear(); + m_domainHash.clear(); ui->cookieTree->clear(); } -void CookieManager::removeCookie() +void CookieManager::remove() { QTreeWidgetItem* current = ui->cookieTree->currentItem(); if (!current) { return; } - QList allCookies = mApp->cookieJar()->allCookies(); - - if (current->text(1).isEmpty()) { //Remove whole cookie group - const QString domain = current->data(0, Qt::UserRole + 10).toString(); - foreach (const QNetworkCookie &cookie, allCookies) { - if (cookie.domain() == domain || cookie.domain() == domain.mid(1)) { - allCookies.removeOne(cookie); - } + if (current->childCount()) { + for (int i = 0; i < current->childCount(); ++i) { + QTreeWidgetItem *item = current->child(i); + if (item && m_itemHash.contains(item)) + removeCookie(m_itemHash.value(item)); } - - ui->cookieTree->deleteItem(current); } else { - const QNetworkCookie cookie = qvariant_cast(current->data(0, Qt::UserRole + 10)); - allCookies.removeOne(cookie); - - QTreeWidgetItem* parentItem = current->parent(); - ui->cookieTree->deleteItem(current); - - if (parentItem->childCount() == 0) { - ui->cookieTree->deleteItem(parentItem); - } + if (m_itemHash.contains(current)) + removeCookie(m_itemHash.value(current)); } - - mApp->cookieJar()->setAllCookies(allCookies); -} - -void CookieManager::blockCurrentHostAndRemoveCookie() -{ - QTreeWidgetItem* current = ui->cookieTree->currentItem(); - if (!current) { - return; - } - const QString domain = (current->text(1).isEmpty()) ? current->data(0, Qt::UserRole + 10).toString() : - qvariant_cast(current->data(0, Qt::UserRole + 10)).domain(); - - removeCookie(); - addBlacklist(domain); } void CookieManager::currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* parent) @@ -185,84 +164,6 @@ void CookieManager::currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem ui->removeOne->setText(tr("Remove cookie")); } -void CookieManager::refreshTable() -{ - disconnect(ui->search, SIGNAL(textChanged(QString)), this, SLOT(filterString(QString))); - ui->search->clear(); - connect(ui->search, SIGNAL(textChanged(QString)), this, SLOT(filterString(QString))); - - QTimer::singleShot(0, this, SLOT(slotRefreshTable())); - QTimer::singleShot(0, this, SLOT(slotRefreshFilters())); -} - -void CookieManager::slotRefreshTable() -{ - const QList &allCookies = mApp->cookieJar()->allCookies(); - - QApplication::setOverrideCursor(Qt::WaitCursor); - ui->cookieTree->clear(); - - int counter = 0; - QPointer guard = this; - QHash hash; - for (int i = 0; i < allCookies.count(); ++i) { - const QNetworkCookie cookie = allCookies.at(i); - QTreeWidgetItem* item; - - QString cookieDomain = cookie.domain(); - if (cookieDomain.startsWith(QLatin1Char('.'))) { - cookieDomain = cookieDomain.mid(1); - } - - QTreeWidgetItem* findParent = hash[cookieDomain]; - if (findParent) { - item = new QTreeWidgetItem(findParent); - } - else { - QTreeWidgetItem* newParent = new QTreeWidgetItem(ui->cookieTree); - newParent->setText(0, cookieDomain); - newParent->setIcon(0, IconProvider::standardIcon(QStyle::SP_DirIcon)); - newParent->setData(0, Qt::UserRole + 10, cookie.domain()); - ui->cookieTree->addTopLevelItem(newParent); - hash[cookieDomain] = newParent; - - item = new QTreeWidgetItem(newParent); - } - - item->setText(0, "." + cookieDomain); - item->setText(1, cookie.name()); - item->setData(0, Qt::UserRole + 10, QVariant::fromValue(cookie)); - ui->cookieTree->addTopLevelItem(item); - - ++counter; - if (counter > 200) { - QApplication::processEvents(); - counter = 0; - } - - if (!guard) { - break; - } - } - - QApplication::restoreOverrideCursor(); -} - -void CookieManager::slotRefreshFilters() -{ - ui->whiteList->clear(); - ui->blackList->clear(); - - Settings settings; - settings.beginGroup("Cookie-Settings"); - QStringList whiteList = settings.value("whitelist", QStringList()).toStringList(); - QStringList blackList = settings.value("blacklist", QStringList()).toStringList(); - settings.endGroup(); - - ui->whiteList->addItems(whiteList); - ui->blackList->addItems(blackList); -} - void CookieManager::addWhitelist() { const QString server = QInputDialog::getText(this, tr("Add to whitelist"), tr("Server:")); @@ -308,6 +209,26 @@ void CookieManager::addBlacklist(const QString &server) } } +QString CookieManager::cookieDomain(const QNetworkCookie &cookie) const +{ + QString domain = cookie.domain(); + if (domain.startsWith(QLatin1Char('.'))) { + domain = domain.mid(1); + } + return domain; +} + +QTreeWidgetItem *CookieManager::cookieItem(const QNetworkCookie &cookie) const +{ + QHashIterator it(m_itemHash); + while (it.hasNext()) { + it.next(); + if (it.value() == cookie) + return it.key(); + } + return Q_NULLPTR; +} + void CookieManager::removeBlacklist() { delete ui->blackList->currentItem(); @@ -316,7 +237,7 @@ void CookieManager::removeBlacklist() void CookieManager::deletePressed() { if (ui->cookieTree->hasFocus()) { - removeCookie(); + remove(); } else if (ui->whiteList->hasFocus()) { removeWhitelist(); @@ -326,11 +247,6 @@ void CookieManager::deletePressed() } } -void CookieManager::saveCookiesChanged(bool state) -{ - ui->deleteCookiesOnClose->setEnabled(state); -} - void CookieManager::filterString(const QString &string) { if (string.isEmpty()) { @@ -348,6 +264,51 @@ void CookieManager::filterString(const QString &string) } } +void CookieManager::addCookie(const QNetworkCookie &cookie) +{ + QTreeWidgetItem* item; + const QString domain = cookieDomain(cookie); + + QTreeWidgetItem* findParent = m_domainHash.value(domain); + if (findParent) { + item = new QTreeWidgetItem(findParent); + } + else { + QTreeWidgetItem* newParent = new QTreeWidgetItem(ui->cookieTree); + newParent->setText(0, domain); + newParent->setIcon(0, IconProvider::standardIcon(QStyle::SP_DirIcon)); + newParent->setData(0, Qt::UserRole + 10, cookie.domain()); + ui->cookieTree->addTopLevelItem(newParent); + m_domainHash[domain] = newParent; + + item = new QTreeWidgetItem(newParent); + } + + item->setText(0, "." + domain); + item->setText(1, cookie.name()); + item->setData(0, Qt::UserRole + 10, QVariant::fromValue(cookie)); + ui->cookieTree->addTopLevelItem(item); + + m_itemHash[item] = cookie; +} + +void CookieManager::removeCookie(const QNetworkCookie &cookie) +{ + QTreeWidgetItem *item = cookieItem(cookie); + if (!item) + return; + + m_itemHash.remove(item); + + if (item->parent() && item->parent()->childCount() == 1) { + m_domainHash.remove(cookieDomain(cookie)); + delete item->parent(); + item = Q_NULLPTR; + } + + delete item; +} + void CookieManager::closeEvent(QCloseEvent* e) { QStringList whitelist; @@ -364,8 +325,7 @@ void CookieManager::closeEvent(QCloseEvent* e) Settings settings; settings.beginGroup("Cookie-Settings"); settings.setValue("allowCookies", ui->saveCookies->isChecked()); - settings.setValue("deleteCookiesOnClose", ui->deleteCookiesOnClose->isChecked()); - settings.setValue("allowThirdPartyCookies", ui->allowThirdPartyCookies->currentIndex()); + settings.setValue("filterThirdPartyCookies", ui->filter3rdParty->isChecked()); settings.setValue("filterTrackingCookie", ui->filterTracking->isChecked()); settings.setValue("whitelist", whitelist); settings.setValue("blacklist", blacklist); diff --git a/src/lib/cookies/cookiemanager.h b/src/lib/cookies/cookiemanager.h index 4fd7d8786..1565ea001 100644 --- a/src/lib/cookies/cookiemanager.h +++ b/src/lib/cookies/cookiemanager.h @@ -28,6 +28,7 @@ class CookieManager; } class QTreeWidgetItem; +class QNetworkCookie; class BrowserWindow; @@ -43,12 +44,8 @@ public: private slots: void currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* parent); - void removeCookie(); + void remove(); void removeAll(); - void blockCurrentHostAndRemoveCookie(); - - void slotRefreshTable(); - void slotRefreshFilters(); void addWhitelist(); void removeWhitelist(); @@ -56,18 +53,24 @@ private slots: void removeBlacklist(); void deletePressed(); - void saveCookiesChanged(bool state); void filterString(const QString &string); + void addCookie(const QNetworkCookie &cookie); + void removeCookie(const QNetworkCookie &cookie); + private: void closeEvent(QCloseEvent* e); void keyPressEvent(QKeyEvent* e); + void addBlacklist(const QString &server); + QString cookieDomain(const QNetworkCookie &cookie) const; + QTreeWidgetItem *cookieItem(const QNetworkCookie &cookie) const; Ui::CookieManager* ui; - bool m_refreshCookieJar; + QHash m_domainHash; + QHash m_itemHash; }; #endif // COOKIEMANAGER_H diff --git a/src/lib/cookies/cookiemanager.ui b/src/lib/cookies/cookiemanager.ui index 7a33c7173..94c66cfe1 100644 --- a/src/lib/cookies/cookiemanager.ui +++ b/src/lib/cookies/cookiemanager.ui @@ -14,7 +14,16 @@ Cookies - + + 4 + + + 4 + + + 4 + + 4 @@ -208,7 +217,16 @@ QFrame::Raised - + + 0 + + + 0 + + + 0 + + 0 @@ -225,13 +243,6 @@ - - - - Remove and block domain - - - @@ -371,21 +382,7 @@ Settings - - - - <b>Cookie Settings</b> - - - - - - - Allow storing of cookies - - - - + Qt::Horizontal @@ -401,46 +398,24 @@ - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - + + - Delete cookies on close + Filter 3rd party cookies - - - - Qt::Horizontal - - - - 344 - 20 - - - - - - + + - Allow 3rd party cookies: + <b>Cookie Settings</b> + + + + + + + Allow storing of cookies @@ -467,7 +442,7 @@ - <b>Warning:</b> Allow 3rd party and tracking cookies options can lead to deny some cookies from sites. If you have problems with cookies, try to disable these options first! + <b>Warning:</b> Filter 3rd party and tracking cookies options can lead to deny some cookies from sites. If you have problems with cookies, try to disable these options first! true @@ -481,30 +456,6 @@ - - - - <p><b>Always:</b> Allow third-party resources to set and retrieve cookies.</p> -<p><b>Never:</b> Never allow third-party resources to set and retrieve cookies.</p> -<p><b>Keep existing:</b> If the cookie jar already contains cookies from a third-party, allow it to set and retrieve new and existing cookies.</p> - - - - Always - - - - - Never - - - - - Keep existing - - - - diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index 53945b43d..8e82d8a71 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -18,6 +18,7 @@ #include "networkmanager.h" #include "autofill.h" #include "qztools.h" +#include "cookiejar.h" #include "mainapplication.h" #include "passwordmanager.h" #include "sslerrordialog.h" @@ -48,6 +49,9 @@ NetworkManager::NetworkManager(QObject *parent) m_urlInterceptor = new NetworkUrlInterceptor(this); mApp->webProfile()->setRequestInterceptor(m_urlInterceptor); + // Create cookie jar + mApp->webProfile()->setCookieStoreClient(mApp->cookieJar()); + connect(this, &QNetworkAccessManager::authenticationRequired, this, [this](QNetworkReply *reply, QAuthenticator *auth) { authentication(reply->url(), auth); }); diff --git a/src/lib/other/clearprivatedata.cpp b/src/lib/other/clearprivatedata.cpp index 7093bb182..c627bcbe2 100644 --- a/src/lib/other/clearprivatedata.cpp +++ b/src/lib/other/clearprivatedata.cpp @@ -136,7 +136,7 @@ void ClearPrivateData::dialogAccepted() } if (ui->cookies->isChecked()) { - mApp->cookieJar()->setAllCookies(QList()); + mApp->cookieJar()->deleteAllCookies(); } if (ui->cache->isChecked()) {