| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #include "chromeos/network/portal_detector/network_portal_detector.h" | 87 #include "chromeos/network/portal_detector/network_portal_detector.h" |
| 88 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" | 88 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" |
| 89 #include "chromeos/settings/cros_settings_names.h" | 89 #include "chromeos/settings/cros_settings_names.h" |
| 90 #include "components/component_updater/component_updater_service.h" | 90 #include "components/component_updater/component_updater_service.h" |
| 91 #include "components/flags_ui/pref_service_flags_storage.h" | 91 #include "components/flags_ui/pref_service_flags_storage.h" |
| 92 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 92 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 93 #include "components/session_manager/core/session_manager.h" | 93 #include "components/session_manager/core/session_manager.h" |
| 94 #include "components/signin/core/account_id/account_id.h" | 94 #include "components/signin/core/account_id/account_id.h" |
| 95 #include "components/signin/core/browser/account_tracker_service.h" | 95 #include "components/signin/core/browser/account_tracker_service.h" |
| 96 #include "components/signin/core/browser/signin_manager_base.h" | 96 #include "components/signin/core/browser/signin_manager_base.h" |
| 97 #include "components/user_manager/known_user.h" |
| 97 #include "components/user_manager/user.h" | 98 #include "components/user_manager/user.h" |
| 98 #include "components/user_manager/user_manager.h" | 99 #include "components/user_manager/user_manager.h" |
| 99 #include "components/user_manager/user_type.h" | 100 #include "components/user_manager/user_type.h" |
| 100 #include "content/public/browser/browser_thread.h" | 101 #include "content/public/browser/browser_thread.h" |
| 101 #include "content/public/browser/notification_service.h" | 102 #include "content/public/browser/notification_service.h" |
| 102 #include "content/public/browser/storage_partition.h" | 103 #include "content/public/browser/storage_partition.h" |
| 103 #include "content/public/common/content_switches.h" | 104 #include "content/public/common/content_switches.h" |
| 104 #include "ui/base/ime/chromeos/input_method_descriptor.h" | 105 #include "ui/base/ime/chromeos/input_method_descriptor.h" |
| 105 #include "ui/base/ime/chromeos/input_method_manager.h" | 106 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 106 #include "url/gurl.h" | 107 #include "url/gurl.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 CreateUserSession(user_context, has_auth_cookies); | 460 CreateUserSession(user_context, has_auth_cookies); |
| 460 | 461 |
| 461 if (!has_active_session) | 462 if (!has_active_session) |
| 462 StartCrosSession(); | 463 StartCrosSession(); |
| 463 | 464 |
| 464 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually | 465 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually |
| 465 // ready to be used (http://crbug.com/361528). | 466 // ready to be used (http://crbug.com/361528). |
| 466 NotifyUserLoggedIn(); | 467 NotifyUserLoggedIn(); |
| 467 | 468 |
| 468 if (!user_context.GetDeviceId().empty()) { | 469 if (!user_context.GetDeviceId().empty()) { |
| 469 user_manager::UserManager::Get()->SetKnownUserDeviceId( | 470 user_manager::known_user::SetKnownUserDeviceId(user_context.GetAccountId(), |
| 470 user_context.GetAccountId(), user_context.GetDeviceId()); | 471 user_context.GetDeviceId()); |
| 471 } | 472 } |
| 472 | 473 |
| 473 PrepareProfile(); | 474 PrepareProfile(); |
| 474 } | 475 } |
| 475 | 476 |
| 476 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { | 477 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { |
| 477 if (delegate_ == delegate) | 478 if (delegate_ == delegate) |
| 478 delegate_ = nullptr; | 479 delegate_ = nullptr; |
| 479 } | 480 } |
| 480 | 481 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 | 858 |
| 858 void UserSessionManager::PreStartSession() { | 859 void UserSessionManager::PreStartSession() { |
| 859 // Switch log file as soon as possible. | 860 // Switch log file as soon as possible. |
| 860 if (base::SysInfo::IsRunningOnChromeOS()) | 861 if (base::SysInfo::IsRunningOnChromeOS()) |
| 861 logging::RedirectChromeLogging(*(base::CommandLine::ForCurrentProcess())); | 862 logging::RedirectChromeLogging(*(base::CommandLine::ForCurrentProcess())); |
| 862 } | 863 } |
| 863 | 864 |
| 864 void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() { | 865 void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() { |
| 865 // Store obfuscated GAIA ID. | 866 // Store obfuscated GAIA ID. |
| 866 if (!user_context_.GetGaiaID().empty()) { | 867 if (!user_context_.GetGaiaID().empty()) { |
| 867 user_manager::UserManager::Get()->UpdateGaiaID(user_context_.GetAccountId(), | 868 user_manager::known_user::UpdateGaiaID(user_context_.GetAccountId(), |
| 868 user_context_.GetGaiaID()); | 869 user_context_.GetGaiaID()); |
| 869 } | 870 } |
| 870 } | 871 } |
| 871 | 872 |
| 872 void UserSessionManager::StartCrosSession() { | 873 void UserSessionManager::StartCrosSession() { |
| 873 BootTimesRecorder* btl = BootTimesRecorder::Get(); | 874 BootTimesRecorder* btl = BootTimesRecorder::Get(); |
| 874 btl->AddLoginTimeMarker("StartSession-Start", false); | 875 btl->AddLoginTimeMarker("StartSession-Start", false); |
| 875 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( | 876 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( |
| 876 user_context_.GetAccountId().GetUserEmail()); | 877 user_context_.GetAccountId().GetUserEmail()); |
| 877 btl->AddLoginTimeMarker("StartSession-End", false); | 878 btl->AddLoginTimeMarker("StartSession-End", false); |
| 878 } | 879 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 // Make sure that the google service username is properly set (we do this | 975 // Make sure that the google service username is properly set (we do this |
| 975 // on every sign in, not just the first login, to deal with existing | 976 // on every sign in, not just the first login, to deal with existing |
| 976 // profiles that might not have it set yet). | 977 // profiles that might not have it set yet). |
| 977 SigninManagerBase* signin_manager = | 978 SigninManagerBase* signin_manager = |
| 978 SigninManagerFactory::GetForProfile(profile); | 979 SigninManagerFactory::GetForProfile(profile); |
| 979 signin_manager->SetAuthenticatedAccountInfo( | 980 signin_manager->SetAuthenticatedAccountInfo( |
| 980 gaia_id, user_context.GetAccountId().GetUserEmail()); | 981 gaia_id, user_context.GetAccountId().GetUserEmail()); |
| 981 | 982 |
| 982 // Backfill GAIA ID in user prefs stored in Local State. | 983 // Backfill GAIA ID in user prefs stored in Local State. |
| 983 std::string tmp_gaia_id; | 984 std::string tmp_gaia_id; |
| 984 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 985 if (!user_manager::known_user::FindGaiaID(user_context.GetAccountId(), |
| 985 if (!user_manager->FindGaiaID(user_context.GetAccountId(), &tmp_gaia_id) && | 986 &tmp_gaia_id) && |
| 986 !gaia_id.empty()) { | 987 !gaia_id.empty()) { |
| 987 user_manager->UpdateGaiaID(user_context.GetAccountId(), gaia_id); | 988 user_manager::known_user::UpdateGaiaID(user_context.GetAccountId(), |
| 989 gaia_id); |
| 988 } | 990 } |
| 989 } | 991 } |
| 990 } | 992 } |
| 991 | 993 |
| 992 void UserSessionManager::UserProfileInitialized(Profile* profile, | 994 void UserSessionManager::UserProfileInitialized(Profile* profile, |
| 993 bool is_incognito_profile, | 995 bool is_incognito_profile, |
| 994 const AccountId& account_id) { | 996 const AccountId& account_id) { |
| 995 // Demo user signed in. | 997 // Demo user signed in. |
| 996 if (is_incognito_profile) { | 998 if (is_incognito_profile) { |
| 997 profile->OnLogin(); | 999 profile->OnLogin(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 if (cryptohome_util::TpmIsOwned()) | 1085 if (cryptohome_util::TpmIsOwned()) |
| 1084 client->CallTpmClearStoredPasswordAndBlock(); | 1086 client->CallTpmClearStoredPasswordAndBlock(); |
| 1085 else | 1087 else |
| 1086 client->TpmCanAttemptOwnership(EmptyVoidDBusMethodCallback()); | 1088 client->TpmCanAttemptOwnership(EmptyVoidDBusMethodCallback()); |
| 1087 } | 1089 } |
| 1088 btl->AddLoginTimeMarker("TPMOwn-End", false); | 1090 btl->AddLoginTimeMarker("TPMOwn-End", false); |
| 1089 | 1091 |
| 1090 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 1092 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 1091 if (user_manager->IsLoggedInAsUserWithGaiaAccount()) { | 1093 if (user_manager->IsLoggedInAsUserWithGaiaAccount()) { |
| 1092 if (user_context_.GetAuthFlow() == UserContext::AUTH_FLOW_GAIA_WITH_SAML) | 1094 if (user_context_.GetAuthFlow() == UserContext::AUTH_FLOW_GAIA_WITH_SAML) |
| 1093 user_manager->UpdateUsingSAML(user_context_.GetAccountId(), true); | 1095 user_manager::known_user::UpdateUsingSAML(user_context_.GetAccountId(), |
| 1096 true); |
| 1094 SAMLOfflineSigninLimiter* saml_offline_signin_limiter = | 1097 SAMLOfflineSigninLimiter* saml_offline_signin_limiter = |
| 1095 SAMLOfflineSigninLimiterFactory::GetForProfile(profile); | 1098 SAMLOfflineSigninLimiterFactory::GetForProfile(profile); |
| 1096 if (saml_offline_signin_limiter) | 1099 if (saml_offline_signin_limiter) |
| 1097 saml_offline_signin_limiter->SignedIn(user_context_.GetAuthFlow()); | 1100 saml_offline_signin_limiter->SignedIn(user_context_.GetAuthFlow()); |
| 1098 } | 1101 } |
| 1099 | 1102 |
| 1100 profile->OnLogin(); | 1103 profile->OnLogin(); |
| 1101 | 1104 |
| 1102 g_browser_process->platform_part()->SessionManager()->SetSessionState( | 1105 g_browser_process->platform_part()->SessionManager()->SetSessionState( |
| 1103 session_manager::SESSION_STATE_LOGGED_IN_NOT_ACTIVE); | 1106 session_manager::SESSION_STATE_LOGGED_IN_NOT_ACTIVE); |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 } | 1759 } |
| 1757 | 1760 |
| 1758 void UserSessionManager::Shutdown() { | 1761 void UserSessionManager::Shutdown() { |
| 1759 token_handle_fetcher_.reset(); | 1762 token_handle_fetcher_.reset(); |
| 1760 token_handle_util_.reset(); | 1763 token_handle_util_.reset(); |
| 1761 first_run::GoodiesDisplayer::Delete(); | 1764 first_run::GoodiesDisplayer::Delete(); |
| 1762 } | 1765 } |
| 1763 | 1766 |
| 1764 void UserSessionManager::CreateTokenUtilIfMissing() { | 1767 void UserSessionManager::CreateTokenUtilIfMissing() { |
| 1765 if (!token_handle_util_.get()) | 1768 if (!token_handle_util_.get()) |
| 1766 token_handle_util_.reset( | 1769 token_handle_util_.reset(new TokenHandleUtil()); |
| 1767 new TokenHandleUtil(user_manager::UserManager::Get())); | |
| 1768 } | 1770 } |
| 1769 | 1771 |
| 1770 } // namespace chromeos | 1772 } // namespace chromeos |
| OLD | NEW |