From 8fccdf08482cbce33740d437af18462eeecfd57f Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 20 May 2011 17:52:32 +0200 Subject: [PATCH] Private browsing now makes a temporary cookies, instead of disabling it all. After private browsing mode is turned off, original cookies are restored. --- src/app/qupzilla.cpp | 2 +- src/cookies/cookiejar.cpp | 13 ++++++++++++- src/cookies/cookiejar.h | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/qupzilla.cpp b/src/app/qupzilla.cpp index 229e005bf..4ad2c01f5 100644 --- a/src/app/qupzilla.cpp +++ b/src/app/qupzilla.cpp @@ -1129,7 +1129,7 @@ void QupZilla::startPrivate(bool state) } mApp->webSettings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, state); mApp->history()->setSaving(!state); - mApp->cookieJar()->setAllowCookies(!state); + mApp->cookieJar()->turnPrivateJar(state); emit message(MainApplication::CheckPrivateBrowsing, state); } diff --git a/src/cookies/cookiejar.cpp b/src/cookies/cookiejar.cpp index c905e4163..7a6bb5144 100644 --- a/src/cookies/cookiejar.cpp +++ b/src/cookies/cookiejar.cpp @@ -25,7 +25,6 @@ CookieJar::CookieJar(QupZilla* mainClass, QObject* parent) : ,p_QupZilla(mainClass) { loadSettings(); -// activeProfil = mApp->getActiveProfil(); m_activeProfil = mApp->getActiveProfil(); } @@ -127,3 +126,15 @@ void CookieJar::setAllCookies(const QList &cookieList) { QNetworkCookieJar::setAllCookies(cookieList); } + +void CookieJar::turnPrivateJar(bool state) +{ + if (state) { + m_tempList = QNetworkCookieJar::allCookies(); + QNetworkCookieJar::setAllCookies(QList()); + } else { + QNetworkCookieJar::setAllCookies(m_tempList); + m_tempList.clear(); + } +} + diff --git a/src/cookies/cookiejar.h b/src/cookies/cookiejar.h index 50e44e2b5..6592a69a0 100644 --- a/src/cookies/cookiejar.h +++ b/src/cookies/cookiejar.h @@ -39,6 +39,8 @@ public: void restoreCookies(); void setAllowCookies(bool allow); + void turnPrivateJar(bool state); + signals: public slots: @@ -51,6 +53,7 @@ private: bool m_deleteOnClose; QString m_activeProfil; + QList m_tempList; }; #endif // COOKIEJAR_H