From 9756e15a230747b4b700d8400f45c285d55955cd Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 15 Apr 2021 13:34:22 -0400 Subject: [PATCH] chrome: Don't rely on CREATE_STATUS_CREATED for disk-based profiles (see issue #2969) --- .../browser/chrome/chrome_browser_context.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libcef/browser/chrome/chrome_browser_context.cc b/libcef/browser/chrome/chrome_browser_context.cc index 37888d19a..ed65ec034 100644 --- a/libcef/browser/chrome/chrome_browser_context.cc +++ b/libcef/browser/chrome/chrome_browser_context.cc @@ -51,7 +51,6 @@ void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) { if (cache_path_ == user_data_dir) { // Use the default disk-based profile. auto profile = profile_manager->GetPrimaryUserProfile(); - ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_CREATED); ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_INITIALIZED); return; } else if (cache_path_.DirName() == user_data_dir) { @@ -92,8 +91,8 @@ void ChromeBrowserContext::ProfileCreated(Profile* profile, if (status != Profile::CreateStatus::CREATE_STATUS_CREATED && status != Profile::CreateStatus::CREATE_STATUS_INITIALIZED) { - DCHECK(!profile); - DCHECK(!profile_); + CHECK(!profile); + CHECK(!profile_); // Creation of a disk-based profile failed for some reason. Create a // new/unique OffTheRecord profile instead. @@ -104,14 +103,15 @@ void ChromeBrowserContext::ProfileCreated(Profile* profile, otr_profile = static_cast(profile_); status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED; should_destroy_ = true; + } else if (profile && !profile_) { + // May be CREATE_STATUS_CREATED or CREATE_STATUS_INITIALIZED since + // *CREATED isn't always sent for a disk-based profile that already + // exists. + profile_ = profile; } - if (status == Profile::CreateStatus::CREATE_STATUS_CREATED) { - DCHECK(profile); - DCHECK(!profile_); - profile_ = profile; - } else if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) { - DCHECK(profile_); + if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) { + CHECK(profile_); browser_prefs::SetLanguagePrefs(profile_); // Must set |profile_| before Init() calls