Index: chrome/browser/profiles/profile_manager.cc |
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc |
index a1ed001fe17b19e9026519dde70ace801855abf0..5d6cc2e30b04c4f3376d592949eef3a82d150b97 100644 |
--- a/chrome/browser/profiles/profile_manager.cc |
+++ b/chrome/browser/profiles/profile_manager.cc |
@@ -1068,6 +1068,9 @@ void ProfileManager::ScheduleProfileForDeletion( |
chrome::HostDesktopType desktop_type) { |
DCHECK(IsMultipleProfilesEnabled()); |
+ bool new_last_profile_being_loaded = false; |
+ size_t last_non_managed_profile_index; |
+ |
PrefService* local_state = g_browser_process->local_state(); |
ProfileInfoCache& cache = GetProfileInfoCache(); |
if (profile_dir.BaseName().MaybeAsASCII() == |
@@ -1079,6 +1082,7 @@ void ProfileManager::ScheduleProfileForDeletion( |
base::FilePath cur_path = cache.GetPathOfProfileAtIndex(i); |
if (cur_path != profile_dir && !cache.ProfileIsManagedAtIndex(i)) { |
last_non_managed_profile = cur_path.BaseName().MaybeAsASCII(); |
+ last_non_managed_profile_index = i; |
break; |
} |
} |
@@ -1102,9 +1106,40 @@ void ProfileManager::ScheduleProfileForDeletion( |
false); |
} else { |
local_state->SetString(prefs::kProfileLastUsed, last_non_managed_profile); |
+ |
+ // On the Mac, the browser process is not killed when all browser windows |
+ // are closed, so just in case we are deleting the active profile, and no |
+ // other profile has been loaded, we must pre-load a next one. |
+ #if defined(OS_MACOSX) |
Roger Tawa OOO till Jul 10th
2013/05/14 14:38:40
# should be at start of line.
noms (inactive)
2013/05/14 15:06:48
Done.
|
+ new_last_profile_being_loaded = true; |
+ base::FilePath path = profile_info_cache_->GetPathOfProfileAtIndex( |
+ last_non_managed_profile_index); |
+ CreateProfileAsync(path, |
+ base::Bind(&ProfileManager::OnNewActiveProfileLoaded, |
+ base::Unretained(this), |
+ profile_dir), |
Roger Tawa OOO till Jul 10th
2013/05/14 14:38:40
Why does FinishDeletingProfile() need to be deferr
noms (inactive)
2013/05/14 14:49:38
Above, we're deleting the only profile in the list
|
+ string16(), |
+ string16(), |
+ false); |
+ #endif |
} |
} |
+ if (!new_last_profile_being_loaded) |
+ FinishDeletingProfile(profile_dir); |
+} |
+ |
+void ProfileManager::OnNewActiveProfileLoaded(const base::FilePath& profile_dir, |
+ Profile* profile, |
+ Profile::CreateStatus status) { |
+ // Ensure we only call the callback once per profile creation. |
+ if (status == Profile::CREATE_STATUS_INITIALIZED) { |
+ FinishDeletingProfile(profile_dir); |
+ } |
Roger Tawa OOO till Jul 10th
2013/05/14 14:38:40
Don't need { and }.
noms (inactive)
2013/05/14 15:06:48
Done.
|
+} |
+ |
+void ProfileManager::FinishDeletingProfile(const base::FilePath& profile_dir) { |
+ ProfileInfoCache& cache = GetProfileInfoCache(); |
// TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we |
// start deleting the profile instance we need to close background apps too. |
Profile* profile = GetProfileByPath(profile_dir); |