1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Qt5: Take advantage of builtin 3rdparty cookie storage policy.

It will now be much more accurate.
This commit is contained in:
nowrep 2012-12-21 16:25:00 +01:00
parent 69eed9efe0
commit f6a55a4c07

View File

@ -21,6 +21,7 @@
#include "settings.h"
#include <QNetworkCookie>
#include <QWebSettings>
#include <QDateTime>
#include <QDebug>
@ -95,6 +96,12 @@ void CookieJar::loadSettings()
m_whitelist = settings.value("whitelist", QStringList()).toStringList();
m_blacklist = settings.value("blacklist", QStringList()).toStringList();
settings.endGroup();
#if QT_VERSION >= 0x050000
mApp->webSettings()->setThirdPartyCookiePolicy(m_blockThirdParty ?
QWebSettings::AlwaysBlockThirdPartyCookies :
QWebSettings::AlwaysAllowThirdPartyCookies);
#endif
}
void CookieJar::setAllowCookies(bool allow)
@ -104,6 +111,8 @@ void CookieJar::setAllowCookies(bool allow)
bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie) const
{
Q_UNUSED(domain)
const QString &cookieDomain = cookie.domain();
if (!m_allowCookies) {
@ -126,6 +135,8 @@ bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie
}
}
// This feature is now natively in QtWebKit in Qt 5
#if QT_VERSION < 0x050000
if (m_blockThirdParty) {
bool result = blockThirdParty(cookieDomain, domain);
if (result) {
@ -135,6 +146,7 @@ bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie
return true;
}
}
#endif
if (m_filterTrackingCookie && cookie.name().startsWith("__utm")) {
#ifdef COOKIE_DEBUG