Index: chrome/browser/ui/startup/startup_browser_creator.cc |
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc |
index 20f8ceacbc74547c6f0362231cbd9500af1882bd..ab5f471aeee0f9690fa53e8bc6bb701c1de927dc 100644 |
--- a/chrome/browser/ui/startup/startup_browser_creator.cc |
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc |
@@ -628,6 +628,8 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
last_used_profile->GetPath()); |
bool signin_required = profile_index != std::string::npos && |
profile_info.ProfileIsSigninRequiredAtIndex(profile_index); |
+ |
+ // Guest or locked profiles cannot be re-opened on startup. |
if (signin_required || last_used_profile->IsGuestSession()) { |
UserManager::Show(base::FilePath(), |
profiles::USER_MANAGER_NO_TUTORIAL, |
@@ -641,6 +643,16 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
return false; |
} |
} else { |
+ // Guest profiles should not be reopened on startup. This can happen if |
+ // the last used profile was a Guest, but other profiles were also open |
+ // when Chrome was closed. In this case, pick a different open profile |
+ // to be the active one, since the Guest profile is never added to the list |
+ // of open profiles. |
+ if (switches::IsNewAvatarMenu() && last_used_profile->IsGuestSession()) { |
+ DCHECK(!last_opened_profiles[0]->IsGuestSession()); |
+ last_used_profile = last_opened_profiles[0]; |
sky
2014/10/16 19:51:12
How do you know last_opened_profiles isn't a guest
noms (inactive)
2014/10/16 19:57:05
Only non-off-the-record profiles are added to the
|
+ } |
+ |
// Launch the last used profile with the full command line, and the other |
// opened profiles without the URLs to launch. |
CommandLine command_line_without_urls(command_line.GetProgram()); |
@@ -663,11 +675,6 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
!HasPendingUncleanExit(*it)) |
continue; |
- // Don't re-open a browser window for the guest profile. |
- if (switches::IsNewAvatarMenu() && |
sky
2014/10/16 19:51:12
Can't this still happen?
noms (inactive)
2014/10/16 19:57:05
No, since none of the profiles in last_opened_prof
|
- (*it)->IsGuestSession()) |
- continue; |
- |
if (!browser_creator->LaunchBrowser((*it == last_used_profile) ? |
command_line : command_line_without_urls, *it, cur_dir, |
is_process_startup, is_first_run, return_code)) |
@@ -677,12 +684,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
} |
// This must be done after all profiles have been launched so the observer |
// knows about all profiles to wait for before activating this one. |
- |
- // If the last used profile was the guest one, we didn't open it so |
- // we don't need to activate it either. |
- if (!switches::IsNewAvatarMenu() && |
- !last_used_profile->IsGuestSession()) |
- profile_launch_observer.Get().set_profile_to_activate(last_used_profile); |
+ profile_launch_observer.Get().set_profile_to_activate(last_used_profile); |
} |
return true; |
} |