Set correct paths for cache and persistent data

Also disable persistent data storage when in private mode
remotes/origin/falkon
David Rosca 11 years ago
parent 0eab2dfb68
commit c08a584333
  1. 33
      src/lib/app/mainapplication.cpp
  2. 5
      src/lib/app/mainapplication.h
  3. 3
      src/lib/other/clearprivatedata.cpp
  4. 6
      src/lib/preferences/preferences.cpp

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,7 +49,6 @@
#include "html5permissions/html5permissionsmanager.h"
#include <QWebEngineSettings>
#include <QNetworkDiskCache>
#include <QDesktopServices>
#include <QFontDatabase>
#include <QSqlDatabase>
@ -61,7 +60,7 @@
#include <QProcess>
#include <QTimer>
#include <QDir>
#include <QWebEngineProfile>
#include <QStandardPaths>
#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
@ -80,7 +79,6 @@ MainApplication::MainApplication(int &argc, char** argv)
, m_autoFill(0)
, m_cookieJar(0)
, m_plugins(0)
, m_networkCache(0)
, m_browsingLibrary(0)
, m_rssManager(0)
, m_networkManager(0)
@ -507,21 +505,6 @@ PluginProxy* MainApplication::plugins()
return m_plugins;
}
QNetworkDiskCache* MainApplication::networkCache()
{
if (!m_networkCache) {
Settings settings;
const QString defaultBasePath = QString("%1/networkcache/").arg(DataPaths::currentProfilePath());
const QString basePath = settings.value("Web-Browser-Settings/CachePath", defaultBasePath).toString();
const QString cachePath = QString("%1/QtWebEngine/").arg(basePath);
m_networkCache = new QNetworkDiskCache(this);
m_networkCache->setCacheDirectory(cachePath);
}
return m_networkCache;
}
BrowsingLibrary* MainApplication::browsingLibrary()
{
if (!m_browsingLibrary) {
@ -893,11 +876,23 @@ void MainApplication::loadSettings()
webSettings->setFontSize(QWebEngineSettings::MinimumLogicalFontSize, settings.value("MinimumLogicalFontSize", 5).toInt());
settings.endGroup();
QWebEngineProfile* profile = QWebEngineProfile::defaultProfile();
profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
profile->setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies);
profile->setPersistentStoragePath(DataPaths::currentProfilePath());
const QString defaultBasePath = QSL("%1/networkcache/").arg(DataPaths::currentProfilePath());
const QString basePath = settings.value("Web-Browser-Settings/CachePath", defaultBasePath).toString();
const QString cachePath = QString("%1/QtWebEngine/").arg(basePath);
profile->setCachePath(cachePath);
if (isPrivate()) {
webSettings->setAttribute(QWebEngineSettings::LocalStorageEnabled, false);
#if QTWEBENGINE_DISABLED
webSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
#endif
profile->setHttpCacheType(QWebEngineProfile::MemoryHttpCache);
profile->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
history()->setSaving(false);
}

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,7 +27,6 @@
#include "qzcommon.h"
class QMenu;
class QNetworkDiskCache;
class QNetworkAccessManager;
class History;
@ -88,7 +87,6 @@ public:
AutoFill* autoFill();
CookieJar* cookieJar();
PluginProxy* plugins();
QNetworkDiskCache* networkCache();
BrowsingLibrary* browsingLibrary();
RSSManager* rssManager();
@ -153,7 +151,6 @@ private:
AutoFill* m_autoFill;
CookieJar* m_cookieJar;
PluginProxy* m_plugins;
QNetworkDiskCache* m_networkCache;
BrowsingLibrary* m_browsingLibrary;
RSSManager* m_rssManager;

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -82,7 +82,6 @@ void ClearPrivateData::clearWebDatabases()
void ClearPrivateData::clearCache()
{
mApp->networkCache()->clear();
#if QTWEBENGINE_DISABLED
QWebEngineSettings::globalSettings()->clearMemoryCaches();
#endif

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -58,7 +58,7 @@
#include <QCloseEvent>
#include <QColorDialog>
#include <QDesktopWidget>
#include <QNetworkDiskCache>
#include <QWebEngineProfile>
#include <QWebEngineSettings>
static QString createLanguageItem(const QString &lang)
@ -306,7 +306,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
ui->allowCache->setChecked(settings.value("AllowLocalCache", true).toBool());
ui->cacheMB->setValue(settings.value("LocalCacheSize", 50).toInt());
ui->MBlabel->setText(settings.value("LocalCacheSize", 50).toString() + " MB");
ui->cachePath->setText(settings.value("CachePath", mApp->networkCache()->cacheDirectory()).toString());
ui->cachePath->setText(settings.value("CachePath", QWebEngineProfile::defaultProfile()->cachePath()).toString());
connect(ui->allowCache, SIGNAL(clicked(bool)), this, SLOT(allowCacheChanged(bool)));
connect(ui->cacheMB, SIGNAL(valueChanged(int)), this, SLOT(cacheValueChanged(int)));
connect(ui->changeCachePath, SIGNAL(clicked()), this, SLOT(changeCachePathClicked()));

Loading…
Cancel
Save