summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp17
-rw-r--r--src/application.h4
-rw-r--r--src/download/downloadmanager.cpp17
-rw-r--r--src/download/downloadmanager.h2
-rw-r--r--src/icons/iconmanager.cpp2
-rw-r--r--src/rekonq_defines.h3
-rw-r--r--src/tabwindow/tabwindow.cpp17
-rw-r--r--src/tabwindow/tabwindow.h8
-rw-r--r--src/urlbar/urlbar.cpp4
-rw-r--r--src/webtab/protocolhandler.cpp3
-rw-r--r--src/webtab/webpage.cpp35
-rw-r--r--src/webtab/webtab.cpp5
-rw-r--r--src/webtab/webview.cpp12
-rw-r--r--src/webtab/webview.h4
-rw-r--r--src/webwindow/webwindow.cpp20
-rw-r--r--src/webwindow/webwindow.h5
16 files changed, 124 insertions, 34 deletions
diff --git a/src/application.cpp b/src/application.cpp
index c36ea441..831df323 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -305,7 +305,12 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
newType = Rekonq::CurrentTab;
TabWindow *w = 0;
- if (newType == Rekonq::NewWindow
+ if (newType == Rekonq::NewPrivateWindow)
+ {
+ w = newTabWindow(true, true);
+ newType = Rekonq::CurrentTab;
+ }
+ else if (newType == Rekonq::NewWindow
|| (newType == Rekonq::NewTab && ReKonfig::openLinksInNewWindow()))
{
w = newTabWindow();
@@ -320,9 +325,9 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
}
-TabWindow *Application::newTabWindow()
+TabWindow *Application::newTabWindow(bool withTab, bool PrivateBrowsingMode)
{
- TabWindow *w = new TabWindow;
+ TabWindow *w = new TabWindow(withTab, PrivateBrowsingMode);
// set object name
int n = m_tabWindows.count() + 1;
@@ -719,3 +724,9 @@ void Application::newTab()
{
tabWindow()->newCleanTab();
}
+
+
+void Application::newPrivateBrowsingWindow()
+{
+ loadUrl(KUrl("about:incognito"), Rekonq::NewPrivateWindow);
+}
diff --git a/src/application.h b/src/application.h
index 240963ef..0b3711ac 100644
--- a/src/application.h
+++ b/src/application.h
@@ -88,7 +88,7 @@ public Q_SLOTS:
const Rekonq::OpenType& type = Rekonq::CurrentTab
);
- TabWindow *newTabWindow();
+ TabWindow *newTabWindow(bool withTab = true, bool PrivateBrowsingMode = false);
protected:
// This is used to track which window was activated most recently
@@ -108,6 +108,8 @@ private Q_SLOTS:
void createWebAppShortcut();
void newTab();
+
+ void newPrivateBrowsingWindow();
private:
TabWindowList m_tabWindows;
diff --git a/src/download/downloadmanager.cpp b/src/download/downloadmanager.cpp
index 560ddb9d..0ee4d672 100644
--- a/src/download/downloadmanager.cpp
+++ b/src/download/downloadmanager.cpp
@@ -135,10 +135,6 @@ void DownloadManager::init()
DownloadItem* DownloadManager::addDownload(KIO::CopyJob *job)
{
- QWebSettings *globalSettings = QWebSettings::globalSettings();
- if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- return 0;
-
KIO::CopyJob *cJob = qobject_cast<KIO::CopyJob *>(job);
QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads");
@@ -162,10 +158,6 @@ DownloadItem* DownloadManager::addDownload(KIO::CopyJob *job)
DownloadItem* DownloadManager::addKGetDownload(const QString &srcUrl, const QString &destUrl)
{
- QWebSettings *globalSettings = QWebSettings::globalSettings();
- if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- return 0;
-
QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads");
QFile downloadFile(downloadFilePath);
if (!downloadFile.open(QFile::WriteOnly | QFile::Append))
@@ -224,7 +216,7 @@ void DownloadManager::removeDownloadItem(int index)
// 1. KGet Integration
// 2. Save downloads history
bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData &metaData,
- QWidget *parent, bool forceDirRequest, const QString &suggestedName)
+ QWidget *parent, bool forceDirRequest, const QString &suggestedName, bool registerDownload)
{
KUrl destUrl;
@@ -259,7 +251,8 @@ bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData &
QDBusMessage transfer = kget.call(QL1S("addTransfer"), srcUrl.prettyUrl(), destUrl.prettyUrl(), true);
- addKGetDownload(srcUrl.pathOrUrl(), destUrl.pathOrUrl());
+ if (registerDownload)
+ addKGetDownload(srcUrl.pathOrUrl(), destUrl.pathOrUrl());
return true;
}
@@ -273,6 +266,8 @@ bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData &
job->ui()->setWindow((parent ? parent->window() : 0));
job->ui()->setAutoErrorHandlingEnabled(true);
- addDownload(job);
+ if (registerDownload)
+ addDownload(job);
+
return true;
}
diff --git a/src/download/downloadmanager.h b/src/download/downloadmanager.h
index 5ac4d628..22998567 100644
--- a/src/download/downloadmanager.h
+++ b/src/download/downloadmanager.h
@@ -70,7 +70,7 @@ public:
bool clearDownloadsHistory();
bool downloadResource(const KUrl &url, const KIO::MetaData &metaData = KIO::MetaData(),
- QWidget *parent = 0, bool forceDirRequest = false, const QString &suggestedName = QString());
+ QWidget *parent = 0, bool forceDirRequest = false, const QString &suggestedName = QString(), bool registerDownload = true);
void downloadLinksWithKGet(const QVariant &contentList);
diff --git a/src/icons/iconmanager.cpp b/src/icons/iconmanager.cpp
index 7799eb99..33c62893 100644
--- a/src/icons/iconmanager.cpp
+++ b/src/icons/iconmanager.cpp
@@ -122,7 +122,7 @@ void IconManager::provideIcon(QWebFrame *mFrame, const KUrl &url, bool notify)
}
// do not load new icons in private browsing..
- if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ if (mFrame->page()->settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
if (notify)
emit iconChanged();
diff --git a/src/rekonq_defines.h b/src/rekonq_defines.h
index 55a8befc..a97fe24d 100644
--- a/src/rekonq_defines.h
+++ b/src/rekonq_defines.h
@@ -77,7 +77,8 @@ enum OpenType
NewTab, ///< open url according to users settings
NewFocusedTab, ///< open url in new tab and focus it
NewBackGroundTab, ///< open url in new background tab
- NewWindow ///< open url in new window
+ NewWindow, ///< open url in new window
+ NewPrivateWindow ///< open url in new private window
};
/**
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index a0f43fa1..cd4ec8ce 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -29,6 +29,7 @@
#include "tabwindow.moc"
// Local Includes
+#include "application.h"
#include "webpage.h"
#include "webwindow.h"
#include "tabbar.h"
@@ -59,10 +60,11 @@
#include <QWebSettings>
-TabWindow::TabWindow(bool withTab, QWidget *parent)
+TabWindow::TabWindow(bool withTab, bool PrivateBrowsingMode, QWidget *parent)
: RekonqWindow(parent)
, _addTabButton(new QToolButton(this))
, _openedTabsCounter(0)
+ , _isPrivateBrowsing(PrivateBrowsingMode)
{
setContentsMargins(0, 0, 0, 0);
@@ -140,6 +142,9 @@ WebWindow *TabWindow::prepareNewTab(WebPage *page)
{
WebWindow *tab = new WebWindow(this, page);
+ if (_isPrivateBrowsing)
+ tab->setPrivateBrowsing(true);
+
connect(tab, SIGNAL(titleChanged(QString)), this, SLOT(tabTitleChanged(QString)));
connect(tab, SIGNAL(loadStarted()), this, SLOT(tabLoadStarted()));
@@ -171,8 +176,8 @@ void TabWindow::loadUrl(const KUrl &url, Rekonq::OpenType type, TabHistory *hist
break;
case Rekonq::NewWindow:
- // TODO
-// emit loadUrlInNewWindow(url);
+ case Rekonq::NewPrivateWindow:
+ rApp->loadUrl(url, type);
return;
case Rekonq::CurrentTab:
@@ -500,3 +505,9 @@ void TabWindow::setFullScreen(bool makeFullScreen)
_addTabButton->setVisible(!makeFullScreen);
KToggleFullScreenAction::setFullScreen(this, makeFullScreen);
}
+
+
+bool TabWindow::isPrivateBrowsingWindowMode()
+{
+ return _isPrivateBrowsing;
+}
diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h
index 882ca4e9..459621c1 100644
--- a/src/tabwindow/tabwindow.h
+++ b/src/tabwindow/tabwindow.h
@@ -59,17 +59,19 @@ class TabWindow : public RekonqWindow
Q_OBJECT
public:
- TabWindow(bool withTab = true, QWidget *parent = 0);
+ TabWindow(bool withTab = true, bool PrivateBrowsingMode = false, QWidget *parent = 0);
WebWindow* currentWebWindow() const;
WebWindow* webWindow(int index) const;
TabBar* tabBar() const;
+ bool isPrivateBrowsingWindowMode();
+
public Q_SLOTS:
void loadUrl(const KUrl &, Rekonq::OpenType type = Rekonq::CurrentTab, TabHistory *history = 0);
void newCleanTab();
-
+
private:
/**
* Prepares the new WebWindow to be open
@@ -109,6 +111,8 @@ private:
int _openedTabsCounter;
QList<TabHistory> m_recentlyClosedTabs;
+
+ bool _isPrivateBrowsing;
};
#endif // TAB_WINDOW
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index db24188b..56d1370d 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -213,7 +213,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
QColor backgroundColor;
QColor foregroundColor;
- if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ if (_tab->page()->settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
backgroundColor = QColor(220, 220, 220); // light gray
foregroundColor = Qt::black;
@@ -651,7 +651,7 @@ void UrlBar::suggest()
void UrlBar::refreshFavicon()
{
- if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ if (_tab->page()->settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
_icon->setIcon(KIcon("view-media-artist"));
return;
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);
diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp
index 9e276271..592000c9 100644
--- a/src/webwindow/webwindow.cpp
+++ b/src/webwindow/webwindow.cpp
@@ -81,6 +81,7 @@ WebWindow::WebWindow(QWidget *parent, WebPage *pg)
, m_popup(new QLabel(this))
, m_hidePopupTimer(new QTimer(this))
, _ac(new KActionCollection(this))
+ , _isPrivateBrowsing(false)
{
if (pg)
{
@@ -248,10 +249,8 @@ void WebWindow::setupActions()
actionCollection()->addAction(QL1S("page_source"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(viewPageSource()));
- a = new KAction(KIcon("view-media-artist"), i18n("Private &Browsing"), this);
- a->setCheckable(true);
-// FIXME connect(a, SIGNAL(triggered(bool)), this, SLOT(setPrivateBrowsingMode(bool)));
- a->setShortcut(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_P);
+ a = new KAction(KIcon("view-media-artist"), i18n("New Private Window"), this);
+ connect(a, SIGNAL(triggered(bool)), rApp, SLOT(newPrivateBrowsingWindow()));
actionCollection()->addAction(QL1S("private_browsing"), a);
a = new KAction(KIcon("edit-clear"), i18n("Clear Private Data..."), this);
@@ -845,3 +844,16 @@ void WebWindow::toggleBookmarksToolbar(bool b)
a->setChecked(b);
rApp->bookmarksToolbarToggled(b);
}
+
+
+bool WebWindow::isPrivateBrowsing()
+{
+ return _isPrivateBrowsing;
+}
+
+
+void WebWindow::setPrivateBrowsing(bool on)
+{
+ _tab->page()->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, on);
+ _isPrivateBrowsing = on;
+}
diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h
index 35de3f10..affa5cb1 100644
--- a/src/webwindow/webwindow.h
+++ b/src/webwindow/webwindow.h
@@ -83,12 +83,15 @@ public:
virtual KActionCollection *actionCollection() const;
QAction *actionByName(const QString &name);
+ bool isPrivateBrowsing();
+
private:
void setupActions();
void setupTools();
public Q_SLOTS:
void setWidgetsHidden(bool hide);
+ void setPrivateBrowsing(bool);
private Q_SLOTS:
void webLoadProgress(int);
@@ -158,6 +161,8 @@ private:
QTimer *m_hidePopupTimer;
KActionCollection *_ac;
+
+ bool _isPrivateBrowsing;
};
#endif // WEB_WINDOW