Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 1042923003: Fail gracefully when starting Chrome with an invalid kProfileDirectory. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/profiles/profiles_state.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « no previous file | chrome/browser/profiles/profiles_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698