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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 445 |
446 void UserSessionManager::StartSession( | 446 void UserSessionManager::StartSession( |
447 const UserContext& user_context, | 447 const UserContext& user_context, |
448 StartSessionType start_session_type, | 448 StartSessionType start_session_type, |
449 bool has_auth_cookies, | 449 bool has_auth_cookies, |
450 bool has_active_session, | 450 bool has_active_session, |
451 UserSessionManagerDelegate* delegate) { | 451 UserSessionManagerDelegate* delegate) { |
452 delegate_ = delegate; | 452 delegate_ = delegate; |
453 start_session_type_ = start_session_type; | 453 start_session_type_ = start_session_type; |
454 | 454 |
455 VLOG(1) << "Starting session for " << user_context.GetUserID(); | 455 VLOG(1) << "Starting session for " |
| 456 << user_context.GetAccountId().GetUserEmail(); |
456 | 457 |
457 PreStartSession(); | 458 PreStartSession(); |
458 CreateUserSession(user_context, has_auth_cookies); | 459 CreateUserSession(user_context, has_auth_cookies); |
459 | 460 |
460 if (!has_active_session) | 461 if (!has_active_session) |
461 StartCrosSession(); | 462 StartCrosSession(); |
462 | 463 |
463 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually | 464 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually |
464 // ready to be used (http://crbug.com/361528). | 465 // ready to be used (http://crbug.com/361528). |
465 NotifyUserLoggedIn(); | 466 NotifyUserLoggedIn(); |
466 | 467 |
467 if (!user_context.GetDeviceId().empty()) { | 468 if (!user_context.GetDeviceId().empty()) { |
468 user_manager::UserManager::Get()->SetKnownUserDeviceId( | 469 user_manager::UserManager::Get()->SetKnownUserDeviceId( |
469 user_context.GetUserID(), user_context.GetDeviceId()); | 470 user_context.GetAccountId(), user_context.GetDeviceId()); |
470 } | 471 } |
471 | 472 |
472 PrepareProfile(); | 473 PrepareProfile(); |
473 } | 474 } |
474 | 475 |
475 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { | 476 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { |
476 if (delegate_ == delegate) | 477 if (delegate_ == delegate) |
477 delegate_ = nullptr; | 478 delegate_ = nullptr; |
478 } | 479 } |
479 | 480 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 // argv[0] is the program name |base::CommandLine::NO_PROGRAM|. | 696 // argv[0] is the program name |base::CommandLine::NO_PROGRAM|. |
696 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); | 697 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); |
697 LOG(WARNING) << "Restarting to apply per-session flags..."; | 698 LOG(WARNING) << "Restarting to apply per-session flags..."; |
698 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( | 699 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( |
699 user_manager::UserManager::Get()->GetActiveUser()->email(), flags); | 700 user_manager::UserManager::Get()->GetActiveUser()->email(), flags); |
700 AttemptRestart(profile); | 701 AttemptRestart(profile); |
701 return true; | 702 return true; |
702 } | 703 } |
703 | 704 |
704 bool UserSessionManager::NeedsToUpdateEasyUnlockKeys() const { | 705 bool UserSessionManager::NeedsToUpdateEasyUnlockKeys() const { |
705 return !user_context_.GetUserID().empty() && | 706 return user_context_.GetAccountId().is_valid() && |
706 user_manager::User::TypeHasGaiaAccount(user_context_.GetUserType()) && | 707 user_manager::User::TypeHasGaiaAccount(user_context_.GetUserType()) && |
707 user_context_.GetKey() && !user_context_.GetKey()->GetSecret().empty(); | 708 user_context_.GetKey() && !user_context_.GetKey()->GetSecret().empty(); |
708 } | 709 } |
709 | 710 |
710 bool UserSessionManager::CheckEasyUnlockKeyOps(const base::Closure& callback) { | 711 bool UserSessionManager::CheckEasyUnlockKeyOps(const base::Closure& callback) { |
711 if (!running_easy_unlock_key_ops_) | 712 if (!running_easy_unlock_key_ops_) |
712 return false; | 713 return false; |
713 | 714 |
714 // Assumes only one deferred callback is needed. | 715 // Assumes only one deferred callback is needed. |
715 DCHECK(easy_unlock_key_ops_finished_callback_.is_null()); | 716 DCHECK(easy_unlock_key_ops_finished_callback_.is_null()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 case OAuth2LoginManager::SESSION_RESTORE_PREPARING: | 754 case OAuth2LoginManager::SESSION_RESTORE_PREPARING: |
754 case OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: | 755 case OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: |
755 return; | 756 return; |
756 } | 757 } |
757 | 758 |
758 // We should not be clearing existing token state if that was a connection | 759 // We should not be clearing existing token state if that was a connection |
759 // error. http://crbug.com/295245 | 760 // error. http://crbug.com/295245 |
760 if (!connection_error) { | 761 if (!connection_error) { |
761 // We are in one of "done" states here. | 762 // We are in one of "done" states here. |
762 user_manager::UserManager::Get()->SaveUserOAuthStatus( | 763 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
763 user_manager::UserManager::Get()->GetLoggedInUser()->email(), | 764 user_manager::UserManager::Get()->GetLoggedInUser()->GetAccountId(), |
764 user_status); | 765 user_status); |
765 } | 766 } |
766 | 767 |
767 login_manager->RemoveObserver(this); | 768 login_manager->RemoveObserver(this); |
768 | 769 |
769 if (exit_after_session_restore_ && | 770 if (exit_after_session_restore_ && |
770 (state == OAuth2LoginManager::SESSION_RESTORE_DONE || | 771 (state == OAuth2LoginManager::SESSION_RESTORE_DONE || |
771 state == OAuth2LoginManager::SESSION_RESTORE_FAILED || | 772 state == OAuth2LoginManager::SESSION_RESTORE_FAILED || |
772 state == OAuth2LoginManager::SESSION_RESTORE_CONNECTION_FAILED)) { | 773 state == OAuth2LoginManager::SESSION_RESTORE_CONNECTION_FAILED)) { |
773 LOG(WARNING) << "Restarting Chrome after session restore finishes, " | 774 LOG(WARNING) << "Restarting Chrome after session restore finishes, " |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 | 857 |
857 void UserSessionManager::PreStartSession() { | 858 void UserSessionManager::PreStartSession() { |
858 // Switch log file as soon as possible. | 859 // Switch log file as soon as possible. |
859 if (base::SysInfo::IsRunningOnChromeOS()) | 860 if (base::SysInfo::IsRunningOnChromeOS()) |
860 logging::RedirectChromeLogging(*(base::CommandLine::ForCurrentProcess())); | 861 logging::RedirectChromeLogging(*(base::CommandLine::ForCurrentProcess())); |
861 } | 862 } |
862 | 863 |
863 void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() { | 864 void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() { |
864 // Store obfuscated GAIA ID. | 865 // Store obfuscated GAIA ID. |
865 if (!user_context_.GetGaiaID().empty()) { | 866 if (!user_context_.GetGaiaID().empty()) { |
866 user_manager::UserManager::Get()->UpdateGaiaID(user_context_.GetUserID(), | 867 user_manager::UserManager::Get()->UpdateGaiaID(user_context_.GetAccountId(), |
867 user_context_.GetGaiaID()); | 868 user_context_.GetGaiaID()); |
868 } | 869 } |
869 } | 870 } |
870 | 871 |
871 void UserSessionManager::StartCrosSession() { | 872 void UserSessionManager::StartCrosSession() { |
872 BootTimesRecorder* btl = BootTimesRecorder::Get(); | 873 BootTimesRecorder* btl = BootTimesRecorder::Get(); |
873 btl->AddLoginTimeMarker("StartSession-Start", false); | 874 btl->AddLoginTimeMarker("StartSession-Start", false); |
874 DBusThreadManager::Get()->GetSessionManagerClient()-> | 875 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( |
875 StartSession(user_context_.GetUserID()); | 876 user_context_.GetAccountId().GetUserEmail()); |
876 btl->AddLoginTimeMarker("StartSession-End", false); | 877 btl->AddLoginTimeMarker("StartSession-End", false); |
877 } | 878 } |
878 | 879 |
879 void UserSessionManager::NotifyUserLoggedIn() { | 880 void UserSessionManager::NotifyUserLoggedIn() { |
880 BootTimesRecorder* btl = BootTimesRecorder::Get(); | 881 BootTimesRecorder* btl = BootTimesRecorder::Get(); |
881 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); | 882 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); |
882 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 883 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
883 user_manager->UserLoggedIn(user_context_.GetUserID(), | 884 user_manager->UserLoggedIn(user_context_.GetAccountId(), |
884 user_context_.GetUserIDHash(), | 885 user_context_.GetUserIDHash(), false); |
885 false); | |
886 btl->AddLoginTimeMarker("UserLoggedIn-End", false); | 886 btl->AddLoginTimeMarker("UserLoggedIn-End", false); |
887 } | 887 } |
888 | 888 |
889 void UserSessionManager::PrepareProfile() { | 889 void UserSessionManager::PrepareProfile() { |
890 bool is_demo_session = | 890 const bool is_demo_session = DemoAppLauncher::IsDemoAppSession( |
891 DemoAppLauncher::IsDemoAppSession(user_context_.GetUserID()); | 891 user_context_.GetAccountId().GetUserEmail()); |
892 | 892 |
893 // TODO(nkostylev): Figure out whether demo session is using the right profile | 893 // TODO(nkostylev): Figure out whether demo session is using the right profile |
894 // path or not. See https://codereview.chromium.org/171423009 | 894 // path or not. See https://codereview.chromium.org/171423009 |
895 g_browser_process->profile_manager()->CreateProfileAsync( | 895 g_browser_process->profile_manager()->CreateProfileAsync( |
896 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), | 896 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), |
897 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(), | 897 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(), |
898 user_context_, is_demo_session), | 898 user_context_, is_demo_session), |
899 base::string16(), std::string(), std::string()); | 899 base::string16(), std::string(), std::string()); |
900 } | 900 } |
901 | 901 |
902 void UserSessionManager::OnProfileCreated(const UserContext& user_context, | 902 void UserSessionManager::OnProfileCreated(const UserContext& user_context, |
903 bool is_incognito_profile, | 903 bool is_incognito_profile, |
904 Profile* profile, | 904 Profile* profile, |
905 Profile::CreateStatus status) { | 905 Profile::CreateStatus status) { |
906 CHECK(profile); | 906 CHECK(profile); |
907 | 907 |
908 switch (status) { | 908 switch (status) { |
909 case Profile::CREATE_STATUS_CREATED: | 909 case Profile::CREATE_STATUS_CREATED: |
910 // Profile created but before initializing extensions and promo resources. | 910 // Profile created but before initializing extensions and promo resources. |
911 InitProfilePreferences(profile, user_context); | 911 InitProfilePreferences(profile, user_context); |
912 break; | 912 break; |
913 case Profile::CREATE_STATUS_INITIALIZED: | 913 case Profile::CREATE_STATUS_INITIALIZED: |
914 // Profile is created, extensions and promo resources are initialized. | 914 // Profile is created, extensions and promo resources are initialized. |
915 // At this point all other Chrome OS services will be notified that it is | 915 // At this point all other Chrome OS services will be notified that it is |
916 // safe to use this profile. | 916 // safe to use this profile. |
917 UserProfileInitialized(profile, | 917 UserProfileInitialized(profile, is_incognito_profile, |
918 is_incognito_profile, | 918 user_context.GetAccountId()); |
919 user_context.GetUserID()); | |
920 break; | 919 break; |
921 case Profile::CREATE_STATUS_LOCAL_FAIL: | 920 case Profile::CREATE_STATUS_LOCAL_FAIL: |
922 case Profile::CREATE_STATUS_REMOTE_FAIL: | 921 case Profile::CREATE_STATUS_REMOTE_FAIL: |
923 case Profile::CREATE_STATUS_CANCELED: | 922 case Profile::CREATE_STATUS_CANCELED: |
924 case Profile::MAX_CREATE_STATUS: | 923 case Profile::MAX_CREATE_STATUS: |
925 NOTREACHED(); | 924 NOTREACHED(); |
926 break; | 925 break; |
927 } | 926 } |
928 } | 927 } |
929 | 928 |
(...skipping 29 matching lines...) Expand all Loading... |
959 } else if (user_manager::UserManager::Get()-> | 958 } else if (user_manager::UserManager::Get()-> |
960 IsLoggedInAsUserWithGaiaAccount()) { | 959 IsLoggedInAsUserWithGaiaAccount()) { |
961 // Get the Gaia ID from the user context. If it's not available, this may | 960 // Get the Gaia ID from the user context. If it's not available, this may |
962 // not be available when unlocking a previously opened profile, or when | 961 // not be available when unlocking a previously opened profile, or when |
963 // creating a supervised users. However, in these cases the gaia_id should | 962 // creating a supervised users. However, in these cases the gaia_id should |
964 // be already available in the account tracker. | 963 // be already available in the account tracker. |
965 std::string gaia_id = user_context.GetGaiaID(); | 964 std::string gaia_id = user_context.GetGaiaID(); |
966 if (gaia_id.empty()) { | 965 if (gaia_id.empty()) { |
967 AccountTrackerService* account_tracker = | 966 AccountTrackerService* account_tracker = |
968 AccountTrackerServiceFactory::GetForProfile(profile); | 967 AccountTrackerServiceFactory::GetForProfile(profile); |
969 AccountInfo info = | 968 const AccountInfo info = account_tracker->FindAccountInfoByEmail( |
970 account_tracker->FindAccountInfoByEmail(user_context.GetUserID()); | 969 user_context.GetAccountId().GetUserEmail()); |
971 gaia_id = info.gaia; | 970 gaia_id = info.gaia; |
972 DCHECK(!gaia_id.empty()); | 971 DCHECK(!gaia_id.empty()); |
973 } | 972 } |
974 | 973 |
975 // Make sure that the google service username is properly set (we do this | 974 // Make sure that the google service username is properly set (we do this |
976 // on every sign in, not just the first login, to deal with existing | 975 // on every sign in, not just the first login, to deal with existing |
977 // profiles that might not have it set yet). | 976 // profiles that might not have it set yet). |
978 SigninManagerBase* signin_manager = | 977 SigninManagerBase* signin_manager = |
979 SigninManagerFactory::GetForProfile(profile); | 978 SigninManagerFactory::GetForProfile(profile); |
980 signin_manager->SetAuthenticatedAccountInfo(gaia_id, | 979 signin_manager->SetAuthenticatedAccountInfo( |
981 user_context.GetUserID()); | 980 gaia_id, user_context.GetAccountId().GetUserEmail()); |
982 | 981 |
983 // Backfill GAIA ID in user prefs stored in Local State. | 982 // Backfill GAIA ID in user prefs stored in Local State. |
984 std::string tmp_gaia_id; | 983 std::string tmp_gaia_id; |
985 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 984 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
986 if (!user_manager->FindGaiaID(user_context.GetUserID(), &tmp_gaia_id) && | 985 if (!user_manager->FindGaiaID(user_context.GetAccountId(), &tmp_gaia_id) && |
987 !gaia_id.empty()) { | 986 !gaia_id.empty()) { |
988 user_manager->UpdateGaiaID(user_context.GetUserID(), gaia_id); | 987 user_manager->UpdateGaiaID(user_context.GetAccountId(), gaia_id); |
989 } | 988 } |
990 } | 989 } |
991 } | 990 } |
992 | 991 |
993 void UserSessionManager::UserProfileInitialized(Profile* profile, | 992 void UserSessionManager::UserProfileInitialized(Profile* profile, |
994 bool is_incognito_profile, | 993 bool is_incognito_profile, |
995 const std::string& user_id) { | 994 const AccountId& account_id) { |
996 // Demo user signed in. | 995 // Demo user signed in. |
997 if (is_incognito_profile) { | 996 if (is_incognito_profile) { |
998 profile->OnLogin(); | 997 profile->OnLogin(); |
999 | 998 |
1000 // Send the notification before creating the browser so additional objects | 999 // Send the notification before creating the browser so additional objects |
1001 // that need the profile (e.g. the launcher) can be created first. | 1000 // that need the profile (e.g. the launcher) can be created first. |
1002 content::NotificationService::current()->Notify( | 1001 content::NotificationService::current()->Notify( |
1003 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 1002 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
1004 content::NotificationService::AllSources(), | 1003 content::NotificationService::AllSources(), |
1005 content::Details<Profile>(profile)); | 1004 content::Details<Profile>(profile)); |
1006 | 1005 |
1007 if (delegate_) | 1006 if (delegate_) |
1008 delegate_->OnProfilePrepared(profile, false); | 1007 delegate_->OnProfilePrepared(profile, false); |
1009 | 1008 |
1010 return; | 1009 return; |
1011 } | 1010 } |
1012 | 1011 |
1013 BootTimesRecorder* btl = BootTimesRecorder::Get(); | 1012 BootTimesRecorder* btl = BootTimesRecorder::Get(); |
1014 btl->AddLoginTimeMarker("UserProfileGotten", false); | 1013 btl->AddLoginTimeMarker("UserProfileGotten", false); |
1015 | 1014 |
1016 if (user_context_.IsUsingOAuth()) { | 1015 if (user_context_.IsUsingOAuth()) { |
1017 // Retrieve the policy that indicates whether to continue copying | 1016 // Retrieve the policy that indicates whether to continue copying |
1018 // authentication cookies set by a SAML IdP on subsequent logins after the | 1017 // authentication cookies set by a SAML IdP on subsequent logins after the |
1019 // first. | 1018 // first. |
1020 bool transfer_saml_auth_cookies_on_subsequent_login = false; | 1019 bool transfer_saml_auth_cookies_on_subsequent_login = false; |
1021 if (has_auth_cookies_ && | 1020 if (has_auth_cookies_ && |
1022 g_browser_process->platform_part()-> | 1021 g_browser_process->platform_part() |
1023 browser_policy_connector_chromeos()->GetUserAffiliation(user_id) == | 1022 ->browser_policy_connector_chromeos() |
1024 policy::USER_AFFILIATION_MANAGED) { | 1023 ->GetUserAffiliation(account_id.GetUserEmail()) == |
| 1024 policy::USER_AFFILIATION_MANAGED) { |
1025 CrosSettings::Get()->GetBoolean( | 1025 CrosSettings::Get()->GetBoolean( |
1026 kAccountsPrefTransferSAMLCookies, | 1026 kAccountsPrefTransferSAMLCookies, |
1027 &transfer_saml_auth_cookies_on_subsequent_login); | 1027 &transfer_saml_auth_cookies_on_subsequent_login); |
1028 } | 1028 } |
1029 | 1029 |
1030 // Transfers authentication-related data from the profile that was used for | 1030 // Transfers authentication-related data from the profile that was used for |
1031 // authentication to the user's profile. The proxy authentication state is | 1031 // authentication to the user's profile. The proxy authentication state is |
1032 // transferred unconditionally. If the user authenticated via an auth | 1032 // transferred unconditionally. If the user authenticated via an auth |
1033 // extension, authentication cookies and channel IDs will be transferred as | 1033 // extension, authentication cookies and channel IDs will be transferred as |
1034 // well when the user's cookie jar is empty. If the cookie jar is not empty, | 1034 // well when the user's cookie jar is empty. If the cookie jar is not empty, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 if (cryptohome_util::TpmIsOwned()) | 1083 if (cryptohome_util::TpmIsOwned()) |
1084 client->CallTpmClearStoredPasswordAndBlock(); | 1084 client->CallTpmClearStoredPasswordAndBlock(); |
1085 else | 1085 else |
1086 client->TpmCanAttemptOwnership(EmptyVoidDBusMethodCallback()); | 1086 client->TpmCanAttemptOwnership(EmptyVoidDBusMethodCallback()); |
1087 } | 1087 } |
1088 btl->AddLoginTimeMarker("TPMOwn-End", false); | 1088 btl->AddLoginTimeMarker("TPMOwn-End", false); |
1089 | 1089 |
1090 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 1090 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
1091 if (user_manager->IsLoggedInAsUserWithGaiaAccount()) { | 1091 if (user_manager->IsLoggedInAsUserWithGaiaAccount()) { |
1092 if (user_context_.GetAuthFlow() == UserContext::AUTH_FLOW_GAIA_WITH_SAML) | 1092 if (user_context_.GetAuthFlow() == UserContext::AUTH_FLOW_GAIA_WITH_SAML) |
1093 user_manager->UpdateUsingSAML(user_context_.GetUserID(), true); | 1093 user_manager->UpdateUsingSAML(user_context_.GetAccountId(), true); |
1094 SAMLOfflineSigninLimiter* saml_offline_signin_limiter = | 1094 SAMLOfflineSigninLimiter* saml_offline_signin_limiter = |
1095 SAMLOfflineSigninLimiterFactory::GetForProfile(profile); | 1095 SAMLOfflineSigninLimiterFactory::GetForProfile(profile); |
1096 if (saml_offline_signin_limiter) | 1096 if (saml_offline_signin_limiter) |
1097 saml_offline_signin_limiter->SignedIn(user_context_.GetAuthFlow()); | 1097 saml_offline_signin_limiter->SignedIn(user_context_.GetAuthFlow()); |
1098 } | 1098 } |
1099 | 1099 |
1100 profile->OnLogin(); | 1100 profile->OnLogin(); |
1101 | 1101 |
1102 g_browser_process->platform_part()->SessionManager()->SetSessionState( | 1102 g_browser_process->platform_part()->SessionManager()->SetSessionState( |
1103 session_manager::SESSION_STATE_LOGGED_IN_NOT_ACTIVE); | 1103 session_manager::SESSION_STATE_LOGGED_IN_NOT_ACTIVE); |
(...skipping 12 matching lines...) Expand all Loading... |
1116 InitRlz(profile); | 1116 InitRlz(profile); |
1117 InitializeCerts(profile); | 1117 InitializeCerts(profile); |
1118 InitializeCRLSetFetcher(user); | 1118 InitializeCRLSetFetcher(user); |
1119 InitializeEVCertificatesWhitelistComponent(user); | 1119 InitializeEVCertificatesWhitelistComponent(user); |
1120 } | 1120 } |
1121 | 1121 |
1122 UpdateEasyUnlockKeys(user_context_); | 1122 UpdateEasyUnlockKeys(user_context_); |
1123 user_context_.ClearSecrets(); | 1123 user_context_.ClearSecrets(); |
1124 if (TokenHandlesEnabled()) { | 1124 if (TokenHandlesEnabled()) { |
1125 CreateTokenUtilIfMissing(); | 1125 CreateTokenUtilIfMissing(); |
1126 if (token_handle_util_->ShouldObtainHandle(user->GetUserID())) { | 1126 if (token_handle_util_->ShouldObtainHandle(user->GetAccountId())) { |
1127 if (!token_handle_fetcher_.get()) { | 1127 if (!token_handle_fetcher_.get()) { |
1128 token_handle_fetcher_.reset(new TokenHandleFetcher( | 1128 token_handle_fetcher_.reset(new TokenHandleFetcher( |
1129 token_handle_util_.get(), user->GetUserID())); | 1129 token_handle_util_.get(), user->GetAccountId())); |
1130 token_handle_fetcher_->BackfillToken( | 1130 token_handle_fetcher_->BackfillToken( |
1131 profile, base::Bind(&UserSessionManager::OnTokenHandleObtained, | 1131 profile, base::Bind(&UserSessionManager::OnTokenHandleObtained, |
1132 weak_factory_.GetWeakPtr())); | 1132 weak_factory_.GetWeakPtr())); |
1133 } | 1133 } |
1134 } | 1134 } |
1135 } | 1135 } |
1136 | 1136 |
1137 // Now that profile is ready, proceed to either alternative login flows or | 1137 // Now that profile is ready, proceed to either alternative login flows or |
1138 // launch browser. | 1138 // launch browser. |
1139 bool browser_launched = InitializeUserSession(profile); | 1139 bool browser_launched = InitializeUserSession(profile); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 ++it) { | 1431 ++it) { |
1432 const user_manager::User* user = (*it); | 1432 const user_manager::User* user = (*it); |
1433 if (user->email() == user_id) { | 1433 if (user->email() == user_id) { |
1434 user_already_logged_in = true; | 1434 user_already_logged_in = true; |
1435 break; | 1435 break; |
1436 } | 1436 } |
1437 } | 1437 } |
1438 DCHECK(!user_already_logged_in); | 1438 DCHECK(!user_already_logged_in); |
1439 | 1439 |
1440 if (!user_already_logged_in) { | 1440 if (!user_already_logged_in) { |
1441 UserContext user_context(user_id); | 1441 UserContext user_context(AccountId::FromUserEmail(user_id)); |
1442 user_context.SetUserIDHash(user_id_hash); | 1442 user_context.SetUserIDHash(user_id_hash); |
1443 user_context.SetIsUsingOAuth(false); | 1443 user_context.SetIsUsingOAuth(false); |
1444 | 1444 |
1445 // Will call OnProfilePrepared() once profile has been loaded. | 1445 // Will call OnProfilePrepared() once profile has been loaded. |
1446 // Only handling secondary users here since primary user profile | 1446 // Only handling secondary users here since primary user profile |
1447 // (and session) has been loaded on Chrome startup. | 1447 // (and session) has been loaded on Chrome startup. |
1448 StartSession(user_context, | 1448 StartSession(user_context, |
1449 SECONDARY_USER_SESSION_AFTER_CRASH, | 1449 SECONDARY_USER_SESSION_AFTER_CRASH, |
1450 false, // has_auth_cookies | 1450 false, // has_auth_cookies |
1451 true, // has_active_session, this is restart after crash | 1451 true, // has_active_session, this is restart after crash |
(...skipping 17 matching lines...) Expand all Loading... |
1469 // and RefreshKeys op expects a failure to stop. As a result, some tests would | 1469 // and RefreshKeys op expects a failure to stop. As a result, some tests would |
1470 // timeout. | 1470 // timeout. |
1471 // TODO(xiyuan): Revisit this when adding tests. | 1471 // TODO(xiyuan): Revisit this when adding tests. |
1472 if (!base::SysInfo::IsRunningOnChromeOS()) | 1472 if (!base::SysInfo::IsRunningOnChromeOS()) |
1473 return; | 1473 return; |
1474 | 1474 |
1475 // Only update Easy unlock keys for regular user. | 1475 // Only update Easy unlock keys for regular user. |
1476 // TODO(xiyuan): Fix inconsistency user type of |user_context| introduced in | 1476 // TODO(xiyuan): Fix inconsistency user type of |user_context| introduced in |
1477 // authenticator. | 1477 // authenticator. |
1478 const user_manager::User* user = | 1478 const user_manager::User* user = |
1479 user_manager::UserManager::Get()->FindUser(user_context.GetUserID()); | 1479 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); |
1480 if (!user || !user->HasGaiaAccount()) | 1480 if (!user || !user->HasGaiaAccount()) |
1481 return; | 1481 return; |
1482 | 1482 |
1483 // Bail if |user_context| does not have secret. | 1483 // Bail if |user_context| does not have secret. |
1484 if (user_context.GetKey()->GetSecret().empty()) | 1484 if (user_context.GetKey()->GetSecret().empty()) |
1485 return; | 1485 return; |
1486 | 1486 |
1487 const base::ListValue* device_list = NULL; | 1487 const base::ListValue* device_list = NULL; |
1488 EasyUnlockService* easy_unlock_service = EasyUnlockService::GetForUser(*user); | 1488 EasyUnlockService* easy_unlock_service = EasyUnlockService::GetForUser(*user); |
1489 if (easy_unlock_service) { | 1489 if (easy_unlock_service) { |
1490 device_list = easy_unlock_service->GetRemoteDevices(); | 1490 device_list = easy_unlock_service->GetRemoteDevices(); |
1491 easy_unlock_service->SetHardlockState( | 1491 easy_unlock_service->SetHardlockState( |
1492 EasyUnlockScreenlockStateHandler::NO_HARDLOCK); | 1492 EasyUnlockScreenlockStateHandler::NO_HARDLOCK); |
1493 } | 1493 } |
1494 | 1494 |
1495 base::ListValue empty_list; | 1495 base::ListValue empty_list; |
1496 if (!device_list) | 1496 if (!device_list) |
1497 device_list = &empty_list; | 1497 device_list = &empty_list; |
1498 | 1498 |
1499 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager(); | 1499 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager(); |
1500 running_easy_unlock_key_ops_ = true; | 1500 running_easy_unlock_key_ops_ = true; |
1501 key_manager->RefreshKeys( | 1501 key_manager->RefreshKeys( |
1502 user_context, *device_list, | 1502 user_context, *device_list, |
1503 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(), | 1503 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(), |
1504 user_context.GetUserID())); | 1504 user_context.GetAccountId().GetUserEmail())); |
1505 } | 1505 } |
1506 | 1506 |
1507 net::URLRequestContextGetter* | 1507 net::URLRequestContextGetter* |
1508 UserSessionManager::GetAuthRequestContext() const { | 1508 UserSessionManager::GetAuthRequestContext() const { |
1509 net::URLRequestContextGetter* auth_request_context = nullptr; | 1509 net::URLRequestContextGetter* auth_request_context = nullptr; |
1510 | 1510 |
1511 if (StartupUtils::IsWebviewSigninEnabled()) { | 1511 if (StartupUtils::IsWebviewSigninEnabled()) { |
1512 // Webview uses different partition storage than iframe. We need to get | 1512 // Webview uses different partition storage than iframe. We need to get |
1513 // cookies from the right storage for url request to get auth token into | 1513 // cookies from the right storage for url request to get auth token into |
1514 // session. | 1514 // session. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 exit_after_session_restore_ = true; | 1555 exit_after_session_restore_ = true; |
1556 } | 1556 } |
1557 | 1557 |
1558 void UserSessionManager::OnEasyUnlockKeyOpsFinished( | 1558 void UserSessionManager::OnEasyUnlockKeyOpsFinished( |
1559 const std::string& user_id, | 1559 const std::string& user_id, |
1560 bool success) { | 1560 bool success) { |
1561 running_easy_unlock_key_ops_ = false; | 1561 running_easy_unlock_key_ops_ = false; |
1562 if (!easy_unlock_key_ops_finished_callback_.is_null()) | 1562 if (!easy_unlock_key_ops_finished_callback_.is_null()) |
1563 easy_unlock_key_ops_finished_callback_.Run(); | 1563 easy_unlock_key_ops_finished_callback_.Run(); |
1564 | 1564 |
1565 const user_manager::User* user = | 1565 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
1566 user_manager::UserManager::Get()->FindUser(user_id); | 1566 AccountId::FromUserEmail(user_id)); |
1567 EasyUnlockService* easy_unlock_service = | 1567 EasyUnlockService* easy_unlock_service = |
1568 EasyUnlockService::GetForUser(*user); | 1568 EasyUnlockService::GetForUser(*user); |
1569 easy_unlock_service->CheckCryptohomeKeysAndMaybeHardlock(); | 1569 easy_unlock_service->CheckCryptohomeKeysAndMaybeHardlock(); |
1570 } | 1570 } |
1571 | 1571 |
1572 void UserSessionManager::ActiveUserChanged( | 1572 void UserSessionManager::ActiveUserChanged( |
1573 const user_manager::User* active_user) { | 1573 const user_manager::User* active_user) { |
1574 if (!user_manager::UserManager::Get()->IsCurrentUserNew()) | 1574 if (!user_manager::UserManager::Get()->IsCurrentUserNew()) |
1575 SendUserPodsMetrics(); | 1575 SendUserPodsMetrics(); |
1576 | 1576 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 else | 1717 else |
1718 display = USER_PODS_DISPLAY_DISABLED_REGULAR; | 1718 display = USER_PODS_DISPLAY_DISABLED_REGULAR; |
1719 } | 1719 } |
1720 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display, | 1720 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display, |
1721 NUM_USER_PODS_DISPLAY); | 1721 NUM_USER_PODS_DISPLAY); |
1722 } | 1722 } |
1723 | 1723 |
1724 void UserSessionManager::OnOAuth2TokensFetched(UserContext context) { | 1724 void UserSessionManager::OnOAuth2TokensFetched(UserContext context) { |
1725 if (StartupUtils::IsWebviewSigninEnabled() && TokenHandlesEnabled()) { | 1725 if (StartupUtils::IsWebviewSigninEnabled() && TokenHandlesEnabled()) { |
1726 CreateTokenUtilIfMissing(); | 1726 CreateTokenUtilIfMissing(); |
1727 if (token_handle_util_->ShouldObtainHandle(context.GetUserID())) { | 1727 if (token_handle_util_->ShouldObtainHandle(context.GetAccountId())) { |
1728 token_handle_fetcher_.reset(new TokenHandleFetcher( | 1728 token_handle_fetcher_.reset(new TokenHandleFetcher( |
1729 token_handle_util_.get(), context.GetUserID())); | 1729 token_handle_util_.get(), context.GetAccountId())); |
1730 token_handle_fetcher_->FillForNewUser( | 1730 token_handle_fetcher_->FillForNewUser( |
1731 context.GetAccessToken(), | 1731 context.GetAccessToken(), |
1732 base::Bind(&UserSessionManager::OnTokenHandleObtained, | 1732 base::Bind(&UserSessionManager::OnTokenHandleObtained, |
1733 weak_factory_.GetWeakPtr())); | 1733 weak_factory_.GetWeakPtr())); |
1734 } | 1734 } |
1735 } | 1735 } |
1736 } | 1736 } |
1737 | 1737 |
1738 void UserSessionManager::OnTokenHandleObtained(const user_manager::UserID& id, | 1738 void UserSessionManager::OnTokenHandleObtained(const AccountId& account_id, |
1739 bool success) { | 1739 bool success) { |
1740 if (!success) | 1740 if (!success) |
1741 LOG(ERROR) << "OAuth2 token handle fetch failed."; | 1741 LOG(ERROR) << "OAuth2 token handle fetch failed."; |
1742 token_handle_fetcher_.reset(); | 1742 token_handle_fetcher_.reset(); |
1743 } | 1743 } |
1744 | 1744 |
1745 bool UserSessionManager::TokenHandlesEnabled() { | 1745 bool UserSessionManager::TokenHandlesEnabled() { |
1746 if (!should_obtain_handles_) | 1746 if (!should_obtain_handles_) |
1747 return false; | 1747 return false; |
1748 bool ephemeral_users_enabled = false; | 1748 bool ephemeral_users_enabled = false; |
(...skipping 12 matching lines...) Expand all Loading... |
1761 first_run::GoodiesDisplayer::Delete(); | 1761 first_run::GoodiesDisplayer::Delete(); |
1762 } | 1762 } |
1763 | 1763 |
1764 void UserSessionManager::CreateTokenUtilIfMissing() { | 1764 void UserSessionManager::CreateTokenUtilIfMissing() { |
1765 if (!token_handle_util_.get()) | 1765 if (!token_handle_util_.get()) |
1766 token_handle_util_.reset( | 1766 token_handle_util_.reset( |
1767 new TokenHandleUtil(user_manager::UserManager::Get())); | 1767 new TokenHandleUtil(user_manager::UserManager::Get())); |
1768 } | 1768 } |
1769 | 1769 |
1770 } // namespace chromeos | 1770 } // namespace chromeos |
OLD | NEW |