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

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

Issue 2582123002: Disable --load-and-launch-app, --load-apps and --cloud-print-file if last_used_profile is not avail… (Closed)
Patch Set: refactor and nit Created 4 years 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 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);
« 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