summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/application.cpp61
-rw-r--r--src/application.h11
-rw-r--r--src/iconmanager.cpp6
-rw-r--r--src/mainwindow.cpp46
-rw-r--r--src/mainwindow.h3
-rw-r--r--src/urlbar/urlbar.cpp18
-rw-r--r--src/urlbar/urlbar.h2
7 files changed, 87 insertions, 60 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);
+ }
+}
diff --git a/src/application.h b/src/application.h
index 8afb956f..b30e337c 100644
--- a/src/application.h
+++ b/src/application.h
@@ -50,6 +50,9 @@ class MainWindow;
class OpenSearchManager;
class SessionManager;
+class KAction;
+
+
namespace ThreadWeaver {class Job;}
@@ -107,6 +110,8 @@ public:
void addDownload(const QString &srcUrl, const QString &destUrl);
DownloadList downloads();
bool clearDownloadsHistory();
+
+ KAction *privateBrowsingAction() { return _privateBrowsingAction; };
public slots:
/**
@@ -124,7 +129,6 @@ public slots:
void removeMainWindow(MainWindow *window);
private slots:
-
/**
* Any actions that can be delayed until the window is visible
*/
@@ -134,6 +138,9 @@ private slots:
void updateConfiguration();
+ // the general place to set private browsing
+ void setPrivateBrowsingMode(bool);
+
private:
static QWeakPointer<HistoryManager> s_historyManager;
static QWeakPointer<BookmarkProvider> s_bookmarkProvider;
@@ -143,6 +150,8 @@ private:
static QWeakPointer<IconManager> s_iconManager;
MainWindowList m_mainWindows;
+
+ KAction *_privateBrowsingAction;
};
#endif // APPLICATION_H
diff --git a/src/iconmanager.cpp b/src/iconmanager.cpp
index 5086c59d..f5b60ea6 100644
--- a/src/iconmanager.cpp
+++ b/src/iconmanager.cpp
@@ -65,10 +65,6 @@ KIcon IconManager::iconForUrl(const KUrl &url)
// first things first.. avoid infinite loop at startup
if (url.isEmpty() || Application::instance()->mainWindowList().isEmpty())
return KIcon("text-html");
-
- // no icons in private browsing..
- if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- return KIcon("view-media-artist");
QByteArray encodedUrl = url.toEncoded();
// rekonq icons..
@@ -114,7 +110,7 @@ void IconManager::provideIcon(QWebPage *page, const KUrl &url, bool notify)
return;
}
- // no icons in private browsing..
+ // do not load new icons in private browsing..
if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
kDebug() << "Private browsing, private icon...";
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 555e58ae..7b4cf8a3 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -408,11 +408,9 @@ void MainWindow::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);
+ a = Application::instance()->privateBrowsingAction();
actionCollection()->addAction(QL1S("private_browsing"), a);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(privateBrowsing(bool)));
-
+
a = new KAction(KIcon("edit-clear"), i18n("Clear Private Data..."), this);
actionCollection()->addAction(QL1S("clear_private_data"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(clearPrivateData()));
@@ -728,42 +726,6 @@ void MainWindow::printRequested(QWebFrame *frame)
}
-void MainWindow::privateBrowsing(bool enable)
-{
- QWebSettings *settings = QWebSettings::globalSettings();
- if (enable && !settings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- {
- QString title = i18n("Are you sure you want to turn on private browsing?");
- QString text = i18n("<b>%1</b>"
- "<p>When private browsing is turned on,"
- " web pages are not added to the history,"
- " new cookies are not stored, current cookies cannot be accessed,"
- " site icons will not be stored, the session will not be saved."
- " Until you close the window, you can still click the Back and Forward buttons"
- " to return to the web pages you have opened.</p>", title);
-
- int button = KMessageBox::warningContinueCancel(this, text, title);
- if (button == KMessageBox::Continue)
- {
- settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
- m_view->urlBar()->setPrivateMode(true);
- }
- else
- {
- actionCollection()->action( QL1S("private_browsing") )->setChecked(false);
- }
- }
- else
- {
- settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
- m_view->urlBar()->setPrivateMode(false);
-
- m_lastSearch.clear();
- m_view->reloadAllTabs();
- }
-}
-
-
void MainWindow::find(const QString & search)
{
if (!currentTab())
@@ -1349,6 +1311,10 @@ bool MainWindow::queryClose()
if(Application::instance()->sessionSaving())
return true;
+ // smooth private browsing mode
+ if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ return true;
+
if (m_view->count() > 1)
{
int answer = KMessageBox::questionYesNoCancel(
diff --git a/src/mainwindow.h b/src/mainwindow.h
index ad4fa4b8..0395db4d 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -147,9 +147,6 @@ private slots:
void viewPageSource();
void viewFullScreen(bool enable);
- // Tools Menu slots
- void privateBrowsing(bool enable);
-
// Settings Menu slot
void preferences();
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 3ec0b2fa..1f4a0367 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -79,7 +79,6 @@ void IconButton::mouseReleaseEvent(QMouseEvent* event)
UrlBar::UrlBar(QWidget *parent)
: KLineEdit(parent)
, _tab(0)
- , _privateMode(false)
, _icon(new IconButton(this))
, _suggestionTimer(new QTimer(this))
{
@@ -159,7 +158,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
QColor backgroundColor;
QColor foregroundColor;
- if (_privateMode)
+ if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
backgroundColor = QColor(220, 220, 220); // light gray
foregroundColor = Qt::black;
@@ -289,12 +288,6 @@ void UrlBar::focusInEvent(QFocusEvent *event)
}
-void UrlBar::setPrivateMode(bool on)
-{
- _privateMode = on;
-}
-
-
void UrlBar::dropEvent(QDropEvent *event)
{
KLineEdit::dropEvent(event);
@@ -505,8 +498,15 @@ void UrlBar::suggest()
void UrlBar::refreshFavicon()
{
+ if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ {
+ _icon->setIcon(KIcon("view-media-artist"));
+ return;
+ }
+
KUrl u = _tab->url();
- if(u.scheme() == QL1S("about")) {
+ if(u.scheme() == QL1S("about"))
+ {
_icon->setIcon(KIcon("arrow-right"));
return;
}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index dcd0ba5b..4cdd9d9c 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -89,7 +89,6 @@ public:
explicit UrlBar(QWidget *parent = 0);
~UrlBar();
- void setPrivateMode(bool on);
void activateSuggestions(bool);
public slots:
@@ -124,7 +123,6 @@ private:
QWeakPointer<CompletionWidget> _box;
WebTab *_tab;
- bool _privateMode;
IconButton *_icon;
IconButtonPointerList _rightIconsList;