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

Unified Diff: chrome/browser/ui/startup/startup_browser_creator.cc

Issue 661603007: Fix re-opening Chrome after the last active profile was a Guest profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add dcheck Created 6 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a2b639a878b3e232015b0d38c5a082c0014debad 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];
+ }
+
// 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());
@@ -653,6 +665,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
// Launch the profiles in the order they became active.
for (Profiles::const_iterator it = last_opened_profiles.begin();
it != last_opened_profiles.end(); ++it) {
+ DCHECK(!(*it)->IsGuestSession());
// Don't launch additional profiles which would only open a new tab
// page. When restarting after an update, all profiles will reopen last
// open pages.
@@ -663,11 +676,6 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
!HasPendingUncleanExit(*it))
continue;
- // Don't re-open a browser window for the guest profile.
- if (switches::IsNewAvatarMenu() &&
- (*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 +685,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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698