summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/browser/browserapplication.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-05-08 12:58:28 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-05-11 11:54:28 +0000
commit4db8c2c92ae8bc722de70e4bd317dce17dea2f74 (patch)
tree3462ae22be4a7cb107e46f2b050649a8cddbf73f /examples/webenginewidgets/browser/browserapplication.cpp
parent76a990cfa3409214530e77d132cdefd9e96685f9 (diff)
Reintroduce private browsing mode for example browser
Uses QWebEngineProfile to support private browsing mode. Change-Id: I78fa712d2425eb2df519594ee3fa5639bbcbebf6 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'examples/webenginewidgets/browser/browserapplication.cpp')
-rw-r--r--examples/webenginewidgets/browser/browserapplication.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/examples/webenginewidgets/browser/browserapplication.cpp b/examples/webenginewidgets/browser/browserapplication.cpp
index b1426ea24..3bc801295 100644
--- a/examples/webenginewidgets/browser/browserapplication.cpp
+++ b/examples/webenginewidgets/browser/browserapplication.cpp
@@ -116,6 +116,8 @@ static void setUserStyleSheet(QWebEngineProfile *profile, const QString &styleSh
BrowserApplication::BrowserApplication(int &argc, char **argv)
: QApplication(argc, argv)
, m_localServer(0)
+ , m_privateProfile(0)
+ , m_privateBrowsing(false)
{
QCoreApplication::setOrganizationName(QLatin1String("Qt"));
QCoreApplication::setApplicationName(QLatin1String("demobrowser"));
@@ -325,11 +327,8 @@ void BrowserApplication::clean()
void BrowserApplication::saveSession()
{
-#if defined(QTWEBENGINE_PRIVATEBROWSING)
- QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
- if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
+ if (m_privateBrowsing)
return;
-#endif
clean();
@@ -529,3 +528,24 @@ QIcon BrowserApplication::defaultIcon() const
m_defaultIcon = QIcon(QLatin1String(":defaulticon.png"));
return m_defaultIcon;
}
+
+void BrowserApplication::setPrivateBrowsing(bool privateBrowsing)
+{
+ if (m_privateBrowsing == privateBrowsing)
+ return;
+ m_privateBrowsing = privateBrowsing;
+ if (privateBrowsing) {
+ if (!m_privateProfile)
+ m_privateProfile = new QWebEngineProfile(this);
+ Q_FOREACH (BrowserMainWindow* window, mainWindows()) {
+ window->tabWidget()->setProfile(m_privateProfile);
+ }
+ } else {
+ Q_FOREACH (BrowserMainWindow* window, mainWindows()) {
+ window->tabWidget()->setProfile(QWebEngineProfile::defaultProfile());
+ window->m_lastSearch = QString::null;
+ window->tabWidget()->clear();
+ }
+ }
+ emit privateBrowsingChanged(privateBrowsing);
+}