summaryrefslogtreecommitdiffstats
path: root/src/core/browser_context_adapter.cpp
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-11-11 16:34:13 +0100
committerPierre Rossi <pierre.rossi@gmail.com>2014-11-19 16:03:59 +0100
commit84cf77bdf980b2e88938e94ace32865528dcc5fc (patch)
treeb1c3f7f5ec2300d21c840c31c27cebb9bdec41cb /src/core/browser_context_adapter.cpp
parenta9e01afcf52b58819ad5e942e01478e738dbfd79 (diff)
Refactor path building from QStandardPath
The duplicated logic was made apparent by the merge conflict resolution. Change-Id: Ib4558ca0b6b5084f851282916cbc9a6615ed33f9 Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'src/core/browser_context_adapter.cpp')
-rw-r--r--src/core/browser_context_adapter.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index b06515c2f..2b87e6e88 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -46,6 +46,17 @@
#include <QStringBuilder>
#include <QStandardPaths>
+namespace {
+inline QString buildLocationFromStandardPath(const QString &standardPath) {
+ QString location = standardPath;
+ if (location.isEmpty())
+ location = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName();
+
+ location.append(QDir::separator() % QLatin1String("QtWebEngine")
+ % QDir::separator() % QLatin1String("Default"));
+ return location;
+}
+}
BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord)
: m_offTheRecord(offTheRecord)
@@ -80,22 +91,10 @@ BrowserContextAdapter* BrowserContextAdapter::offTheRecordContext()
QString BrowserContextAdapter::dataPath() const
{
- QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
- if (dataLocation.isEmpty())
- dataLocation = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName();
-
- dataLocation.append(QDir::separator() % QLatin1String("QtWebEngine"));
- dataLocation.append(QDir::separator() % QLatin1String("Default"));
- return dataLocation;
+ return buildLocationFromStandardPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
}
QString BrowserContextAdapter::cachePath() const
{
- QString cacheLocation = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
- if (cacheLocation.isEmpty())
- cacheLocation = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName();
-
- cacheLocation.append(QDir::separator() % QLatin1String("QtWebEngine"));
- cacheLocation.append(QDir::separator() % QLatin1String("Default"));
- return cacheLocation;
+ return buildLocationFromStandardPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
}