diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-09-25 18:02:23 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:05 +0100 |
commit | 02d9b5fe590303e540c1ff9111e0cfe3194f7e7d (patch) | |
tree | f2515238feb6593efc89621805046cca4d24b968 /src/webtab | |
parent | Don't overwrite downloads by default (diff) | |
download | rekonq-02d9b5fe590303e540c1ff9111e0cfe3194f7e7d.tar.xz |
New Private Browsing mode :D
Diffstat (limited to 'src/webtab')
-rw-r--r-- | src/webtab/protocolhandler.cpp | 3 | ||||
-rw-r--r-- | src/webtab/webpage.cpp | 35 | ||||
-rw-r--r-- | src/webtab/webtab.cpp | 5 | ||||
-rw-r--r-- | src/webtab/webview.cpp | 12 | ||||
-rw-r--r-- | src/webtab/webview.h | 4 |
5 files changed, 54 insertions, 5 deletions
diff --git a/src/webtab/protocolhandler.cpp b/src/webtab/protocolhandler.cpp index dd5527bd..26fd481a 100644 --- a/src/webtab/protocolhandler.cpp +++ b/src/webtab/protocolhandler.cpp @@ -278,6 +278,9 @@ void ProtocolHandler::showResults(const KFileItemList &list) _webwin->urlBar()->setQUrl(_url); _webwin->view()->setFocus(); + if (_frame->page()->settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + return; + HistoryManager::self()->addHistoryEntry(_url, _url.prettyUrl()); } } diff --git a/src/webtab/webpage.cpp b/src/webtab/webpage.cpp index cb4ea373..585c6aab 100644 --- a/src/webtab/webpage.cpp +++ b/src/webtab/webpage.cpp @@ -290,6 +290,29 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r 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) { + KIO::Integration::CookieJar *cookieJar = manager ? qobject_cast<KIO::Integration::CookieJar*>(manager->cookieJar()) : 0; + if (cookieJar) { + cookieJar->setDisableCookieStorage(true); + kDebug() << "COOKIE DISABLED -------------------------------------------------------------"; + } + } + setSessionMetaData(QL1S("no-cache"), QL1S("true")); + } + else + { + if (manager) { + KIO::Integration::CookieJar *cookieJar = manager ? qobject_cast<KIO::Integration::CookieJar*>(manager->cookieJar()) : 0; + if (cookieJar) { + cookieJar->setDisableCookieStorage(false); + } + } + removeSessionMetaData(QL1S("no-cache")); + } return KWebPage::acceptNavigationRequest(frame, request, type); } @@ -388,7 +411,12 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) switch (dlg.askEmbedOrSave()) { case KParts::BrowserOpenOrSaveQuestion::Save: - DownloadManager::self()->downloadResource(reply->url(), KIO::MetaData(), view(), !hideDialog, _suggestedFileName); + DownloadManager::self()->downloadResource(reply->url(), + KIO::MetaData(), + view(), + !hideDialog, + _suggestedFileName, + settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)); return; case KParts::BrowserOpenOrSaveQuestion::Cancel: @@ -664,13 +692,14 @@ void WebPage::downloadRequest(const QNetworkRequest &request) { DownloadManager::self()->downloadResource(request.url(), request.attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap(), - view()); + view(), false, QString(), settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)); } void WebPage::downloadUrl(const KUrl &url) { - DownloadManager::self()->downloadResource(url, KIO::MetaData(), view()); + DownloadManager::self()->downloadResource(url, KIO::MetaData(), view(), false, QString(), + settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)); } diff --git a/src/webtab/webtab.cpp b/src/webtab/webtab.cpp index bc40ecca..1a4c0fe2 100644 --- a/src/webtab/webtab.cpp +++ b/src/webtab/webtab.cpp @@ -293,7 +293,10 @@ void WebTab::showMessageBar() void WebTab::loadFinished() { - // add page to history + // add page to history, if not in private browsing mode + if (page()->settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + return; + QString pageTitle = (page() && page()->isOnRekonqPage()) ? url().url() : m_webView->title(); HistoryManager::self()->addHistoryEntry(url(), pageTitle); } diff --git a/src/webtab/webview.cpp b/src/webtab/webview.cpp index 618edf3c..e8b629ec 100644 --- a/src/webtab/webview.cpp +++ b/src/webtab/webview.cpp @@ -368,6 +368,11 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow())); menu.addAction(a); + a = new KAction(KIcon("view-media-artist"), i18n("Open in Private &Window"), this); + a->setData(m_contextMenuHitResult.linkUrl()); + connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInPrivateWindow())); + menu.addAction(a); + menu.addSeparator(); // Don't show dots if we are NOT going to ask for download path @@ -741,6 +746,13 @@ void WebView::openLinkInNewTab() emit loadUrl(url, Rekonq::NewTab); } +void WebView::openLinkInPrivateWindow() +{ + KAction *a = qobject_cast<KAction*>(sender()); + KUrl url(a->data().toUrl()); + + emit loadUrl(url, Rekonq::NewPrivateWindow); +} void WebView::bookmarkLink() { diff --git a/src/webtab/webview.h b/src/webtab/webview.h index 5487a59f..ba4c0df4 100644 --- a/src/webtab/webview.h +++ b/src/webtab/webview.h @@ -94,8 +94,10 @@ protected: private Q_SLOTS: void search(); - void openLinkInNewWindow(); void openLinkInNewTab(); + void openLinkInNewWindow(); + void openLinkInPrivateWindow(); + void bookmarkLink(); void spellCheck(); void spellCheckerCorrected(const QString& original, int pos, const QString& replacement); |