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

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

Issue 444903002: [cros] user_manager component - move UserManagerBase and UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 43 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
44 #include "chrome/browser/chromeos/login/profile_auth_data.h" 44 #include "chrome/browser/chromeos/login/profile_auth_data.h"
45 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" 45 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h"
46 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h" 46 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h"
47 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 47 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
48 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" 48 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h"
49 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" 49 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h"
50 #include "chrome/browser/chromeos/login/startup_utils.h" 50 #include "chrome/browser/chromeos/login/startup_utils.h"
51 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h" 51 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h"
52 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 52 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
53 #include "chrome/browser/chromeos/login/user_flow.h"
54 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
53 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 55 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
54 #include "chrome/browser/chromeos/login/users/user_manager.h"
55 #include "chrome/browser/chromeos/profiles/profile_helper.h" 56 #include "chrome/browser/chromeos/profiles/profile_helper.h"
56 #include "chrome/browser/chromeos/settings/cros_settings.h" 57 #include "chrome/browser/chromeos/settings/cros_settings.h"
57 #include "chrome/browser/extensions/extension_service.h" 58 #include "chrome/browser/extensions/extension_service.h"
58 #include "chrome/browser/first_run/first_run.h" 59 #include "chrome/browser/first_run/first_run.h"
59 #include "chrome/browser/google/google_brand_chromeos.h" 60 #include "chrome/browser/google/google_brand_chromeos.h"
60 #include "chrome/browser/lifetime/application_lifetime.h" 61 #include "chrome/browser/lifetime/application_lifetime.h"
61 #include "chrome/browser/pref_service_flags_storage.h" 62 #include "chrome/browser/pref_service_flags_storage.h"
62 #include "chrome/browser/profiles/profile.h" 63 #include "chrome/browser/profiles/profile.h"
63 #include "chrome/browser/profiles/profile_manager.h" 64 #include "chrome/browser/profiles/profile_manager.h"
64 #include "chrome/browser/rlz/rlz.h" 65 #include "chrome/browser/rlz/rlz.h"
65 #include "chrome/browser/signin/signin_manager_factory.h" 66 #include "chrome/browser/signin/signin_manager_factory.h"
66 #include "chrome/browser/sync/profile_sync_service.h" 67 #include "chrome/browser/sync/profile_sync_service.h"
67 #include "chrome/browser/sync/profile_sync_service_factory.h" 68 #include "chrome/browser/sync/profile_sync_service_factory.h"
68 #include "chrome/browser/ui/app_list/start_page_service.h" 69 #include "chrome/browser/ui/app_list/start_page_service.h"
69 #include "chrome/browser/ui/startup/startup_browser_creator.h" 70 #include "chrome/browser/ui/startup/startup_browser_creator.h"
70 #include "chrome/common/chrome_switches.h" 71 #include "chrome/common/chrome_switches.h"
71 #include "chrome/common/logging_chrome.h" 72 #include "chrome/common/logging_chrome.h"
72 #include "chrome/common/pref_names.h" 73 #include "chrome/common/pref_names.h"
73 #include "chromeos/chromeos_switches.h" 74 #include "chromeos/chromeos_switches.h"
74 #include "chromeos/cryptohome/cryptohome_util.h" 75 #include "chromeos/cryptohome/cryptohome_util.h"
75 #include "chromeos/dbus/cryptohome_client.h" 76 #include "chromeos/dbus/cryptohome_client.h"
76 #include "chromeos/dbus/dbus_method_call_status.h" 77 #include "chromeos/dbus/dbus_method_call_status.h"
77 #include "chromeos/dbus/dbus_thread_manager.h" 78 #include "chromeos/dbus/dbus_thread_manager.h"
78 #include "chromeos/dbus/session_manager_client.h" 79 #include "chromeos/dbus/session_manager_client.h"
79 #include "chromeos/login/auth/user_context.h" 80 #include "chromeos/login/auth/user_context.h"
80 #include "chromeos/settings/cros_settings_names.h" 81 #include "chromeos/settings/cros_settings_names.h"
81 #include "components/signin/core/browser/signin_manager.h" 82 #include "components/signin/core/browser/signin_manager.h"
82 #include "components/user_manager/user.h" 83 #include "components/user_manager/user.h"
84 #include "components/user_manager/user_manager.h"
83 #include "content/public/browser/browser_thread.h" 85 #include "content/public/browser/browser_thread.h"
84 #include "content/public/browser/notification_service.h" 86 #include "content/public/browser/notification_service.h"
85 #include "google_apis/gaia/gaia_auth_consumer.h" 87 #include "google_apis/gaia/gaia_auth_consumer.h"
86 #include "net/base/network_change_notifier.h" 88 #include "net/base/network_change_notifier.h"
87 #include "net/url_request/url_request_context.h" 89 #include "net/url_request/url_request_context.h"
88 #include "net/url_request/url_request_context_getter.h" 90 #include "net/url_request/url_request_context_getter.h"
89 #include "url/gurl.h" 91 #include "url/gurl.h"
90 92
91 using content::BrowserThread; 93 using content::BrowserThread;
92 94
93 namespace chromeos { 95 namespace chromeos {
94 96
95 namespace { 97 namespace {
96 98
97 // Returns new CommandLine with per-user flags. 99 // Returns new CommandLine with per-user flags.
98 CommandLine CreatePerSessionCommandLine(Profile* profile) { 100 CommandLine CreatePerSessionCommandLine(Profile* profile) {
99 CommandLine user_flags(CommandLine::NO_PROGRAM); 101 CommandLine user_flags(CommandLine::NO_PROGRAM);
100 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); 102 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs());
101 about_flags::ConvertFlagsToSwitches( 103 about_flags::ConvertFlagsToSwitches(
102 &flags_storage_, &user_flags, about_flags::kAddSentinels); 104 &flags_storage_, &user_flags, about_flags::kAddSentinels);
103 return user_flags; 105 return user_flags;
104 } 106 }
105 107
106 // Returns true if restart is needed to apply per-session flags. 108 // Returns true if restart is needed to apply per-session flags.
107 bool NeedRestartToApplyPerSessionFlags(const CommandLine& user_flags) { 109 bool NeedRestartToApplyPerSessionFlags(const CommandLine& user_flags) {
108 // Don't restart browser if it is not first profile in session. 110 // Don't restart browser if it is not first profile in session.
109 if (UserManager::Get()->GetLoggedInUsers().size() != 1) 111 if (user_manager::UserManager::Get()->GetLoggedInUsers().size() != 1)
110 return false; 112 return false;
111 113
112 // Only restart if needed and if not going into managed mode. 114 // Only restart if needed and if not going into managed mode.
113 if (UserManager::Get()->IsLoggedInAsSupervisedUser()) 115 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser())
114 return false; 116 return false;
115 117
116 if (about_flags::AreSwitchesIdenticalToCurrentCommandLine( 118 if (about_flags::AreSwitchesIdenticalToCurrentCommandLine(
117 user_flags, *CommandLine::ForCurrentProcess())) { 119 user_flags, *CommandLine::ForCurrentProcess())) {
118 return false; 120 return false;
119 } 121 }
120 122
121 return true; 123 return true;
122 } 124 }
123 125
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (!locale_pref_checked) { 242 if (!locale_pref_checked) {
241 RespectLocalePreference(profile, 243 RespectLocalePreference(profile,
242 base::Bind(&LoginUtilsImpl::DoBrowserLaunchInternal, 244 base::Bind(&LoginUtilsImpl::DoBrowserLaunchInternal,
243 base::Unretained(this), 245 base::Unretained(this),
244 profile, 246 profile,
245 login_host, 247 login_host,
246 true /* locale_pref_checked */)); 248 true /* locale_pref_checked */));
247 return; 249 return;
248 } 250 }
249 251
250 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) { 252 if (!ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) {
251 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile); 253 ChromeUserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile);
252 return; 254 return;
253 } 255 }
254 256
255 if (RestartToApplyPerSessionFlagsIfNeed(profile, false)) 257 if (RestartToApplyPerSessionFlagsIfNeed(profile, false))
256 return; 258 return;
257 259
258 if (login_host) { 260 if (login_host) {
259 login_host->SetStatusAreaVisible(true); 261 login_host->SetStatusAreaVisible(true);
260 login_host->BeforeSessionStart(); 262 login_host->BeforeSessionStart();
261 } 263 }
(...skipping 15 matching lines...) Expand all
277 &return_code); 279 &return_code);
278 280
279 // Triggers app launcher start page service to load start page web contents. 281 // Triggers app launcher start page service to load start page web contents.
280 app_list::StartPageService::Get(profile); 282 app_list::StartPageService::Get(profile);
281 283
282 // Mark login host for deletion after browser starts. This 284 // Mark login host for deletion after browser starts. This
283 // guarantees that the message loop will be referenced by the 285 // guarantees that the message loop will be referenced by the
284 // browser before it is dereferenced by the login host. 286 // browser before it is dereferenced by the login host.
285 if (login_host) 287 if (login_host)
286 login_host->Finalize(); 288 login_host->Finalize();
287 UserManager::Get()->SessionStarted(); 289 user_manager::UserManager::Get()->SessionStarted();
288 chromeos::BootTimesLoader::Get()->LoginDone( 290 chromeos::BootTimesLoader::Get()->LoginDone(
289 chromeos::UserManager::Get()->IsCurrentUserNew()); 291 user_manager::UserManager::Get()->IsCurrentUserNew());
290 } 292 }
291 293
292 // static 294 // static
293 void LoginUtilsImpl::RunCallbackOnLocaleLoaded( 295 void LoginUtilsImpl::RunCallbackOnLocaleLoaded(
294 const base::Closure& callback, 296 const base::Closure& callback,
295 InputEventsBlocker* /* input_events_blocker */, 297 InputEventsBlocker* /* input_events_blocker */,
296 const std::string& /* locale */, 298 const std::string& /* locale */,
297 const std::string& /* loaded_locale */, 299 const std::string& /* loaded_locale */,
298 const bool /* success */) { 300 const bool /* success */) {
299 callback.Run(); 301 callback.Run();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 360
359 const CommandLine user_flags(CreatePerSessionCommandLine(profile)); 361 const CommandLine user_flags(CreatePerSessionCommandLine(profile));
360 if (!NeedRestartToApplyPerSessionFlags(user_flags)) 362 if (!NeedRestartToApplyPerSessionFlags(user_flags))
361 return false; 363 return false;
362 364
363 CommandLine::StringVector flags; 365 CommandLine::StringVector flags;
364 // argv[0] is the program name |CommandLine::NO_PROGRAM|. 366 // argv[0] is the program name |CommandLine::NO_PROGRAM|.
365 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); 367 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end());
366 VLOG(1) << "Restarting to apply per-session flags..."; 368 VLOG(1) << "Restarting to apply per-session flags...";
367 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( 369 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser(
368 UserManager::Get()->GetActiveUser()->email(), flags); 370 user_manager::UserManager::Get()->GetActiveUser()->email(), flags);
369 AttemptRestart(profile); 371 AttemptRestart(profile);
370 return true; 372 return true;
371 } 373 }
372 374
373 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { 375 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
374 VLOG(1) << "Completing incognito login"; 376 VLOG(1) << "Completing incognito login";
375 377
376 // For guest session we ask session manager to restart Chrome with --bwsi 378 // For guest session we ask session manager to restart Chrome with --bwsi
377 // flag. We keep only some of the arguments of this process. 379 // flag. We keep only some of the arguments of this process.
378 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 380 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 CrosSettings* cros_settings = CrosSettings::Get(); 463 CrosSettings* cros_settings = CrosSettings::Get();
462 bool allow_new_user = false; 464 bool allow_new_user = false;
463 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 465 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
464 if (allow_new_user) 466 if (allow_new_user)
465 return true; 467 return true;
466 return cros_settings->FindEmailInList( 468 return cros_settings->FindEmailInList(
467 kAccountsPrefUsers, username, wildcard_match); 469 kAccountsPrefUsers, username, wildcard_match);
468 } 470 }
469 471
470 } // namespace chromeos 472 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698