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

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: pkasting's comments 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..bed9aa0829dc8e15f516a66d8ff0e29ff7617e2d 100644
--- a/chrome/browser/ui/startup/startup_browser_creator.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -262,34 +262,34 @@ 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 true if we should show the user manager on startup.
+bool ShouldShowUserManagerOnStartup(Profile* last_profile) {
#if defined(OS_CHROMEOS)
// ChromeOS never shows the User Manager on startup.
return false;
#else
+ // Avoid reopen profile that requires sign in.
Peter Kasting 2016/12/20 23:21:09 Nit: You changed my suggested comments, which is f
zmin 2016/12/21 00:09:50 Done.
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(last_profile->GetPath(), &entry) &&
+ entry->IsSigninRequired()) {
+ return true;
}
+ // Avoid reopen guest or sysmte profile, unless a separate process already has
+ // a window open for the profile,
+ return (last_profile->IsGuestSession() || last_profile->IsSystemProfile()) &&
+ (chrome::GetBrowserCount(last_profile->GetOffTheRecordProfile()) == 0);
+#endif
+}
+
+// Returns whether the User Manager was shown.
+bool ShowUserManagerOnStartupIfNeeded(Profile* last_used_profile,
+ const base::CommandLine& command_line) {
+ if (!ShouldShowUserManagerOnStartup(last_used_profile))
+ return false;
+
// Show the User Manager.
profiles::UserManagerAction action =
command_line.HasSwitch(switches::kShowAppList) ?
@@ -298,7 +298,6 @@ bool ShowUserManagerOnStartupIfNeeded(
UserManager::Show(
base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, action);
return true;
-#endif
}
} // namespace
@@ -587,11 +586,14 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
}
bool silent_launch = false;
+ bool should_show_user_manager =
+ ShouldShowUserManagerOnStartup(last_used_profile);
#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) &&
+ !should_show_user_manager &&
Peter Kasting 2016/12/20 23:21:09 Should this code have previously been checking !Sh
zmin 2016/12/21 00:09:50 I just did a quick test,--cloud-print-file will ig
Peter Kasting 2016/12/21 00:21:25 At first glance, that sounds more consistent with
print_dialog_cloud::CreatePrintDialogFromCommandLine(last_used_profile,
command_line)) {
silent_launch = true;
@@ -683,6 +685,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
return true;
if (command_line.HasSwitch(extensions::switches::kLoadApps) &&
+ !should_show_user_manager &&
!IncognitoModePrefs::ShouldLaunchIncognito(
command_line, last_used_profile->GetPrefs())) {
if (!ProcessLoadApps(command_line, cur_dir, last_used_profile))
@@ -699,6 +702,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
// Check for --load-and-launch-app.
if (command_line.HasSwitch(apps::kLoadAndLaunchApp) &&
+ !should_show_user_manager &&
!IncognitoModePrefs::ShouldLaunchIncognito(
command_line, last_used_profile->GetPrefs())) {
base::CommandLine::StringType path =
« 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