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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 375413002: Replace chromeos::UserManager::Get() with chromeos::GetUserManager(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 CommandLine user_flags(CommandLine::NO_PROGRAM); 97 CommandLine user_flags(CommandLine::NO_PROGRAM);
98 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); 98 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs());
99 about_flags::ConvertFlagsToSwitches( 99 about_flags::ConvertFlagsToSwitches(
100 &flags_storage_, &user_flags, about_flags::kAddSentinels); 100 &flags_storage_, &user_flags, about_flags::kAddSentinels);
101 return user_flags; 101 return user_flags;
102 } 102 }
103 103
104 // Returns true if restart is needed to apply per-session flags. 104 // Returns true if restart is needed to apply per-session flags.
105 bool NeedRestartToApplyPerSessionFlags(const CommandLine& user_flags) { 105 bool NeedRestartToApplyPerSessionFlags(const CommandLine& user_flags) {
106 // Don't restart browser if it is not first profile in session. 106 // Don't restart browser if it is not first profile in session.
107 if (UserManager::Get()->GetLoggedInUsers().size() != 1) 107 if (GetUserManager()->GetLoggedInUsers().size() != 1)
108 return false; 108 return false;
109 109
110 // Only restart if needed and if not going into managed mode. 110 // Only restart if needed and if not going into managed mode.
111 if (UserManager::Get()->IsLoggedInAsLocallyManagedUser()) 111 if (GetUserManager()->IsLoggedInAsLocallyManagedUser())
112 return false; 112 return false;
113 113
114 if (about_flags::AreSwitchesIdenticalToCurrentCommandLine( 114 if (about_flags::AreSwitchesIdenticalToCurrentCommandLine(
115 user_flags, *CommandLine::ForCurrentProcess())) { 115 user_flags, *CommandLine::ForCurrentProcess())) {
116 return false; 116 return false;
117 } 117 }
118 118
119 return true; 119 return true;
120 } 120 }
121 121
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 context->login_utils_impl->DoBrowserLaunchOnLocaleLoadedImpl( 256 context->login_utils_impl->DoBrowserLaunchOnLocaleLoadedImpl(
257 context->profile, context->display_host); 257 context->profile, context->display_host);
258 } 258 }
259 259
260 // Called from DoBrowserLaunch() or from 260 // Called from DoBrowserLaunch() or from
261 // DoBrowserLaunchOnLocaleLoaded() depending on 261 // DoBrowserLaunchOnLocaleLoaded() depending on
262 // if locale switch was needed. 262 // if locale switch was needed.
263 void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoadedImpl( 263 void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoadedImpl(
264 Profile* profile, 264 Profile* profile,
265 LoginDisplayHost* login_host) { 265 LoginDisplayHost* login_host) {
266 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) { 266 if (!GetUserManager()->GetCurrentUserFlow()->ShouldLaunchBrowser()) {
267 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile); 267 GetUserManager()->GetCurrentUserFlow()->LaunchExtraSteps(profile);
268 return; 268 return;
269 } 269 }
270 270
271 if (RestartToApplyPerSessionFlagsIfNeed(profile, false)) 271 if (RestartToApplyPerSessionFlagsIfNeed(profile, false))
272 return; 272 return;
273 273
274 if (login_host) { 274 if (login_host) {
275 login_host->SetStatusAreaVisible(true); 275 login_host->SetStatusAreaVisible(true);
276 login_host->BeforeSessionStart(); 276 login_host->BeforeSessionStart();
277 } 277 }
(...skipping 15 matching lines...) Expand all
293 &return_code); 293 &return_code);
294 294
295 // Triggers app launcher start page service to load start page web contents. 295 // Triggers app launcher start page service to load start page web contents.
296 app_list::StartPageService::Get(profile); 296 app_list::StartPageService::Get(profile);
297 297
298 // Mark login host for deletion after browser starts. This 298 // Mark login host for deletion after browser starts. This
299 // guarantees that the message loop will be referenced by the 299 // guarantees that the message loop will be referenced by the
300 // browser before it is dereferenced by the login host. 300 // browser before it is dereferenced by the login host.
301 if (login_host) 301 if (login_host)
302 login_host->Finalize(); 302 login_host->Finalize();
303 UserManager::Get()->SessionStarted(); 303 GetUserManager()->SessionStarted();
304 chromeos::BootTimesLoader::Get()->LoginDone( 304 chromeos::BootTimesLoader::Get()->LoginDone(
305 chromeos::UserManager::Get()->IsCurrentUserNew()); 305 chromeos::GetUserManager()->IsCurrentUserNew());
306 } 306 }
307 307
308 void LoginUtilsImpl::DoBrowserLaunch(Profile* profile, 308 void LoginUtilsImpl::DoBrowserLaunch(Profile* profile,
309 LoginDisplayHost* login_host) { 309 LoginDisplayHost* login_host) {
310 if (browser_shutdown::IsTryingToQuit()) 310 if (browser_shutdown::IsTryingToQuit())
311 return; 311 return;
312 312
313 User* const user = ProfileHelper::Get()->GetUserByProfile(profile); 313 User* const user = ProfileHelper::Get()->GetUserByProfile(profile);
314 scoped_ptr<DoBrowserLaunchOnLocaleLoadedData> data( 314 scoped_ptr<DoBrowserLaunchOnLocaleLoadedData> data(
315 new DoBrowserLaunchOnLocaleLoadedData(this, profile, login_host)); 315 new DoBrowserLaunchOnLocaleLoadedData(this, profile, login_host));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 const CommandLine user_flags(CreatePerSessionCommandLine(profile)); 360 const CommandLine user_flags(CreatePerSessionCommandLine(profile));
361 if (!NeedRestartToApplyPerSessionFlags(user_flags)) 361 if (!NeedRestartToApplyPerSessionFlags(user_flags))
362 return false; 362 return false;
363 363
364 CommandLine::StringVector flags; 364 CommandLine::StringVector flags;
365 // argv[0] is the program name |CommandLine::NO_PROGRAM|. 365 // argv[0] is the program name |CommandLine::NO_PROGRAM|.
366 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); 366 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end());
367 VLOG(1) << "Restarting to apply per-session flags..."; 367 VLOG(1) << "Restarting to apply per-session flags...";
368 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( 368 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser(
369 UserManager::Get()->GetActiveUser()->email(), flags); 369 GetUserManager()->GetActiveUser()->email(), flags);
370 AttemptRestart(profile); 370 AttemptRestart(profile);
371 return true; 371 return true;
372 } 372 }
373 373
374 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { 374 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
375 VLOG(1) << "Completing incognito login"; 375 VLOG(1) << "Completing incognito login";
376 376
377 // For guest session we ask session manager to restart Chrome with --bwsi 377 // For guest session we ask session manager to restart Chrome with --bwsi
378 // flag. We keep only some of the arguments of this process. 378 // flag. We keep only some of the arguments of this process.
379 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 379 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 CrosSettings* cros_settings = CrosSettings::Get(); 462 CrosSettings* cros_settings = CrosSettings::Get();
463 bool allow_new_user = false; 463 bool allow_new_user = false;
464 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 464 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
465 if (allow_new_user) 465 if (allow_new_user)
466 return true; 466 return true;
467 return cros_settings->FindEmailInList( 467 return cros_settings->FindEmailInList(
468 kAccountsPrefUsers, username, wildcard_match); 468 kAccountsPrefUsers, username, wildcard_match);
469 } 469 }
470 470
471 } // namespace chromeos 471 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698