chrome: Don't rely on CREATE_STATUS_CREATED for disk-based profiles (see issue #2969)

This commit is contained in:
Marshall Greenblatt
2021-04-15 13:34:22 -04:00
parent a4d71d8fe2
commit 9756e15a23

View File

@@ -51,7 +51,6 @@ void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) {
if (cache_path_ == user_data_dir) { if (cache_path_ == user_data_dir) {
// Use the default disk-based profile. // Use the default disk-based profile.
auto profile = profile_manager->GetPrimaryUserProfile(); auto profile = profile_manager->GetPrimaryUserProfile();
ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_CREATED);
ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_INITIALIZED); ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_INITIALIZED);
return; return;
} else if (cache_path_.DirName() == user_data_dir) { } else if (cache_path_.DirName() == user_data_dir) {
@@ -92,8 +91,8 @@ void ChromeBrowserContext::ProfileCreated(Profile* profile,
if (status != Profile::CreateStatus::CREATE_STATUS_CREATED && if (status != Profile::CreateStatus::CREATE_STATUS_CREATED &&
status != Profile::CreateStatus::CREATE_STATUS_INITIALIZED) { status != Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
DCHECK(!profile); CHECK(!profile);
DCHECK(!profile_); CHECK(!profile_);
// Creation of a disk-based profile failed for some reason. Create a // Creation of a disk-based profile failed for some reason. Create a
// new/unique OffTheRecord profile instead. // new/unique OffTheRecord profile instead.
@@ -104,14 +103,15 @@ void ChromeBrowserContext::ProfileCreated(Profile* profile,
otr_profile = static_cast<OffTheRecordProfileImpl*>(profile_); otr_profile = static_cast<OffTheRecordProfileImpl*>(profile_);
status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED; status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED;
should_destroy_ = true; 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) { if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
DCHECK(profile); CHECK(profile_);
DCHECK(!profile_);
profile_ = profile;
} else if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
DCHECK(profile_);
browser_prefs::SetLanguagePrefs(profile_); browser_prefs::SetLanguagePrefs(profile_);
// Must set |profile_| before Init() calls // Must set |profile_| before Init() calls