Index: chrome/browser/profiles/profile_manager.cc |
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc |
index e2d2cc1cb85530ec4436bfe0169bf0aa87f6f62d..4c472a92e23b4c826cfd5b4667d1658483ce022b 100644 |
--- a/chrome/browser/profiles/profile_manager.cc |
+++ b/chrome/browser/profiles/profile_manager.cc |
@@ -645,6 +645,7 @@ ProfileShortcutManager* ProfileManager::profile_shortcut_manager() { |
void ProfileManager::ScheduleProfileForDeletion( |
const base::FilePath& profile_dir, |
+ bool suppress_profile_creation, |
const CreateCallback& callback) { |
DCHECK(profiles::IsMultipleProfilesEnabled()); |
@@ -675,32 +676,35 @@ void ProfileManager::ScheduleProfileForDeletion( |
} |
} |
- base::FilePath new_path; |
- if (last_non_supervised_profile_path.empty()) { |
+ base::FilePath new_path = last_non_supervised_profile_path; |
+ if (new_path.empty()) { |
// If we are using --new-avatar-menu, then assign the default |
// placeholder avatar and name. Otherwise, use random ones. |
- bool is_new_avatar_menu = switches::IsNewAvatarMenu(); |
- int avatar_index = profiles::GetPlaceholderAvatarIndex(); |
- base::string16 new_avatar_url = is_new_avatar_menu ? |
- base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl(avatar_index)) : |
- base::string16(); |
- base::string16 new_profile_name = is_new_avatar_menu ? |
- cache.ChooseNameForNewProfile(avatar_index) : base::string16(); |
+ base::string16 new_avatar_url; |
+ base::string16 new_profile_name; |
+ if (switches::IsNewAvatarMenu()) { |
+ int avatar_index = profiles::GetPlaceholderAvatarIndex(); |
+ new_avatar_url = |
+ base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl(avatar_index)); |
+ new_profile_name = cache.ChooseNameForNewProfile(avatar_index); |
+ } |
new_path = GenerateNextProfileDirectoryPath(); |
- CreateProfileAsync(new_path, |
- base::Bind(&ProfileManager::OnNewActiveProfileLoaded, |
- base::Unretained(this), |
- profile_dir, |
- new_path, |
- callback), |
- new_profile_name, |
- new_avatar_url, |
- std::string()); |
- |
- ProfileMetrics::LogProfileAddNewUser( |
- ProfileMetrics::ADD_NEW_USER_LAST_DELETED); |
- return; |
+ if (!suppress_profile_creation) { |
+ CreateProfileAsync(new_path, |
+ base::Bind(&ProfileManager::OnNewActiveProfileLoaded, |
+ base::Unretained(this), |
+ profile_dir, |
+ new_path, |
+ callback), |
+ new_profile_name, |
+ new_avatar_url, |
+ std::string()); |
+ |
+ ProfileMetrics::LogProfileAddNewUser( |
+ ProfileMetrics::ADD_NEW_USER_LAST_DELETED); |
+ return; |
+ } |
} |
#if defined(OS_MACOSX) |
@@ -709,8 +713,10 @@ void ProfileManager::ScheduleProfileForDeletion( |
// profile has been loaded, we must pre-load a next one. |
const std::string last_used_profile = |
g_browser_process->local_state()->GetString(prefs::kProfileLastUsed); |
- if (last_used_profile == profile_dir.BaseName().MaybeAsASCII() || |
- last_used_profile == GetGuestProfilePath().BaseName().MaybeAsASCII()) { |
+ if ((last_used_profile == profile_dir.BaseName().MaybeAsASCII() || |
+ last_used_profile == GetGuestProfilePath().BaseName().MaybeAsASCII()) && |
+ !suppress_profile_creation) { |
+ DCHECK(!last_non_supervised_profile_path.empty()); |
CreateProfileAsync(last_non_supervised_profile_path, |
base::Bind(&ProfileManager::OnNewActiveProfileLoaded, |
base::Unretained(this), |
@@ -724,18 +730,7 @@ void ProfileManager::ScheduleProfileForDeletion( |
} |
#endif // defined(OS_MACOSX) |
- FinishDeletingProfile(profile_dir, last_non_supervised_profile_path); |
-} |
- |
-// static |
-void ProfileManager::CleanUpStaleProfiles( |
- const std::vector<base::FilePath>& profile_paths) { |
- DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
- |
- for (std::vector<base::FilePath>::const_iterator it = profile_paths.begin(); |
- it != profile_paths.end(); ++it) { |
- NukeProfileFromDisk(*it); |
- } |
+ FinishDeletingProfile(profile_dir, new_path); |
} |
void ProfileManager::AutoloadProfiles() { |
@@ -1377,7 +1372,8 @@ void ProfileManager::BrowserListObserver::OnBrowserRemoved( |
if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) && |
!IsProfileMarkedForDeletion(path)) { |
g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
- path, ProfileManager::CreateCallback()); |
+ path, false /* suppress_profile_creation */, |
+ ProfileManager::CreateCallback()); |
} |
} |
@@ -1418,7 +1414,9 @@ void ProfileManager::OnNewActiveProfileLoaded( |
// If the profile we tried to load as the next active profile has been |
// deleted, then retry deleting this profile to redo the logic to load |
// the next available profile. |
- ScheduleProfileForDeletion(profile_to_delete_path, original_callback); |
+ ScheduleProfileForDeletion(profile_to_delete_path, |
+ false /* suppress_profile_creation */, |
+ original_callback); |
return; |
} |