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..81b53666f2e203d3886b6b2cd13ed091fc16bc24 100644 |
--- a/chrome/browser/chromeos/login/login_utils.cc |
+++ b/chrome/browser/chromeos/login/login_utils.cc |
@@ -105,6 +105,31 @@ base::FilePath GetRlzDisabledFlagPath() { |
} |
#endif |
+CommandLine CreatePerSessionCommandLine(Profile* profile) { |
+ 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 NeedRestartToApplyPerSessionFlags(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( |
+ user_flags, *CommandLine::ForCurrentProcess())) { |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
} // namespace |
struct DoBrowserLaunchOnLocaleLoadedData; |
@@ -155,6 +180,10 @@ class LoginUtilsImpl |
virtual void OnConnectionTypeChanged( |
net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
+ // Attempts restarting the browser process and esures that this does |
+ // not happen while we are still fetching new OAuth refresh tokens. |
+ void AttemptRestart(Profile* profile); |
+ |
private: |
typedef std::set<std::string> SessionRestoreStateSet; |
@@ -216,10 +245,6 @@ class LoginUtilsImpl |
// Initializes RLZ. If |disabled| is true, RLZ pings are disabled. |
void InitRlz(Profile* user_profile, bool disabled); |
- // Attempts restarting the browser process and esures that this does |
- // not happen while we are still fetching new OAuth refresh tokens. |
- void AttemptRestart(Profile* profile); |
- |
UserContext user_context_; |
// True if the authentication profile's cookie jar should contain |
@@ -311,25 +336,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 +347,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() ? |
@@ -959,4 +968,19 @@ bool LoginUtils::IsWhitelisted(const std::string& username, |
kAccountsPrefUsers, username, wildcard_match); |
} |
+bool RestartToApplyPerSessionFlagsIfNeed(Profile* profile) { |
+ 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); |
+ static_cast<LoginUtilsImpl*>(LoginUtilsImpl::Get())->AttemptRestart(profile); |
Alexander Alekseev
2014/06/10 22:05:13
Need a way to call LoginUtilsImpl method here.
Sta
|
+ return true; |
+} |
+ |
} // namespace chromeos |