diff --git a/libcef/browser/browser_context_impl.cc b/libcef/browser/browser_context_impl.cc index 60528c3dc..0e8d5881e 100644 --- a/libcef/browser/browser_context_impl.cc +++ b/libcef/browser/browser_context_impl.cc @@ -265,17 +265,12 @@ void CefBrowserContextImpl::Initialize() { CefString(&CefContext::Get()->settings().accept_language_list); } - // Initialize a temporary PrefService object that may be referenced during - // BrowserContextServices initialization. - pref_service_ = - browser_prefs::CreatePrefService(this, base::FilePath(), false, true); + // Initialize the PrefService object. + pref_service_ = browser_prefs::CreatePrefService( + this, cache_path_, !!settings_.persist_user_preferences); CefBrowserContext::Initialize(); - // Initialize the real PrefService object. - pref_service_ = browser_prefs::CreatePrefService( - this, cache_path_, !!settings_.persist_user_preferences, false); - // Initialize visited links management. base::FilePath visited_link_path; if (!cache_path_.empty()) diff --git a/libcef/browser/prefs/browser_prefs.cc b/libcef/browser/prefs/browser_prefs.cc index 0b78191c5..a197c18b6 100644 --- a/libcef/browser/prefs/browser_prefs.cc +++ b/libcef/browser/prefs/browser_prefs.cc @@ -97,8 +97,7 @@ const char kUserPrefsFileName[] = "UserPrefs.json"; std::unique_ptr CreatePrefService(Profile* profile, const base::FilePath& cache_path, - bool persist_user_preferences, - bool is_pre_initialization) { + bool persist_user_preferences) { const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); @@ -115,8 +114,7 @@ std::unique_ptr CreatePrefService(Profile* profile, factory.set_command_line_prefs(command_line_pref_store); // True if preferences will be stored on disk. - const bool store_on_disk = - !cache_path.empty() && persist_user_preferences && !is_pre_initialization; + const bool store_on_disk = !cache_path.empty() && persist_user_preferences; scoped_refptr sequenced_task_runner; if (store_on_disk) { @@ -142,26 +140,23 @@ std::unique_ptr CreatePrefService(Profile* profile, } #if BUILDFLAG(ENABLE_SUPERVISED_USERS) - // Don't access factories during pre-initialization. - if (!is_pre_initialization) { - // Used to store supervised user preferences. - SupervisedUserSettingsService* supervised_user_settings = - SupervisedUserSettingsServiceFactory::GetForProfile(profile); + // Used to store supervised user preferences. + SupervisedUserSettingsService* supervised_user_settings = + SupervisedUserSettingsServiceFactory::GetForProfile(profile); - if (store_on_disk) { - supervised_user_settings->Init(cache_path, sequenced_task_runner.get(), - true); - } else { - scoped_refptr cef_pref_store = new CefPrefStore(); - cef_pref_store->SetInitializationCompleted(); - supervised_user_settings->Init(cef_pref_store); - } - - scoped_refptr supervised_user_prefs = make_scoped_refptr( - new SupervisedUserPrefStore(supervised_user_settings)); - DCHECK(supervised_user_prefs->IsInitializationComplete()); - factory.set_supervised_user_prefs(supervised_user_prefs); + if (store_on_disk) { + supervised_user_settings->Init(cache_path, sequenced_task_runner.get(), + true); + } else { + scoped_refptr cef_pref_store = new CefPrefStore(); + cef_pref_store->SetInitializationCompleted(); + supervised_user_settings->Init(cef_pref_store); } + + scoped_refptr supervised_user_prefs = + make_scoped_refptr(new SupervisedUserPrefStore(supervised_user_settings)); + DCHECK(supervised_user_prefs->IsInitializationComplete()); + factory.set_supervised_user_prefs(supervised_user_prefs); #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) // Registry that will be populated with all known preferences. Preferences diff --git a/libcef/browser/prefs/browser_prefs.h b/libcef/browser/prefs/browser_prefs.h index c9654f2cc..ce1e9e63f 100644 --- a/libcef/browser/prefs/browser_prefs.h +++ b/libcef/browser/prefs/browser_prefs.h @@ -19,13 +19,10 @@ namespace browser_prefs { // Name for the user prefs JSON file. extern const char kUserPrefsFileName[]; -// Create the PrefService used to manage pref registration and storage. If -// |is_pre_initialization| is true a non-persistent PrefService will be created -// for temporary usage during BrowserContextServices initialization. +// Create the PrefService used to manage pref registration and storage. std::unique_ptr CreatePrefService(Profile* profile, const base::FilePath& cache_path, - bool persist_user_preferences, - bool is_pre_initialization); + bool persist_user_preferences); } // namespace browser_prefs