summaryrefslogtreecommitdiff
path: root/src/webtab
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-12-16 17:04:37 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-12-16 17:04:37 +0100
commite3b8ece1ce004f2049481ceb668bf05ad3ae99f7 (patch)
treec13e0d67aeca03b1a7f95da346a128eca686676d /src/webtab
parentFix download dir choice (diff)
downloadrekonq-e3b8ece1ce004f2049481ceb668bf05ad3ae99f7.tar.xz
"Workaround" cookie management in private browsing mode
From the note in webpage file: I'm sorry I really cannot let KIO work as needed in private browsing mode. The problem is basically cookie related. This way we lose some features in private browsing mode, but we ensure PRIVACY! This change cannot be reverted until a proper fix for KIO (or the right workaround for rekonq) will be found. BUG: 303552
Diffstat (limited to 'src/webtab')
-rw-r--r--src/webtab/webpage.cpp111
-rw-r--r--src/webtab/webpage.h2
-rw-r--r--src/webtab/webtab.cpp5
-rw-r--r--src/webtab/webtab.h4
-rw-r--r--src/webtab/webview.cpp5
-rw-r--r--src/webtab/webview.h4
6 files changed, 67 insertions, 64 deletions
diff --git a/src/webtab/webpage.cpp b/src/webtab/webpage.cpp
index 171e7113..1a12f8dc 100644
--- a/src/webtab/webpage.cpp
+++ b/src/webtab/webpage.cpp
@@ -124,7 +124,7 @@ static void extractMimeType(const QNetworkReply* reply, QString& mimeType)
// ---------------------------------------------------------------------------------
-WebPage::WebPage(QWidget *parent)
+WebPage::WebPage(QWidget *parent, bool isPrivateBrowsing)
: KWebPage(parent, KWalletIntegration)
, _networkAnalyzer(false)
, _isOnRekonqPage(false)
@@ -133,26 +133,44 @@ WebPage::WebPage(QWidget *parent)
setForwardUnsupportedContent(true);
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*)));
- // rekonq Network Manager
- NetworkAccessManager *manager = new NetworkAccessManager(this);
+ if (isPrivateBrowsing)
+ {
+ // NOTE:
+ // I'm sorry I really cannot let KIO work as needed in private browsing mode.
+ // The problem is basically cookie related. This way we lose some features in private
+ // browsing mode, but we ensure PRIVACY! This change cannot be reverted until a proper
+ // fix for KIO (or the right workaround for rekonq) will be found.
+ QNetworkAccessManager *manager = new QNetworkAccessManager(this);
+ setNetworkAccessManager(manager);
+
+ // ----- last stuffs
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
+
+ settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
+ }
+ else
+ {
+ // rekonq Network Manager
+ NetworkAccessManager *manager = new NetworkAccessManager(this);
- // set network reply object to emit readyRead when it receives meta data
- manager->setEmitReadyReadOnMetaDataChange(true);
+ // set network reply object to emit readyRead when it receives meta data
+ manager->setEmitReadyReadOnMetaDataChange(true);
- // disable QtWebKit cache to just use KIO one..
- manager->setCache(0);
+ // disable QtWebKit cache to just use KIO one..
+ manager->setCache(0);
- setNetworkAccessManager(manager);
+ setNetworkAccessManager(manager);
- // activate ssl warnings
- setSessionMetaData(QL1S("ssl_activate_warnings"), QL1S("TRUE"));
+ // activate ssl warnings
+ setSessionMetaData(QL1S("ssl_activate_warnings"), QL1S("TRUE"));
+ // ----- last stuffs
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
+ }
+
// ----- Web Plugin Factory
setPluginFactory(new WebPluginFactory(this));
- // ----- last stuffs
- connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
-
connect(this, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequest(QNetworkRequest)));
connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
@@ -177,10 +195,13 @@ WebPage::~WebPage()
void WebPage::setWindow(QWidget *w)
{
- // set cookieJar window..
- NetworkAccessManager *manager = qobject_cast<NetworkAccessManager *>(networkAccessManager());
- manager->setWindow(w);
-
+ if (!settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ {
+ // set cookieJar window..
+ NetworkAccessManager *manager = qobject_cast<NetworkAccessManager *>(networkAccessManager());
+ manager->setWindow(w);
+ }
+
_protHandler.setWindow(w);
}
@@ -269,56 +290,32 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
}
}
- // Get the SSL information sent, if any...
- KIO::AccessManager *manager = qobject_cast<KIO::AccessManager*>(networkAccessManager());
- KIO::MetaData metaData = manager->requestMetaData();
- if (metaData.contains(QL1S("ssl_in_use")))
- {
- WebSslInfo info;
- info.restoreFrom(metaData.toVariant(), request.url());
- info.setUrl(request.url());
- _sslInfo = info;
- }
-
- if (isMainFrameRequest)
+ // Make sure nothing is cached when private browsing mode is enabled...
+ if (!settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
- setRequestMetaData(QL1S("main_frame_request"), QL1S("TRUE"));
- if (_sslInfo.isValid() && !domainSchemeMatch(request.url(), _sslInfo.url()))
+ // Get the SSL information sent, if any...
+ KIO::AccessManager *manager = qobject_cast<KIO::AccessManager*>(networkAccessManager());
+ KIO::MetaData metaData = manager->requestMetaData();
+ if (metaData.contains(QL1S("ssl_in_use")))
{
- _sslInfo = WebSslInfo();
+ WebSslInfo info;
+ info.restoreFrom(metaData.toVariant(), request.url());
+ info.setUrl(request.url());
+ _sslInfo = info;
}
- }
- else
- {
- setRequestMetaData(QL1S("main_frame_request"), QL1S("FALSE"));
- }
-
- // Make sure nothing is cached when private browsing mode is enabled...
- if (settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- {
- if (manager)
+ if (isMainFrameRequest)
{
- KIO::Integration::CookieJar *cookieJar = manager ? qobject_cast<KIO::Integration::CookieJar*>(manager->cookieJar()) : 0;
- if (cookieJar)
+ setRequestMetaData(QL1S("main_frame_request"), QL1S("TRUE"));
+ if (_sslInfo.isValid() && !domainSchemeMatch(request.url(), _sslInfo.url()))
{
- cookieJar->setDisableCookieStorage(true);
- kDebug() << "COOKIE DISABLED -------------------------------------------------------------";
+ _sslInfo = WebSslInfo();
}
}
- setSessionMetaData(QL1S("no-cache"), QL1S("true"));
- }
- else
- {
- if (manager)
+ else
{
- KIO::Integration::CookieJar *cookieJar = manager ? qobject_cast<KIO::Integration::CookieJar*>(manager->cookieJar()) : 0;
- if (cookieJar)
- {
- cookieJar->setDisableCookieStorage(false);
- }
+ setRequestMetaData(QL1S("main_frame_request"), QL1S("FALSE"));
}
- removeSessionMetaData(QL1S("no-cache"));
}
return KWebPage::acceptNavigationRequest(frame, request, type);
diff --git a/src/webtab/webpage.h b/src/webtab/webpage.h
index 0ce95ae1..c9bd4c69 100644
--- a/src/webtab/webpage.h
+++ b/src/webtab/webpage.h
@@ -49,7 +49,7 @@ class REKONQ_TESTS_EXPORT WebPage : public KWebPage
Q_OBJECT
public:
- explicit WebPage(QWidget *parent = 0);
+ explicit WebPage(QWidget *parent = 0, bool isPrivateBrowsing = false);
~WebPage();
void setWindow(QWidget *);
diff --git a/src/webtab/webtab.cpp b/src/webtab/webtab.cpp
index 1d80198c..ba4c9c7c 100644
--- a/src/webtab/webtab.cpp
+++ b/src/webtab/webtab.cpp
@@ -67,12 +67,13 @@
#include <QWebSettings>
-WebTab::WebTab(QWidget *parent)
+WebTab::WebTab(QWidget *parent, bool isPrivateBrowsing)
: QWidget(parent)
, m_webView(0)
, m_progress(0)
, m_part(0)
, m_zoomFactor(10)
+ , m_isPrivateBrowsing(isPrivateBrowsing)
, m_splitter(new QSplitter(this))
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -136,7 +137,7 @@ WebView *WebTab::view()
{
if (!m_webView)
{
- m_webView = new WebView(this);
+ m_webView = new WebView(this, m_isPrivateBrowsing);
}
return m_webView;
}
diff --git a/src/webtab/webtab.h b/src/webtab/webtab.h
index d016e6b2..a168e55d 100644
--- a/src/webtab/webtab.h
+++ b/src/webtab/webtab.h
@@ -58,7 +58,7 @@ class REKONQ_TESTS_EXPORT WebTab : public QWidget
Q_OBJECT
public:
- explicit WebTab(QWidget *parent = 0);
+ explicit WebTab(QWidget *parent = 0, bool isPrivateBrowsing = false);
~WebTab();
WebView *view();
@@ -127,6 +127,8 @@ private:
int m_zoomFactor;
+ bool m_isPrivateBrowsing;
+
QSplitter *m_splitter;
};
diff --git a/src/webtab/webview.cpp b/src/webtab/webview.cpp
index 8d99eeb2..c49002d6 100644
--- a/src/webtab/webview.cpp
+++ b/src/webtab/webview.cpp
@@ -86,7 +86,7 @@ static QVariant execJScript(QWebHitTestResult result, const QString& script)
// --------------------------------------------------------------------------------------------------
-WebView::WebView(QWidget* parent)
+WebView::WebView(QWidget* parent, bool isPrivateBrowsing)
: KWebView(parent, false)
, m_autoScrollTimer(new QTimer(this))
, m_verticalAutoScrollSpeed(0)
@@ -100,6 +100,7 @@ WebView::WebView(QWidget* parent)
, m_accessKeysPressed(false)
, m_accessKeysActive(false)
, m_parentTab(qobject_cast<WebTab *>(parent))
+ , m_isPrivateBrowsing(isPrivateBrowsing)
{
// loadUrl signal
connect(this, SIGNAL(loadUrl(KUrl, Rekonq::OpenType)), rApp, SLOT(loadUrl(KUrl, Rekonq::OpenType)));
@@ -153,7 +154,7 @@ WebPage *WebView::page()
WebPage *p = qobject_cast<WebPage *>(KWebView::page());
if (!p)
{
- p = new WebPage(this);
+ p = new WebPage(this, m_isPrivateBrowsing);
setPage(p);
}
return p;
diff --git a/src/webtab/webview.h b/src/webtab/webview.h
index 9d3a16dc..af199195 100644
--- a/src/webtab/webview.h
+++ b/src/webtab/webview.h
@@ -63,7 +63,7 @@ public:
TextSelection = 0x00000100
};
- explicit WebView(QWidget *parent);
+ explicit WebView(QWidget *parent, bool isPrivateBrowsing);
~WebView();
WebPage *page();
@@ -170,6 +170,8 @@ private:
bool m_accessKeysActive;
WebTab *m_parentTab;
+
+ bool m_isPrivateBrowsing;
};
#endif