OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
25 #include "chrome/browser/chromeos/base/locale_util.h" | 25 #include "chrome/browser/chromeos/base/locale_util.h" |
26 #include "chrome/browser/chromeos/boot_times_loader.h" | 26 #include "chrome/browser/chromeos/boot_times_loader.h" |
27 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 27 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
28 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" | 28 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" |
29 #include "chrome/browser/chromeos/login/profile_auth_data.h" | 29 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
30 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" | 30 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" |
31 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory
.h" | 31 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory
.h" |
32 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" | 32 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
33 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 33 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
| 34 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
34 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 35 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
35 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
36 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" | 36 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" |
37 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 37 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
38 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 38 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
39 #include "chrome/browser/chromeos/settings/cros_settings.h" | 39 #include "chrome/browser/chromeos/settings/cros_settings.h" |
40 #include "chrome/browser/component_updater/component_updater_service.h" | 40 #include "chrome/browser/component_updater/component_updater_service.h" |
41 #include "chrome/browser/first_run/first_run.h" | 41 #include "chrome/browser/first_run/first_run.h" |
42 #include "chrome/browser/google/google_brand_chromeos.h" | 42 #include "chrome/browser/google/google_brand_chromeos.h" |
43 #include "chrome/browser/lifetime/application_lifetime.h" | 43 #include "chrome/browser/lifetime/application_lifetime.h" |
44 #include "chrome/browser/net/crl_set_fetcher.h" | 44 #include "chrome/browser/net/crl_set_fetcher.h" |
45 #include "chrome/browser/net/nss_context.h" | 45 #include "chrome/browser/net/nss_context.h" |
(...skipping 11 matching lines...) Expand all Loading... |
57 #include "chromeos/dbus/dbus_thread_manager.h" | 57 #include "chromeos/dbus/dbus_thread_manager.h" |
58 #include "chromeos/dbus/session_manager_client.h" | 58 #include "chromeos/dbus/session_manager_client.h" |
59 #include "chromeos/ime/input_method_manager.h" | 59 #include "chromeos/ime/input_method_manager.h" |
60 #include "chromeos/network/portal_detector/network_portal_detector.h" | 60 #include "chromeos/network/portal_detector/network_portal_detector.h" |
61 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" | 61 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" |
62 #include "chromeos/settings/cros_settings_names.h" | 62 #include "chromeos/settings/cros_settings_names.h" |
63 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 63 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
64 #include "components/session_manager/core/session_manager.h" | 64 #include "components/session_manager/core/session_manager.h" |
65 #include "components/signin/core/browser/signin_manager_base.h" | 65 #include "components/signin/core/browser/signin_manager_base.h" |
66 #include "components/user_manager/user.h" | 66 #include "components/user_manager/user.h" |
| 67 #include "components/user_manager/user_manager.h" |
67 #include "components/user_manager/user_type.h" | 68 #include "components/user_manager/user_type.h" |
68 #include "content/public/browser/browser_thread.h" | 69 #include "content/public/browser/browser_thread.h" |
69 #include "content/public/browser/notification_service.h" | 70 #include "content/public/browser/notification_service.h" |
70 | 71 |
71 namespace chromeos { | 72 namespace chromeos { |
72 | 73 |
73 namespace { | 74 namespace { |
74 | 75 |
75 void InitLocaleAndInputMethodsForNewUser( | 76 void InitLocaleAndInputMethodsForNewUser( |
76 PrefService* prefs, | 77 PrefService* prefs, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 UserSessionManager* UserSessionManager::GetInstance() { | 184 UserSessionManager* UserSessionManager::GetInstance() { |
184 return Singleton<UserSessionManager, | 185 return Singleton<UserSessionManager, |
185 DefaultSingletonTraits<UserSessionManager> >::get(); | 186 DefaultSingletonTraits<UserSessionManager> >::get(); |
186 } | 187 } |
187 | 188 |
188 // static | 189 // static |
189 void UserSessionManager::OverrideHomedir() { | 190 void UserSessionManager::OverrideHomedir() { |
190 // Override user homedir, check for ProfileManager being initialized as | 191 // Override user homedir, check for ProfileManager being initialized as |
191 // it may not exist in unit tests. | 192 // it may not exist in unit tests. |
192 if (g_browser_process->profile_manager()) { | 193 if (g_browser_process->profile_manager()) { |
193 UserManager* user_manager = UserManager::Get(); | 194 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
194 if (user_manager->GetLoggedInUsers().size() == 1) { | 195 if (user_manager->GetLoggedInUsers().size() == 1) { |
195 base::FilePath homedir = ProfileHelper::GetProfilePathByUserIdHash( | 196 base::FilePath homedir = ProfileHelper::GetProfilePathByUserIdHash( |
196 user_manager->GetPrimaryUser()->username_hash()); | 197 user_manager->GetPrimaryUser()->username_hash()); |
197 // This path has been either created by cryptohome (on real Chrome OS | 198 // This path has been either created by cryptohome (on real Chrome OS |
198 // device) or by ProfileManager (on chromeos=1 desktop builds). | 199 // device) or by ProfileManager (on chromeos=1 desktop builds). |
199 PathService::OverrideAndCreateIfNeeded(base::DIR_HOME, | 200 PathService::OverrideAndCreateIfNeeded(base::DIR_HOME, |
200 homedir, | 201 homedir, |
201 true /* path is absolute */, | 202 true /* path is absolute */, |
202 false /* don't create */); | 203 false /* don't create */); |
203 } | 204 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 if (!has_active_session) | 242 if (!has_active_session) |
242 StartCrosSession(); | 243 StartCrosSession(); |
243 | 244 |
244 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually | 245 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually |
245 // ready to be used (http://crbug.com/361528). | 246 // ready to be used (http://crbug.com/361528). |
246 NotifyUserLoggedIn(); | 247 NotifyUserLoggedIn(); |
247 PrepareProfile(); | 248 PrepareProfile(); |
248 } | 249 } |
249 | 250 |
250 void UserSessionManager::PerformPostUserLoggedInActions() { | 251 void UserSessionManager::PerformPostUserLoggedInActions() { |
251 UserManager* user_manager = UserManager::Get(); | 252 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
252 if (user_manager->GetLoggedInUsers().size() == 1) { | 253 if (user_manager->GetLoggedInUsers().size() == 1) { |
253 // Owner must be first user in session. DeviceSettingsService can't deal | 254 // Owner must be first user in session. DeviceSettingsService can't deal |
254 // with multiple user and will mix up ownership, crbug.com/230018. | 255 // with multiple user and will mix up ownership, crbug.com/230018. |
255 OwnerSettingsServiceFactory::GetInstance()-> | 256 OwnerSettingsServiceFactory::GetInstance()-> |
256 SetUsername(user_manager->GetActiveUser()->email()); | 257 SetUsername(user_manager->GetActiveUser()->email()); |
257 | 258 |
258 if (NetworkPortalDetector::IsInitialized()) { | 259 if (NetworkPortalDetector::IsInitialized()) { |
259 NetworkPortalDetector::Get()->SetStrategy( | 260 NetworkPortalDetector::Get()->SetStrategy( |
260 PortalDetectorStrategy::STRATEGY_ID_SESSION); | 261 PortalDetectorStrategy::STRATEGY_ID_SESSION); |
261 } | 262 } |
262 } | 263 } |
263 } | 264 } |
264 | 265 |
265 void UserSessionManager::RestoreAuthenticationSession(Profile* user_profile) { | 266 void UserSessionManager::RestoreAuthenticationSession(Profile* user_profile) { |
266 UserManager* user_manager = UserManager::Get(); | 267 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
267 // We need to restore session only for logged in regular (GAIA) users. | 268 // We need to restore session only for logged in regular (GAIA) users. |
268 // Note: stub user is a special case that is used for tests, running | 269 // Note: stub user is a special case that is used for tests, running |
269 // linux_chromeos build on dev workstations w/o user_id parameters. | 270 // linux_chromeos build on dev workstations w/o user_id parameters. |
270 // Stub user is considered to be a regular GAIA user but it has special | 271 // Stub user is considered to be a regular GAIA user but it has special |
271 // user_id (kStubUser) and certain services like restoring OAuth session are | 272 // user_id (kStubUser) and certain services like restoring OAuth session are |
272 // explicitly disabled for it. | 273 // explicitly disabled for it. |
273 if (!user_manager->IsUserLoggedIn() || | 274 if (!user_manager->IsUserLoggedIn() || |
274 !user_manager->IsLoggedInAsRegularUser() || | 275 !user_manager->IsLoggedInAsRegularUser() || |
275 user_manager->IsLoggedInAsStub()) { | 276 user_manager->IsLoggedInAsStub()) { |
276 return; | 277 return; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 360 |
360 bool UserSessionManager::RespectLocalePreference( | 361 bool UserSessionManager::RespectLocalePreference( |
361 Profile* profile, | 362 Profile* profile, |
362 const user_manager::User* user, | 363 const user_manager::User* user, |
363 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const { | 364 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const { |
364 // TODO(alemate): http://crbug.com/288941 : Respect preferred language list in | 365 // TODO(alemate): http://crbug.com/288941 : Respect preferred language list in |
365 // the Google user profile. | 366 // the Google user profile. |
366 if (g_browser_process == NULL) | 367 if (g_browser_process == NULL) |
367 return false; | 368 return false; |
368 | 369 |
369 UserManager* user_manager = UserManager::Get(); | 370 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
370 if (!user || (user_manager->IsUserLoggedIn() && | 371 if (!user || (user_manager->IsUserLoggedIn() && |
371 user != user_manager->GetPrimaryUser())) { | 372 user != user_manager->GetPrimaryUser())) { |
372 return false; | 373 return false; |
373 } | 374 } |
374 | 375 |
375 // In case of multi-profiles session we don't apply profile locale | 376 // In case of multi-profiles session we don't apply profile locale |
376 // because it is unsafe. | 377 // because it is unsafe. |
377 if (user_manager->GetLoggedInUsers().size() != 1) | 378 if (user_manager->GetLoggedInUsers().size() != 1) |
378 return false; | 379 return false; |
379 | 380 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 420 |
420 // Here we don't enable keyboard layouts for normal users. Input methods | 421 // Here we don't enable keyboard layouts for normal users. Input methods |
421 // are set up when the user first logs in. Then the user may customize the | 422 // are set up when the user first logs in. Then the user may customize the |
422 // input methods. Hence changing input methods here, just because the user's | 423 // input methods. Hence changing input methods here, just because the user's |
423 // UI language is different from the login screen UI language, is not | 424 // UI language is different from the login screen UI language, is not |
424 // desirable. Note that input method preferences are synced, so users can use | 425 // desirable. Note that input method preferences are synced, so users can use |
425 // their farovite input methods as soon as the preferences are synced. | 426 // their farovite input methods as soon as the preferences are synced. |
426 // | 427 // |
427 // For Guest mode, user locale preferences will never get initialized. | 428 // For Guest mode, user locale preferences will never get initialized. |
428 // So input methods should be enabled somewhere. | 429 // So input methods should be enabled somewhere. |
429 const bool enable_layouts = UserManager::Get()->IsLoggedInAsGuest(); | 430 const bool enable_layouts = |
| 431 user_manager::UserManager::Get()->IsLoggedInAsGuest(); |
430 locale_util::SwitchLanguage(pref_locale, | 432 locale_util::SwitchLanguage(pref_locale, |
431 enable_layouts, | 433 enable_layouts, |
432 false /* login_layouts_only */, | 434 false /* login_layouts_only */, |
433 callback.Pass()); | 435 callback.Pass()); |
434 | 436 |
435 return true; | 437 return true; |
436 } | 438 } |
437 | 439 |
438 void UserSessionManager::AddSessionStateObserver( | 440 void UserSessionManager::AddSessionStateObserver( |
439 UserSessionStateObserver* observer) { | 441 UserSessionStateObserver* observer) { |
(...skipping 29 matching lines...) Expand all Loading... |
469 case OAuth2LoginManager::SESSION_RESTORE_NOT_STARTED: | 471 case OAuth2LoginManager::SESSION_RESTORE_NOT_STARTED: |
470 case OAuth2LoginManager::SESSION_RESTORE_PREPARING: | 472 case OAuth2LoginManager::SESSION_RESTORE_PREPARING: |
471 case OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: | 473 case OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: |
472 return; | 474 return; |
473 } | 475 } |
474 | 476 |
475 // We should not be clearing existing token state if that was a connection | 477 // We should not be clearing existing token state if that was a connection |
476 // error. http://crbug.com/295245 | 478 // error. http://crbug.com/295245 |
477 if (!connection_error) { | 479 if (!connection_error) { |
478 // We are in one of "done" states here. | 480 // We are in one of "done" states here. |
479 UserManager::Get()->SaveUserOAuthStatus( | 481 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
480 UserManager::Get()->GetLoggedInUser()->email(), | 482 user_manager::UserManager::Get()->GetLoggedInUser()->email(), |
481 user_status); | 483 user_status); |
482 } | 484 } |
483 | 485 |
484 login_manager->RemoveObserver(this); | 486 login_manager->RemoveObserver(this); |
485 } | 487 } |
486 | 488 |
487 void UserSessionManager::OnNewRefreshTokenAvaiable(Profile* user_profile) { | 489 void UserSessionManager::OnNewRefreshTokenAvaiable(Profile* user_profile) { |
488 // Check if we were waiting to restart chrome. | 490 // Check if we were waiting to restart chrome. |
489 if (!exit_after_session_restore_) | 491 if (!exit_after_session_restore_) |
490 return; | 492 return; |
491 | 493 |
492 OAuth2LoginManager* login_manager = | 494 OAuth2LoginManager* login_manager = |
493 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); | 495 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); |
494 login_manager->RemoveObserver(this); | 496 login_manager->RemoveObserver(this); |
495 | 497 |
496 // Mark user auth token status as valid. | 498 // Mark user auth token status as valid. |
497 UserManager::Get()->SaveUserOAuthStatus( | 499 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
498 UserManager::Get()->GetLoggedInUser()->email(), | 500 user_manager::UserManager::Get()->GetLoggedInUser()->email(), |
499 user_manager::User::OAUTH2_TOKEN_STATUS_VALID); | 501 user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
500 | 502 |
501 VLOG(1) << "Exiting after new refresh token fetched"; | 503 VLOG(1) << "Exiting after new refresh token fetched"; |
502 | 504 |
503 // We need to restart cleanly in this case to make sure OAuth2 RT is actually | 505 // We need to restart cleanly in this case to make sure OAuth2 RT is actually |
504 // saved. | 506 // saved. |
505 chrome::AttemptRestart(); | 507 chrome::AttemptRestart(); |
506 } | 508 } |
507 | 509 |
508 void UserSessionManager::OnConnectionTypeChanged( | 510 void UserSessionManager::OnConnectionTypeChanged( |
509 net::NetworkChangeNotifier::ConnectionType type) { | 511 net::NetworkChangeNotifier::ConnectionType type) { |
510 bool is_running_test = | 512 bool is_running_test = |
511 base::CommandLine::ForCurrentProcess()->HasSwitch( | 513 base::CommandLine::ForCurrentProcess()->HasSwitch( |
512 ::switches::kTestName) || | 514 ::switches::kTestName) || |
513 base::CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType); | 515 base::CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType); |
514 UserManager* user_manager = UserManager::Get(); | 516 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
515 if (type == net::NetworkChangeNotifier::CONNECTION_NONE || | 517 if (type == net::NetworkChangeNotifier::CONNECTION_NONE || |
516 !user_manager->IsUserLoggedIn() || | 518 !user_manager->IsUserLoggedIn() || |
517 !user_manager->IsLoggedInAsRegularUser() || | 519 !user_manager->IsLoggedInAsRegularUser() || |
518 user_manager->IsLoggedInAsStub() || is_running_test) { | 520 user_manager->IsLoggedInAsStub() || is_running_test) { |
519 return; | 521 return; |
520 } | 522 } |
521 | 523 |
522 // Need to iterate over all users and their OAuth2 session state. | 524 // Need to iterate over all users and their OAuth2 session state. |
523 const user_manager::UserList& users = user_manager->GetLoggedInUsers(); | 525 const user_manager::UserList& users = user_manager->GetLoggedInUsers(); |
524 for (user_manager::UserList::const_iterator it = users.begin(); | 526 for (user_manager::UserList::const_iterator it = users.begin(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 BootTimesLoader* btl = BootTimesLoader::Get(); | 580 BootTimesLoader* btl = BootTimesLoader::Get(); |
579 btl->AddLoginTimeMarker("StartSession-Start", false); | 581 btl->AddLoginTimeMarker("StartSession-Start", false); |
580 DBusThreadManager::Get()->GetSessionManagerClient()-> | 582 DBusThreadManager::Get()->GetSessionManagerClient()-> |
581 StartSession(user_context_.GetUserID()); | 583 StartSession(user_context_.GetUserID()); |
582 btl->AddLoginTimeMarker("StartSession-End", false); | 584 btl->AddLoginTimeMarker("StartSession-End", false); |
583 } | 585 } |
584 | 586 |
585 void UserSessionManager::NotifyUserLoggedIn() { | 587 void UserSessionManager::NotifyUserLoggedIn() { |
586 BootTimesLoader* btl = BootTimesLoader::Get(); | 588 BootTimesLoader* btl = BootTimesLoader::Get(); |
587 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); | 589 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); |
588 UserManager* user_manager = UserManager::Get(); | 590 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
589 user_manager->UserLoggedIn(user_context_.GetUserID(), | 591 user_manager->UserLoggedIn(user_context_.GetUserID(), |
590 user_context_.GetUserIDHash(), | 592 user_context_.GetUserIDHash(), |
591 false); | 593 false); |
592 btl->AddLoginTimeMarker("UserLoggedIn-End", false); | 594 btl->AddLoginTimeMarker("UserLoggedIn-End", false); |
593 } | 595 } |
594 | 596 |
595 void UserSessionManager::PrepareProfile() { | 597 void UserSessionManager::PrepareProfile() { |
596 bool is_demo_session = | 598 bool is_demo_session = |
597 DemoAppLauncher::IsDemoAppSession(user_context_.GetUserID()); | 599 DemoAppLauncher::IsDemoAppSession(user_context_.GetUserID()); |
598 | 600 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 case Profile::CREATE_STATUS_CANCELED: | 635 case Profile::CREATE_STATUS_CANCELED: |
634 case Profile::MAX_CREATE_STATUS: | 636 case Profile::MAX_CREATE_STATUS: |
635 NOTREACHED(); | 637 NOTREACHED(); |
636 break; | 638 break; |
637 } | 639 } |
638 } | 640 } |
639 | 641 |
640 void UserSessionManager::InitProfilePreferences( | 642 void UserSessionManager::InitProfilePreferences( |
641 Profile* profile, | 643 Profile* profile, |
642 const UserContext& user_context) { | 644 const UserContext& user_context) { |
643 if (UserManager::Get()->IsCurrentUserNew()) { | 645 if (user_manager::UserManager::Get()->IsCurrentUserNew()) { |
644 SetFirstLoginPrefs(profile->GetPrefs(), | 646 SetFirstLoginPrefs(profile->GetPrefs(), |
645 user_context.GetPublicSessionLocale(), | 647 user_context.GetPublicSessionLocale(), |
646 user_context.GetPublicSessionInputMethod()); | 648 user_context.GetPublicSessionInputMethod()); |
647 } | 649 } |
648 | 650 |
649 if (UserManager::Get()->IsLoggedInAsSupervisedUser()) { | 651 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { |
650 user_manager::User* active_user = UserManager::Get()->GetActiveUser(); | 652 user_manager::User* active_user = |
| 653 user_manager::UserManager::Get()->GetActiveUser(); |
651 std::string supervised_user_sync_id = | 654 std::string supervised_user_sync_id = |
652 UserManager::Get()->GetSupervisedUserManager()-> | 655 ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( |
653 GetUserSyncId(active_user->email()); | 656 active_user->email()); |
654 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, | 657 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, |
655 supervised_user_sync_id); | 658 supervised_user_sync_id); |
656 } else if (UserManager::Get()->IsLoggedInAsRegularUser()) { | 659 } else if (user_manager::UserManager::Get()->IsLoggedInAsRegularUser()) { |
657 // Make sure that the google service username is properly set (we do this | 660 // Make sure that the google service username is properly set (we do this |
658 // on every sign in, not just the first login, to deal with existing | 661 // on every sign in, not just the first login, to deal with existing |
659 // profiles that might not have it set yet). | 662 // profiles that might not have it set yet). |
660 SigninManagerBase* signin_manager = | 663 SigninManagerBase* signin_manager = |
661 SigninManagerFactory::GetForProfile(profile); | 664 SigninManagerFactory::GetForProfile(profile); |
662 signin_manager->SetAuthenticatedUsername(user_context.GetUserID()); | 665 signin_manager->SetAuthenticatedUsername(user_context.GetUserID()); |
663 } | 666 } |
664 } | 667 } |
665 | 668 |
666 void UserSessionManager::UserProfileInitialized(Profile* profile, | 669 void UserSessionManager::UserProfileInitialized(Profile* profile, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 CryptohomeClient* client = DBusThreadManager::Get()->GetCryptohomeClient(); | 739 CryptohomeClient* client = DBusThreadManager::Get()->GetCryptohomeClient(); |
737 btl->AddLoginTimeMarker("TPMOwn-Start", false); | 740 btl->AddLoginTimeMarker("TPMOwn-Start", false); |
738 if (cryptohome_util::TpmIsEnabled() && !cryptohome_util::TpmIsBeingOwned()) { | 741 if (cryptohome_util::TpmIsEnabled() && !cryptohome_util::TpmIsBeingOwned()) { |
739 if (cryptohome_util::TpmIsOwned()) | 742 if (cryptohome_util::TpmIsOwned()) |
740 client->CallTpmClearStoredPasswordAndBlock(); | 743 client->CallTpmClearStoredPasswordAndBlock(); |
741 else | 744 else |
742 client->TpmCanAttemptOwnership(EmptyVoidDBusMethodCallback()); | 745 client->TpmCanAttemptOwnership(EmptyVoidDBusMethodCallback()); |
743 } | 746 } |
744 btl->AddLoginTimeMarker("TPMOwn-End", false); | 747 btl->AddLoginTimeMarker("TPMOwn-End", false); |
745 | 748 |
746 UserManager* user_manager = UserManager::Get(); | 749 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
747 if (user_manager->IsLoggedInAsRegularUser()) { | 750 if (user_manager->IsLoggedInAsRegularUser()) { |
748 SAMLOfflineSigninLimiter* saml_offline_signin_limiter = | 751 SAMLOfflineSigninLimiter* saml_offline_signin_limiter = |
749 SAMLOfflineSigninLimiterFactory::GetForProfile(profile); | 752 SAMLOfflineSigninLimiterFactory::GetForProfile(profile); |
750 if (saml_offline_signin_limiter) | 753 if (saml_offline_signin_limiter) |
751 saml_offline_signin_limiter->SignedIn(user_context_.GetAuthFlow()); | 754 saml_offline_signin_limiter->SignedIn(user_context_.GetAuthFlow()); |
752 } | 755 } |
753 | 756 |
754 profile->OnLogin(); | 757 profile->OnLogin(); |
755 | 758 |
756 g_browser_process->platform_part()->SessionManager()->SetSessionState( | 759 g_browser_process->platform_part()->SessionManager()->SetSessionState( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 // When switching to RLZ enabled/disabled state, clear all recorded events. | 863 // When switching to RLZ enabled/disabled state, clear all recorded events. |
861 RLZTracker::ClearRlzState(); | 864 RLZTracker::ClearRlzState(); |
862 local_state->SetBoolean(prefs::kRLZDisabled, disabled); | 865 local_state->SetBoolean(prefs::kRLZDisabled, disabled); |
863 } | 866 } |
864 // Init the RLZ library. | 867 // Init the RLZ library. |
865 int ping_delay = profile->GetPrefs()->GetInteger( | 868 int ping_delay = profile->GetPrefs()->GetInteger( |
866 first_run::GetPingDelayPrefName().c_str()); | 869 first_run::GetPingDelayPrefName().c_str()); |
867 // Negative ping delay means to send ping immediately after a first search is | 870 // Negative ping delay means to send ping immediately after a first search is |
868 // recorded. | 871 // recorded. |
869 RLZTracker::InitRlzFromProfileDelayed( | 872 RLZTracker::InitRlzFromProfileDelayed( |
870 profile, UserManager::Get()->IsCurrentUserNew(), | 873 profile, |
871 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); | 874 user_manager::UserManager::Get()->IsCurrentUserNew(), |
| 875 ping_delay < 0, |
| 876 base::TimeDelta::FromMilliseconds(abs(ping_delay))); |
872 if (delegate_) | 877 if (delegate_) |
873 delegate_->OnRlzInitialized(); | 878 delegate_->OnRlzInitialized(); |
874 #endif | 879 #endif |
875 } | 880 } |
876 | 881 |
877 void UserSessionManager::InitializeCerts(Profile* profile) { | 882 void UserSessionManager::InitializeCerts(Profile* profile) { |
878 // Now that the user profile has been initialized | 883 // Now that the user profile has been initialized |
879 // |GetNSSCertDatabaseForProfile| is safe to be used. | 884 // |GetNSSCertDatabaseForProfile| is safe to be used. |
880 if (CertLoader::IsInitialized() && base::SysInfo::IsRunningOnChromeOS()) { | 885 if (CertLoader::IsInitialized() && base::SysInfo::IsRunningOnChromeOS()) { |
881 GetNSSCertDatabaseForProfile(profile, | 886 GetNSSCertDatabaseForProfile(profile, |
(...skipping 20 matching lines...) Expand all Loading... |
902 bool success) { | 907 bool success) { |
903 if (!success) { | 908 if (!success) { |
904 LOG(ERROR) << "Could not get list of active user sessions after crash."; | 909 LOG(ERROR) << "Could not get list of active user sessions after crash."; |
905 // If we could not get list of active user sessions it is safer to just | 910 // If we could not get list of active user sessions it is safer to just |
906 // sign out so that we don't get in the inconsistent state. | 911 // sign out so that we don't get in the inconsistent state. |
907 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); | 912 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); |
908 return; | 913 return; |
909 } | 914 } |
910 | 915 |
911 // One profile has been already loaded on browser start. | 916 // One profile has been already loaded on browser start. |
912 UserManager* user_manager = UserManager::Get(); | 917 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
913 DCHECK(user_manager->GetLoggedInUsers().size() == 1); | 918 DCHECK(user_manager->GetLoggedInUsers().size() == 1); |
914 DCHECK(user_manager->GetActiveUser()); | 919 DCHECK(user_manager->GetActiveUser()); |
915 std::string active_user_id = user_manager->GetActiveUser()->email(); | 920 std::string active_user_id = user_manager->GetActiveUser()->email(); |
916 | 921 |
917 SessionManagerClient::ActiveSessionsMap::const_iterator it; | 922 SessionManagerClient::ActiveSessionsMap::const_iterator it; |
918 for (it = sessions.begin(); it != sessions.end(); ++it) { | 923 for (it = sessions.begin(); it != sessions.end(); ++it) { |
919 if (active_user_id == it->first) | 924 if (active_user_id == it->first) |
920 continue; | 925 continue; |
921 pending_user_sessions_[it->first] = it->second; | 926 pending_user_sessions_[it->first] = it->second; |
922 } | 927 } |
(...skipping 10 matching lines...) Expand all Loading... |
933 SessionManagerClient::ActiveSessionsMap::const_iterator it = | 938 SessionManagerClient::ActiveSessionsMap::const_iterator it = |
934 pending_user_sessions_.begin(); | 939 pending_user_sessions_.begin(); |
935 std::string user_id = it->first; | 940 std::string user_id = it->first; |
936 std::string user_id_hash = it->second; | 941 std::string user_id_hash = it->second; |
937 DCHECK(!user_id.empty()); | 942 DCHECK(!user_id.empty()); |
938 DCHECK(!user_id_hash.empty()); | 943 DCHECK(!user_id_hash.empty()); |
939 pending_user_sessions_.erase(user_id); | 944 pending_user_sessions_.erase(user_id); |
940 | 945 |
941 // Check that this user is not logged in yet. | 946 // Check that this user is not logged in yet. |
942 user_manager::UserList logged_in_users = | 947 user_manager::UserList logged_in_users = |
943 UserManager::Get()->GetLoggedInUsers(); | 948 user_manager::UserManager::Get()->GetLoggedInUsers(); |
944 bool user_already_logged_in = false; | 949 bool user_already_logged_in = false; |
945 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); | 950 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); |
946 it != logged_in_users.end(); | 951 it != logged_in_users.end(); |
947 ++it) { | 952 ++it) { |
948 const user_manager::User* user = (*it); | 953 const user_manager::User* user = (*it); |
949 if (user->email() == user_id) { | 954 if (user->email() == user_id) { |
950 user_already_logged_in = true; | 955 user_already_logged_in = true; |
951 break; | 956 break; |
952 } | 957 } |
953 } | 958 } |
(...skipping 17 matching lines...) Expand all Loading... |
971 | 976 |
972 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { | 977 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { |
973 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 978 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
974 user_sessions_restored_ = true; | 979 user_sessions_restored_ = true; |
975 FOR_EACH_OBSERVER(UserSessionStateObserver, | 980 FOR_EACH_OBSERVER(UserSessionStateObserver, |
976 session_state_observer_list_, | 981 session_state_observer_list_, |
977 PendingUserSessionsRestoreFinished()); | 982 PendingUserSessionsRestoreFinished()); |
978 } | 983 } |
979 | 984 |
980 } // namespace chromeos | 985 } // namespace chromeos |
OLD | NEW |