diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-06-23 13:11:58 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-06-29 09:17:28 +0200 |
commit | f341988f451c6ba1fc3b8da765c00d1d64eaff30 (patch) | |
tree | 407e1f7d121c19d20006ec7e143210a0aea7ef92 /src/core/profile_adapter.cpp | |
parent | 1a26c0ace958c3604c8a751134429dd38168a1a1 (diff) |
Return valid path in Profile::GetPath() for incognito profiles
Parts of Chromium depends on it for temporary directories it creates.
This also changes the logic of depending on it being empty as indicating
an in memory profile, so it required a bit of cleaning up.
Note this does subtly change the return value of off-the-record profiles.
Task-number: QTBUG-62957
Change-Id: Iec6e24556128c515fce27803171a766b8a9d92e3
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core/profile_adapter.cpp')
-rw-r--r-- | src/core/profile_adapter.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index 4557ad7a4..c436c8277 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -245,13 +245,17 @@ QObject* ProfileAdapter::globalQObjectRoot() QString ProfileAdapter::dataPath() const { - if (m_offTheRecord) - return QString(); if (!m_dataPath.isEmpty()) return m_dataPath; - if (!m_name.isNull()) - return buildLocationFromStandardPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation), m_name); - return QString(); + // And off-the-record or memory-only profile should not write to disk + // but Chromium often creates temporary directories anyway, so given them + // a location to do so. + QString name = m_name; + if (m_offTheRecord) + name = QStringLiteral("OffTheRecord"); + else if (m_name.isEmpty()) + name = QStringLiteral("UnknownProfile"); + return buildLocationFromStandardPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation), name); } void ProfileAdapter::setDataPath(const QString &path) @@ -259,13 +263,11 @@ void ProfileAdapter::setDataPath(const QString &path) if (m_dataPath == path) return; m_dataPath = path; - if (!m_offTheRecord) { - m_profile->setupPrefService(); - if (!m_profile->m_profileIOData->isClearHttpCacheInProgress()) - m_profile->m_profileIOData->resetNetworkContext(); - if (m_visitedLinksManager) - resetVisitedLinksManager(); - } + m_profile->setupPrefService(); + if (!m_profile->m_profileIOData->isClearHttpCacheInProgress()) + m_profile->m_profileIOData->resetNetworkContext(); + if (!m_offTheRecord && m_visitedLinksManager) + resetVisitedLinksManager(); } void ProfileAdapter::setDownloadPath(const QString &path) @@ -353,7 +355,7 @@ void ProfileAdapter::setHttpCacheType(ProfileAdapter::HttpCacheType newhttpCache ProfileAdapter::PersistentCookiesPolicy ProfileAdapter::persistentCookiesPolicy() const { - if (isOffTheRecord() || dataPath().isEmpty()) + if (isOffTheRecord() || m_name.isEmpty()) return NoPersistentCookies; return m_persistentCookiesPolicy; } @@ -372,7 +374,7 @@ ProfileAdapter::VisitedLinksPolicy ProfileAdapter::visitedLinksPolicy() const { if (isOffTheRecord() || m_visitedLinksPolicy == DoNotTrackVisitedLinks) return DoNotTrackVisitedLinks; - if (dataPath().isEmpty()) + if (m_name.isEmpty()) return TrackVisitedLinksInMemory; return m_visitedLinksPolicy; } |