1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Allow whitelisted cookies to be kept

Keep whitelisted cookies from being deleted when deleteCookiesOnClose is true

Differential Revision: https://phabricator.kde.org/D13097
This commit is contained in:
Jyri Tuomisto 2018-05-25 09:31:08 +02:00 committed by David Rosca
parent 45658dc521
commit 326be38a45
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 13 additions and 4 deletions

View File

@ -786,7 +786,7 @@ void MainApplication::saveSettings()
ClearPrivateData::clearLocalStorage();
}
if (deleteCookies) {
m_cookieJar->deleteAllCookies();
m_cookieJar->deleteAllCookies(false);
}
if (deleteCache) {
QzTools::removeRecursively(mApp->webProfile()->cachePath());

View File

@ -78,9 +78,18 @@ QVector<QNetworkCookie> CookieJar::getAllCookies() const
return m_cookies;
}
void CookieJar::deleteAllCookies()
void CookieJar::deleteAllCookies(bool deleteAll)
{
m_client->deleteAllCookies();
if (deleteAll || m_whitelist.isEmpty()) {
m_client->deleteAllCookies();
return;
}
for (const QNetworkCookie &cookie : qAsConst(m_cookies)) {
if (!listMatchesDomain(m_whitelist, cookie.domain())) {
m_client->deleteCookie(cookie);
}
}
}
bool CookieJar::matchDomain(QString cookieDomain, QString siteDomain) const

View File

@ -41,7 +41,7 @@ public:
void deleteCookie(const QNetworkCookie &cookie);
QVector<QNetworkCookie> getAllCookies() const;
void deleteAllCookies();
void deleteAllCookies(bool deleteAll = true);
Q_SIGNALS:
void cookieAdded(const QNetworkCookie &cookie);