From 3d87a685613181d7cc39da750a3a73a6f99270e9 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 1 Apr 2020 16:55:36 -0400 Subject: [PATCH] Always persist local_state by default (fixes issue #2890) If a cache_path is specified local_state will now be persisted to a LocalPrefs.json file. This is necessary because local_state is used to store the cookie encryption key on Windows. --- libcef/browser/chrome_browser_process_stub.cc | 4 +++- libcef/browser/prefs/browser_prefs.cc | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libcef/browser/chrome_browser_process_stub.cc b/libcef/browser/chrome_browser_process_stub.cc index 1becff3c2..8579642df 100644 --- a/libcef/browser/chrome_browser_process_stub.cc +++ b/libcef/browser/chrome_browser_process_stub.cc @@ -162,8 +162,10 @@ PrefService* ChromeBrowserProcessStub::local_state() { base::FilePath(CefString(&settings.cache_path)); // Used for very early NetworkService initialization. + // Always persist preferences for this PrefService if possible because it + // contains the cookie encryption key on Windows. local_state_ = browser_prefs::CreatePrefService( - nullptr, cache_path, !!settings.persist_user_preferences); + nullptr /* profile */, cache_path, true /* persist_user_preferences */); } return local_state_.get(); } diff --git a/libcef/browser/prefs/browser_prefs.cc b/libcef/browser/prefs/browser_prefs.cc index 5edffac37..f7d3847a6 100644 --- a/libcef/browser/prefs/browser_prefs.cc +++ b/libcef/browser/prefs/browser_prefs.cc @@ -83,6 +83,7 @@ std::string GetAcceptLanguageList(Profile* profile) { } // namespace const char kUserPrefsFileName[] = "UserPrefs.json"; +const char kLocalPrefsFileName[] = "LocalPrefs.json"; std::unique_ptr CreatePrefService(Profile* profile, const base::FilePath& cache_path, @@ -118,8 +119,8 @@ std::unique_ptr CreatePrefService(Profile* profile, // Used to store user preferences. scoped_refptr user_pref_store; if (store_on_disk) { - const base::FilePath& pref_path = - cache_path.AppendASCII(browser_prefs::kUserPrefsFileName); + const base::FilePath& pref_path = cache_path.AppendASCII( + profile ? kUserPrefsFileName : kLocalPrefsFileName); scoped_refptr json_pref_store = new JsonPrefStore( pref_path, std::unique_ptr(), sequenced_task_runner); factory.set_user_prefs(json_pref_store.get());