summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tabwindow/tabwindow.cpp5
-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
-rw-r--r--src/webwindow/webwindow.cpp18
-rw-r--r--src/webwindow/webwindow.h7
9 files changed, 71 insertions, 90 deletions
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index 59aa1275..7fa7439d 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -217,10 +217,7 @@ WebWindow *TabWindow::webWindow(int index) const
WebWindow *TabWindow::prepareNewTab(WebPage *page)
{
- WebWindow *tab = new WebWindow(this, page);
-
- if (_isPrivateBrowsing)
- tab->setPrivateBrowsing(true);
+ WebWindow *tab = new WebWindow(this, _isPrivateBrowsing, page);
connect(tab, SIGNAL(titleChanged(QString)), this, SLOT(tabTitleChanged(QString)));
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
diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp
index 616ccc69..74d1eda7 100644
--- a/src/webwindow/webwindow.cpp
+++ b/src/webwindow/webwindow.cpp
@@ -70,9 +70,9 @@
#include <QVBoxLayout>
-WebWindow::WebWindow(QWidget *parent, WebPage *pg)
+WebWindow::WebWindow(QWidget *parent, bool isPrivateBrowsing, WebPage *pg)
: QWidget(parent)
- , _tab(new WebTab(this))
+ , _tab(new WebTab(this, isPrivateBrowsing))
, _bar(new UrlBar(_tab))
, _mainToolBar(0)
, m_findBar(new FindBar(this))
@@ -81,7 +81,6 @@ WebWindow::WebWindow(QWidget *parent, WebPage *pg)
, m_popup(new QLabel(this))
, m_hidePopupTimer(new QTimer(this))
, _ac(new KActionCollection(this))
- , _isPrivateBrowsing(false)
{
if (pg)
{
@@ -897,19 +896,6 @@ void WebWindow::toggleBookmarksToolbar(bool b)
}
-bool WebWindow::isPrivateBrowsing()
-{
- return _isPrivateBrowsing;
-}
-
-
-void WebWindow::setPrivateBrowsing(bool on)
-{
- _tab->page()->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, on);
- _isPrivateBrowsing = on;
-}
-
-
void WebWindow::showCrashMessageBar()
{
_tab->showCrashMessageBar();
diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h
index 3f7fcc54..55c8b1d7 100644
--- a/src/webwindow/webwindow.h
+++ b/src/webwindow/webwindow.h
@@ -62,7 +62,7 @@ class WebWindow : public QWidget
Q_OBJECT
public:
- WebWindow(QWidget *parent = 0, WebPage *pg = 0);
+ WebWindow(QWidget *parent = 0, bool isPrivateBrowsing = false, WebPage *pg = 0);
~WebWindow();
void load(const QUrl &);
@@ -82,8 +82,6 @@ public:
virtual KActionCollection *actionCollection() const;
QAction *actionByName(const QString &name);
- bool isPrivateBrowsing();
-
void checkFocus();
private:
@@ -92,7 +90,6 @@ private:
public Q_SLOTS:
void setWidgetsHidden(bool hide);
- void setPrivateBrowsing(bool);
private Q_SLOTS:
void webLoadProgress(int);
@@ -177,8 +174,6 @@ private:
QTimer *m_hidePopupTimer;
KActionCollection *_ac;
-
- bool _isPrivateBrowsing;
};
#endif // WEB_WINDOW