aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/webengineprofile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/webengineprofile.cpp')
-rw-r--r--src/webengine/webengineprofile.cpp157
1 files changed, 74 insertions, 83 deletions
diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp
index 62f744e..52a740f 100644
--- a/src/webengine/webengineprofile.cpp
+++ b/src/webengine/webengineprofile.cpp
@@ -19,113 +19,104 @@
******************************************************************************/
#include "webengineprofile.h"
-#include "browser.h"
#include <QSettings>
#include <QWebEngineSettings>
-#include <QFile>
WebEngineProfile::WebEngineProfile(QObject *parent) :
QWebEngineProfile(parent)
{
m_name = tr("Off-the-record");
- // Off-the-record profiles have no persistent path
+#ifdef QT_DEBUG
+ qDebug("Creating off-the-record profile");
+#endif
- m_homepage = browser->settings()->value("browser.profile.new.homepage").toUrl();
- m_newtab = browser->settings()->value("browser.profile.new.newtab").toUrl();
+ // Off-the-record profiles have no persistent path
}
-WebEngineProfile::WebEngineProfile(const QString &name, QObject *parent) :
+WebEngineProfile::WebEngineProfile(const QString &name, const QString &path, QObject *parent) :
QWebEngineProfile(name, parent)
{
m_name = name;
- setPersistentStoragePath(browser->settings()->value("browser.profile.storagePath").toString() + name);
- setCachePath(browser->settings()->value("browser.profile.cachePath").toString() + name);
+
+#ifdef QT_DEBUG
+ qDebug("Creating profile %s", qUtf8Printable(m_name));
+#endif
+
+ setPersistentStoragePath(path + "/storage");
+ setCachePath(path + "/cache");
// Read profile settings
- QString profileIniPath = browser->settings()->value("browser.profile.path").toString() + name + "/profile.ini";
-
- // If none exist, use the defaults
- if(!QFile::exists(profileIniPath)) {
- qDebug("Creating new profile...");
- m_homepage = browser->settings()->value("browser.profile.new.homepage").toUrl();
- m_newtab = browser->settings()->value("browser.profile.new.newtab").toUrl();
-
- // Else read them
- } else {
-
- qDebug("Reading profile from [%s]", qUtf8Printable(profileIniPath));
- QSettings config(profileIniPath, QSettings::IniFormat);
-
- m_homepage = config.value("homepage", m_homepage).toUrl();
- m_newtab = config.value("newtab", m_newtab).toUrl();
-
- config.beginGroup("http");
- setHttpUserAgent(config.value("userAgent").toString());
- setHttpAcceptLanguage(config.value("accept-lang").toString());
- {
- QString cacheType = config.value("cacheType").toString();
- if(cacheType == "memory") {
- setHttpCacheType(MemoryHttpCache);
- } else if(cacheType == "disk") {
- setHttpCacheType(DiskHttpCache);
- } else if(cacheType == "disabled") {
- setHttpCacheType(NoCache);
- }
+ const QString profileIniPath = path + "/profile.ini";
+ qDebug("Reading profile from [%s]", qUtf8Printable(profileIniPath));
+ QSettings config(profileIniPath, QSettings::IniFormat);
+
+ m_homepage = config.value("homepage", m_homepage).toUrl();
+ m_newtab = config.value("newtab", m_newtab).toUrl();
+
+ config.beginGroup("http");
+ setHttpUserAgent(config.value("userAgent").toString());
+ setHttpAcceptLanguage(config.value("accept-lang").toString());
+ {
+ QString cacheType = config.value("cacheType").toString();
+ if(cacheType == "memory") {
+ setHttpCacheType(MemoryHttpCache);
+ } else if(cacheType == "disk") {
+ setHttpCacheType(DiskHttpCache);
+ } else if(cacheType == "disabled") {
+ setHttpCacheType(NoCache);
}
- setHttpCacheMaximumSize(config.value("cacheSize").toInt());
- config.endGroup(); // http
-
- config.beginGroup("policy");
- {
- QString cookies = config.value("cookies").toString();
- if(cookies == "disabled") {
- setPersistentCookiesPolicy(NoPersistentCookies);
- } else if(cookies == "allow") {
- setPersistentCookiesPolicy(AllowPersistentCookies);
- } else if(cookies == "force") {
- setPersistentCookiesPolicy(ForcePersistentCookies);
- }
+ }
+ setHttpCacheMaximumSize(config.value("cacheSize").toInt());
+ config.endGroup(); // http
+
+ config.beginGroup("policy");
+ {
+ QString cookies = config.value("cookies").toString();
+ if(cookies == "disabled") {
+ setPersistentCookiesPolicy(NoPersistentCookies);
+ } else if(cookies == "allow") {
+ setPersistentCookiesPolicy(AllowPersistentCookies);
+ } else if(cookies == "force") {
+ setPersistentCookiesPolicy(ForcePersistentCookies);
}
- config.endGroup(); // policy
-
- config.beginGroup("attributes");
- settings()->setAttribute(QWebEngineSettings::AutoLoadImages, config.value("autoLoadImages", true).toBool());
- settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, config.value("javascriptEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, config.value("javascriptCanOpenWindows", true).toBool());
- settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, config.value("javascriptCanAccessClipboard", false).toBool());
- settings()->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, config.value("linksIncludedInFocusChain", true).toBool());
- settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, config.value("localStorageEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, config.value("localContentCanAccessRemoteUrls", false).toBool());
- settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, config.value("xssAuditingEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, config.value("spatialNavigationEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, config.value("localContentCanAccessFileUrls", true).toBool());
- settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, config.value("hyperlinkAuditingEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, config.value("scrollAnimatorEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, config.value("errorPageEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::PluginsEnabled, config.value("pluginsEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, config.value("fullscreenSupportEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, config.value("screenCaptureEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::WebGLEnabled, config.value("webglEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, config.value("accelerated2dCanvasEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, config.value("autoLoadIconsForPage", true).toBool());
- settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, config.value("touchIconsEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, config.value("focusOnNavigationEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, config.value("printElementBackgrounds", true).toBool());
- settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, config.value("allowRunningInsecureContent", false).toBool());
- config.endGroup(); // attributes
-
- } // QFile::exists(profilePath)
+ }
+ config.endGroup(); // policy
+
+ config.beginGroup("attributes");
+ settings()->setAttribute(QWebEngineSettings::AutoLoadImages, config.value("autoLoadImages", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, config.value("javascriptEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, config.value("javascriptCanOpenWindows", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, config.value("javascriptCanAccessClipboard", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, config.value("linksIncludedInFocusChain", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, config.value("localStorageEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, config.value("localContentCanAccessRemoteUrls", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, config.value("xssAuditingEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, config.value("spatialNavigationEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, config.value("localContentCanAccessFileUrls", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, config.value("hyperlinkAuditingEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, config.value("scrollAnimatorEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, config.value("errorPageEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::PluginsEnabled, config.value("pluginsEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, config.value("fullscreenSupportEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, config.value("screenCaptureEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::WebGLEnabled, config.value("webglEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, config.value("accelerated2dCanvasEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, config.value("autoLoadIconsForPage", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, config.value("touchIconsEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, config.value("focusOnNavigationEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, config.value("printElementBackgrounds", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, config.value("allowRunningInsecureContent", false).toBool());
+ config.endGroup(); // attributes
+
+
}
WebEngineProfile::~WebEngineProfile()
{
- if(!isOffTheRecord()) {
+ if(shouldSaveProfile) {
saveProfile();
}
- if(m_profileDialog != nullptr) {
- m_profileDialog->deleteLater();
- }
}
QString WebEngineProfile::name() const