Index: chrome/browser/chrome_browser_main.cc |
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc |
index c250470a47a87a8c9aeb8299b86069b1bfc4c714..637e4c31303200cac61ae70809f0a06ad630da50 100644 |
--- a/chrome/browser/chrome_browser_main.cc |
+++ b/chrome/browser/chrome_browser_main.cc |
@@ -353,13 +353,22 @@ Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
#else |
base::FilePath profile_path = |
GetStartupProfilePath(user_data_dir, parsed_command_line); |
+ const ProfileInfoCache& cache = |
+ g_browser_process->profile_manager()->GetProfileInfoCache(); |
+ |
+ // If we are trying to load a profile that has been deleted (for example from |
+ // an old shortcut, or using an incorrect kProfileDirectory argument), set |
+ // the active profile to Guest to force showing the User Manager. |
+ size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path); |
+ if (profile_index == std::string::npos) |
+ profile_path = ProfileManager::GetGuestProfilePath(); |
// Without NewAvatarMenu, replace guest with any existing profile. |
if (!switches::IsNewAvatarMenu() && |
profile_path == ProfileManager::GetGuestProfilePath()) { |
- profile_path = g_browser_process->profile_manager()->GetProfileInfoCache(). |
- GetPathOfProfileAtIndex(0); |
+ profile_path = cache.GetPathOfProfileAtIndex(0); |
} |
+ |
profile = g_browser_process->profile_manager()->GetProfile( |
profile_path); |
@@ -370,12 +379,7 @@ Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
if (switches::IsNewProfileManagement() && |
profile && |
!profile->IsGuestSession()) { |
- ProfileInfoCache& cache = |
- g_browser_process->profile_manager()->GetProfileInfoCache(); |
- size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path); |
- |
- if (profile_index != std::string::npos && |
- cache.ProfileIsSigninRequiredAtIndex(profile_index)) { |
+ if (cache.ProfileIsSigninRequiredAtIndex(profile_index)) { |
profile = g_browser_process->profile_manager()->GetProfile( |
ProfileManager::GetGuestProfilePath()); |
} |