diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2019-05-24 14:59:43 +0200 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2019-06-13 14:33:37 +0200 |
commit | 9680828ac40d6e10eac02f4981f3668669409acf (patch) | |
tree | aabb21fc66835ac66d2857b328ea80a7ba8a463d /src/core/profile_qt.h | |
parent | 93827875d4515a686978d98ff239332ce1adcb01 (diff) |
Persistent storage of preferences between app runs
We can now persist the user preferences to disk at application exit so
they are correctly remembered for the next run. The preferences are
stored in dataPath()/user_prefs.json. This is managed via the
PrefServiceAdapter class.
It's not possible to test this in a correct pattern as we require the
app to exit properly to be able to guarantee that the preferences are
written to disk. The code added in ~PrefServiceAdapter() does not
provide any guarantees in the next profile construction that the
previous preferences have been written to disk.
Fixes: QTBUG-75740
Change-Id: I96bb3037707d90b05b3dfab4f083702351923aee
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/profile_qt.h')
-rw-r--r-- | src/core/profile_qt.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h index 704c5a6e4..76749fdfe 100644 --- a/src/core/profile_qt.h +++ b/src/core/profile_qt.h @@ -45,6 +45,7 @@ #include "content/public/browser/resource_context.h" #include "extensions/buildflags/buildflags.h" #include "net/url_request/url_request_context.h" +#include "pref_service_adapter.h" #include "profile_io_data_qt.h" #include <QtGlobal> @@ -107,6 +108,7 @@ public: std::vector<network::mojom::CorsOriginPatternPtr> block_patterns, base::OnceClosure closure) override; const content::SharedCorsOriginAccessList* GetSharedCorsOriginAccessList() const override; + std::string GetMediaDeviceIDSalt() override; // Profile implementation: PrefService *GetPrefs() override; @@ -118,15 +120,19 @@ public: #if QT_CONFIG(webengine_spellchecker) void FailedToLoadDictionary(const std::string &language) override; - void setSpellCheckLanguages(const QStringList &languages); - QStringList spellCheckLanguages() const; - void setSpellCheckEnabled(bool enabled); - bool isSpellCheckEnabled() const; #endif #if BUILDFLAG(ENABLE_EXTENSIONS) extensions::ExtensionSystemQt* GetExtensionSystem(); #endif // defined(ENABLE_EXTENSIONS) + // Build/Re-build the preference service. Call when updating the storage + // data path. + void setupPrefService(); + + PrefServiceAdapter &prefServiceAdapter(); + + const PrefServiceAdapter &prefServiceAdapter() const; + private: friend class ContentBrowserClientQt; friend class WebContentsAdapter; @@ -134,10 +140,11 @@ private: std::unique_ptr<BrowsingDataRemoverDelegateQt> m_removerDelegate; std::unique_ptr<PermissionManagerQt> m_permissionManager; std::unique_ptr<SSLHostStateDelegateQt> m_sslHostStateDelegate; - std::unique_ptr<PrefService> m_prefService; scoped_refptr<content::SharedCorsOriginAccessList> m_sharedCorsOriginAccessList; std::unique_ptr<ProfileIODataQt> m_profileIOData; ProfileAdapter *m_profileAdapter; + PrefServiceAdapter m_prefServiceAdapter; + friend class ProfileAdapter; #if BUILDFLAG(ENABLE_EXTENSIONS) extensions::ExtensionSystemQt *m_extensionSystem; |