Index: chrome/browser/chromeos/login/login_utils.cc |
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc |
index caef5731dcf6872eacfe81bacaf3bde15eead31c..9a591e4da2ac7c47957f5ca822190c9da5a4e1aa 100644 |
--- a/chrome/browser/chromeos/login/login_utils.cc |
+++ b/chrome/browser/chromeos/login/login_utils.cc |
@@ -144,6 +144,7 @@ class LoginUtilsImpl |
LoginStatusConsumer* consumer) OVERRIDE; |
virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; |
virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; |
+ virtual bool RestartToApplyPerSessionFlagsIfNeed(Profile* profile) OVERRIDE; |
// OAuth2LoginManager::Observer overrides. |
virtual void OnSessionRestoreStateChanged( |
@@ -220,6 +221,12 @@ class LoginUtilsImpl |
// not happen while we are still fetching new OAuth refresh tokens. |
void AttemptRestart(Profile* profile); |
+ // Returns new CommandLine with per-user flags. |
+ CommandLine CreatePerSessionCommandLine(Profile* profile); |
+ |
+ // Returns true if restart is needed to apply per-session flags. |
+ bool NeedRestartToApplyPerSessionFlags(const CommandLine& user_flags); |
+ |
UserContext user_context_; |
// True if the authentication profile's cookie jar should contain |
@@ -311,25 +318,8 @@ void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoadedImpl( |
return; |
} |
- CommandLine user_flags(CommandLine::NO_PROGRAM); |
- about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); |
- about_flags::ConvertFlagsToSwitches(&flags_storage_, &user_flags, |
- about_flags::kAddSentinels); |
- // Only restart if needed and if not going into managed mode. |
- // Don't restart browser if it is not first profile in session. |
- if (UserManager::Get()->GetLoggedInUsers().size() == 1 && |
- !UserManager::Get()->IsLoggedInAsLocallyManagedUser() && |
- !about_flags::AreSwitchesIdenticalToCurrentCommandLine( |
- user_flags, *CommandLine::ForCurrentProcess())) { |
- CommandLine::StringVector flags; |
- // argv[0] is the program name |CommandLine::NO_PROGRAM|. |
- flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); |
- VLOG(1) << "Restarting to apply per-session flags..."; |
- DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( |
- UserManager::Get()->GetActiveUser()->email(), flags); |
- AttemptRestart(profile); |
+ if (RestartToApplyPerSessionFlagsIfNeed(profile)) |
return; |
- } |
if (login_host) { |
login_host->SetStatusAreaVisible(true); |
@@ -339,6 +329,7 @@ void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoadedImpl( |
BootTimesLoader::Get()->AddLoginTimeMarker("BrowserLaunched", false); |
VLOG(1) << "Launching browser..."; |
+ TRACE_EVENT0("login", "LaunchBrowser"); |
StartupBrowserCreator browser_creator; |
int return_code; |
chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
@@ -685,6 +676,21 @@ void LoginUtilsImpl::InitRlzDelayed(Profile* user_profile) { |
#endif |
} |
+bool LoginUtilsImpl::RestartToApplyPerSessionFlagsIfNeed(Profile* profile) { |
Nikita (slow)
2014/06/10 14:21:00
nit: Move this to unnamed namespace.
Alexander Alekseev
2014/06/10 22:05:13
It's called from profile_impl.cc .
I've moved it
Nikita (slow)
2014/06/11 12:42:51
Sorry, since this one is called from ProfileImpl y
Alexander Alekseev
2014/06/11 15:15:50
Done.
|
+ const CommandLine user_flags(CreatePerSessionCommandLine(profile)); |
+ if (!NeedRestartToApplyPerSessionFlags(user_flags)) |
+ return false; |
+ |
+ CommandLine::StringVector flags; |
+ // argv[0] is the program name |CommandLine::NO_PROGRAM|. |
+ flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); |
+ VLOG(1) << "Restarting to apply per-session flags..."; |
+ DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( |
+ UserManager::Get()->GetActiveUser()->email(), flags); |
+ AttemptRestart(profile); |
+ return true; |
+} |
+ |
void LoginUtilsImpl::InitRlz(Profile* user_profile, bool disabled) { |
#if defined(ENABLE_RLZ) |
PrefService* local_state = g_browser_process->local_state(); |
@@ -923,6 +929,32 @@ void LoginUtilsImpl::AttemptRestart(Profile* profile) { |
exit_after_session_restore_ = true; |
} |
+CommandLine LoginUtilsImpl::CreatePerSessionCommandLine(Profile* profile) { |
Nikita (slow)
2014/06/10 14:21:00
nit: Please move to unnamed namespace.
|
+ CommandLine user_flags(CommandLine::NO_PROGRAM); |
+ about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); |
+ about_flags::ConvertFlagsToSwitches( |
+ &flags_storage_, &user_flags, about_flags::kAddSentinels); |
+ return user_flags; |
+} |
+ |
+bool LoginUtilsImpl::NeedRestartToApplyPerSessionFlags( |
Nikita (slow)
2014/06/10 14:21:00
nit: Same here.
|
+ const CommandLine& user_flags) { |
+ // Don't restart browser if it is not first profile in session. |
+ if (UserManager::Get()->GetLoggedInUsers().size() != 1) |
+ return false; |
+ |
+ // Only restart if needed and if not going into managed mode. |
+ if (UserManager::Get()->IsLoggedInAsLocallyManagedUser()) |
+ return false; |
+ |
+ if (about_flags::AreSwitchesIdenticalToCurrentCommandLine( |
Nikita (slow)
2014/06/10 14:21:00
nit: rewrite this as
return !about_flags::AreSwi
|
+ user_flags, *CommandLine::ForCurrentProcess())) { |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
// static |
void LoginUtils::RegisterPrefs(PrefRegistrySimple* registry) { |
registry->RegisterBooleanPref(prefs::kFactoryResetRequested, false); |