summaryrefslogtreecommitdiff
path: root/src/application.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-10-22 00:04:47 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-10-22 00:10:28 +0200
commit7c981aa978bea7551aec99bc3c68a23cd6c8df00 (patch)
tree4db8b374676927afe7915a0cc034b477beeb3ebf /src/application.cpp
parentThis commit fixes icons handling for "rekonq pages" (eg: about urls). (diff)
downloadrekonq-7c981aa978bea7551aec99bc3c68a23cd6c8df00.tar.xz
This commit implements the new private browsign mode for rekonq:
- it implements a new KAaction in the Application class to trace changes on - stops session management and save it, restoring last visited sites on restoring mormal mode - implements necessary changes to iconmanager, urlbar & application Please, note that the private browsing mode will definitely work just on KDE SC 4.6, cause of the needed changes in kdewebkit to eg handle cookies and so on.. . Hope you like it :)
Diffstat (limited to 'src/application.cpp')
-rw-r--r--src/application.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 233be527..cadfa50f 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -55,10 +55,12 @@
#include <KMessageBox>
#include <KStandardDirs>
#include <ThreadWeaver/Weaver>
+#include <KAction>
// Qt Includes
#include <QVBoxLayout>
+
QWeakPointer<AdBlockManager> Application::s_adblockManager;
QWeakPointer<BookmarkProvider> Application::s_bookmarkProvider;
QWeakPointer<HistoryManager> Application::s_historyManager;
@@ -66,13 +68,20 @@ QWeakPointer<IconManager> Application::s_iconManager;
QWeakPointer<OpenSearchManager> Application::s_opensearchManager;
QWeakPointer<SessionManager> Application::s_sessionManager;
+
using namespace ThreadWeaver;
+
Application::Application()
: KUniqueApplication()
+ , _privateBrowsingAction(0)
{
connect(Weaver::instance(), SIGNAL(jobDone(ThreadWeaver::Job*)),
this, SLOT(loadResolvedUrl(ThreadWeaver::Job*)));
+
+ _privateBrowsingAction = new KAction(KIcon("view-media-artist"), i18n("Private &Browsing"), this);
+ _privateBrowsingAction->setCheckable(true);
+ connect(_privateBrowsingAction, SIGNAL(triggered(bool)), this, SLOT(setPrivateBrowsingMode(bool)));
}
@@ -575,3 +584,55 @@ bool Application::clearDownloadsHistory()
QFile downloadFile(downloadFilePath);
return downloadFile.remove();
}
+
+
+void Application::setPrivateBrowsingMode(bool b)
+{
+// NOTE
+// to let work nicely Private Browsing, we need the following:
+// - enable WebKit Private Browsing mode :)
+// - treat all cookies as session cookies
+// (so that they do not get saved to a persistent storage). Available from KDE SC 4.5.72, see BUG: 250122
+// - favicons (fixed in rekonq 0.5.87)
+// - save actual session (to restore it when Private Mode is closed) and stop storing it
+// - disable history saving
+
+ QWebSettings *settings = QWebSettings::globalSettings();
+ bool isJustEnabled = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled);
+ if(isJustEnabled == b)
+ return; // uhm... something goes wrong...
+
+ if (b)
+ {
+ QString caption = i18n("Are you sure you want to turn on private browsing?");
+ QString text = i18n("<b>%1</b>"
+ "<p>rekonq will save your current tabs for when you'll stop private browsing the net..</p>", caption);
+
+ int button = KMessageBox::warningContinueCancel(mainWindow(), text, caption, KStandardGuiItem::cont(), KStandardGuiItem::cancel(), i18n("don't ask again") );
+ if (button != KMessageBox::Continue)
+ return;
+
+ settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
+ _privateBrowsingAction->setChecked(true);
+
+ Q_FOREACH(const QWeakPointer<MainWindow> &w, m_mainWindows)
+ {
+ w.data()->close();
+ }
+ loadUrl( KUrl("about:home"), Rekonq::NewWindow);
+ }
+ else
+ {
+ Q_FOREACH(const QWeakPointer<MainWindow> &w, m_mainWindows)
+ {
+ w.data()->close();
+ }
+
+ settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
+ _privateBrowsingAction->setChecked(false);
+
+ loadUrl( KUrl("about:blank"), Rekonq::NewWindow);
+ if(!sessionManager()->restoreSession())
+ loadUrl( KUrl("about:home"), Rekonq::NewWindow);
+ }
+}