| 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 9caec3b3b51986a3d74f665f9aa47bbd0971989f..856a2addb0ef60346109ee149825425eea2fc8f0 100644
|
| --- a/chrome/browser/ui/startup/startup_browser_creator.cc
|
| +++ b/chrome/browser/ui/startup/startup_browser_creator.cc
|
| @@ -262,34 +262,36 @@ void DumpBrowserHistograms(const base::FilePath& output_file) {
|
| static_cast<int>(output_string.size()));
|
| }
|
|
|
| -// Shows the User Manager on startup if the last used profile must sign in or
|
| -// if the last used profile was the guest or system profile.
|
| -// Returns true if the User Manager was shown, false otherwise.
|
| -bool ShowUserManagerOnStartupIfNeeded(
|
| - Profile* last_used_profile, const base::CommandLine& command_line) {
|
| +// Returns whether |profile| can be opened during Chrome startup without
|
| +// explicit user action.
|
| +bool ProfileCanBeAutoOpened(Profile* profile) {
|
| #if defined(OS_CHROMEOS)
|
| - // ChromeOS never shows the User Manager on startup.
|
| - return false;
|
| + // On ChromeOS, ther user has alrady chosen and logged into the profile
|
| + // before Chrome starts up.
|
| + return true;
|
| #else
|
| + // Profiles that require signin are not available.
|
| ProfileAttributesEntry* entry = nullptr;
|
| - bool has_entry =
|
| - g_browser_process->profile_manager()
|
| + if (g_browser_process->profile_manager()
|
| ->GetProfileAttributesStorage()
|
| - .GetProfileAttributesWithPath(last_used_profile->GetPath(), &entry);
|
| -
|
| - if (!has_entry || !entry->IsSigninRequired()) {
|
| - // Signin is not required. However, guest, system or locked profiles cannot
|
| - // be re-opened on startup. The only exception is if there's already a Guest
|
| - // window open in a separate process (for example, launching a new browser
|
| - // after clicking on a downloaded file in Guest mode).
|
| - if ((!last_used_profile->IsGuestSession() &&
|
| - !last_used_profile->IsSystemProfile()) ||
|
| - (chrome::GetBrowserCount(last_used_profile->GetOffTheRecordProfile()) >
|
| - 0)) {
|
| - return false;
|
| - }
|
| + .GetProfileAttributesWithPath(profile->GetPath(), &entry) &&
|
| + entry->IsSigninRequired()) {
|
| + return false;
|
| }
|
|
|
| + // Guest or system profiles are not available unless a separate process
|
| + // already has a window open for the profile.
|
| + return (!profile->IsGuestSession() && !profile->IsSystemProfile()) ||
|
| + (chrome::GetBrowserCount(profile->GetOffTheRecordProfile()) > 0);
|
| +#endif
|
| +}
|
| +
|
| +// Returns whether the User Manager was shown.
|
| +bool ShowUserManagerOnStartupIfNeeded(Profile* last_used_profile,
|
| + const base::CommandLine& command_line) {
|
| + if (ProfileCanBeAutoOpened(last_used_profile))
|
| + return false;
|
| +
|
| // Show the User Manager.
|
| profiles::UserManagerAction action =
|
| command_line.HasSwitch(switches::kShowAppList) ?
|
| @@ -298,7 +300,6 @@ bool ShowUserManagerOnStartupIfNeeded(
|
| UserManager::Show(
|
| base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, action);
|
| return true;
|
| -#endif
|
| }
|
|
|
| } // namespace
|
| @@ -587,11 +588,16 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
|
| }
|
|
|
| bool silent_launch = false;
|
| + bool can_use_last_profile =
|
| + (ProfileCanBeAutoOpened(last_used_profile) &&
|
| + !IncognitoModePrefs::ShouldLaunchIncognito(
|
| + command_line, last_used_profile->GetPrefs()));
|
|
|
| #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
| // If we are just displaying a print dialog we shouldn't open browser
|
| // windows.
|
| if (command_line.HasSwitch(switches::kCloudPrintFile) &&
|
| + can_use_last_profile &&
|
| print_dialog_cloud::CreatePrintDialogFromCommandLine(last_used_profile,
|
| command_line)) {
|
| silent_launch = true;
|
| @@ -683,8 +689,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
|
| return true;
|
|
|
| if (command_line.HasSwitch(extensions::switches::kLoadApps) &&
|
| - !IncognitoModePrefs::ShouldLaunchIncognito(
|
| - command_line, last_used_profile->GetPrefs())) {
|
| + can_use_last_profile) {
|
| if (!ProcessLoadApps(command_line, cur_dir, last_used_profile))
|
| return false;
|
|
|
| @@ -698,9 +703,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
|
| }
|
|
|
| // Check for --load-and-launch-app.
|
| - if (command_line.HasSwitch(apps::kLoadAndLaunchApp) &&
|
| - !IncognitoModePrefs::ShouldLaunchIncognito(
|
| - command_line, last_used_profile->GetPrefs())) {
|
| + if (command_line.HasSwitch(apps::kLoadAndLaunchApp) && can_use_last_profile) {
|
| base::CommandLine::StringType path =
|
| command_line.GetSwitchValueNative(apps::kLoadAndLaunchApp);
|
|
|
|
|