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.
This commit is contained in:
Marshall Greenblatt 2020-04-01 16:55:36 -04:00
parent 66433c1869
commit 3d87a68561
2 changed files with 6 additions and 3 deletions

View File

@ -162,8 +162,10 @@ PrefService* ChromeBrowserProcessStub::local_state() {
base::FilePath(CefString(&settings.cache_path)); base::FilePath(CefString(&settings.cache_path));
// Used for very early NetworkService initialization. // 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( local_state_ = browser_prefs::CreatePrefService(
nullptr, cache_path, !!settings.persist_user_preferences); nullptr /* profile */, cache_path, true /* persist_user_preferences */);
} }
return local_state_.get(); return local_state_.get();
} }

View File

@ -83,6 +83,7 @@ std::string GetAcceptLanguageList(Profile* profile) {
} // namespace } // namespace
const char kUserPrefsFileName[] = "UserPrefs.json"; const char kUserPrefsFileName[] = "UserPrefs.json";
const char kLocalPrefsFileName[] = "LocalPrefs.json";
std::unique_ptr<PrefService> CreatePrefService(Profile* profile, std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
const base::FilePath& cache_path, const base::FilePath& cache_path,
@ -118,8 +119,8 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
// Used to store user preferences. // Used to store user preferences.
scoped_refptr<PersistentPrefStore> user_pref_store; scoped_refptr<PersistentPrefStore> user_pref_store;
if (store_on_disk) { if (store_on_disk) {
const base::FilePath& pref_path = const base::FilePath& pref_path = cache_path.AppendASCII(
cache_path.AppendASCII(browser_prefs::kUserPrefsFileName); profile ? kUserPrefsFileName : kLocalPrefsFileName);
scoped_refptr<JsonPrefStore> json_pref_store = new JsonPrefStore( scoped_refptr<JsonPrefStore> json_pref_store = new JsonPrefStore(
pref_path, std::unique_ptr<PrefFilter>(), sequenced_task_runner); pref_path, std::unique_ptr<PrefFilter>(), sequenced_task_runner);
factory.set_user_prefs(json_pref_store.get()); factory.set_user_prefs(json_pref_store.get());