| 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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { | 922 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { |
| 923 user_manager::User* active_user = | 923 user_manager::User* active_user = |
| 924 user_manager::UserManager::Get()->GetActiveUser(); | 924 user_manager::UserManager::Get()->GetActiveUser(); |
| 925 std::string supervised_user_sync_id = | 925 std::string supervised_user_sync_id = |
| 926 ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( | 926 ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( |
| 927 active_user->email()); | 927 active_user->email()); |
| 928 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, | 928 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, |
| 929 supervised_user_sync_id); | 929 supervised_user_sync_id); |
| 930 } else if (user_manager::UserManager::Get()-> | 930 } else if (user_manager::UserManager::Get()-> |
| 931 IsLoggedInAsUserWithGaiaAccount()) { | 931 IsLoggedInAsUserWithGaiaAccount()) { |
| 932 // Prime the account tracker with this combination of gaia id/display email. | 932 // Get the Gaia ID from the user context. If it's not available, this may |
| 933 // Don't do this unless both email and gaia_id are valid. They may not | 933 // not be available when unlocking a previously opened profile, or when |
| 934 // be when simply unlocking the profile. | 934 // creating a supervised users. However, in these cases the gaia_id should |
| 935 if (!user_context.GetGaiaID().empty() && | 935 // be already available in the account tracker. |
| 936 !user_context.GetUserID().empty()) { | 936 std::string gaia_id = user_context.GetGaiaID(); |
| 937 if (gaia_id.empty()) { |
| 937 AccountTrackerService* account_tracker = | 938 AccountTrackerService* account_tracker = |
| 938 AccountTrackerServiceFactory::GetForProfile(profile); | 939 AccountTrackerServiceFactory::GetForProfile(profile); |
| 939 account_tracker->SeedAccountInfo(user_context.GetGaiaID(), | 940 AccountTrackerService::AccountInfo info = |
| 940 user_context.GetUserID()); | 941 account_tracker->FindAccountInfoByEmail(user_context.GetUserID()); |
| 942 gaia_id = info.gaia; |
| 943 DCHECK(!gaia_id.empty()); |
| 941 } | 944 } |
| 942 | 945 |
| 943 // Make sure that the google service username is properly set (we do this | 946 // Make sure that the google service username is properly set (we do this |
| 944 // on every sign in, not just the first login, to deal with existing | 947 // on every sign in, not just the first login, to deal with existing |
| 945 // profiles that might not have it set yet). | 948 // profiles that might not have it set yet). |
| 946 SigninManagerBase* signin_manager = | 949 SigninManagerBase* signin_manager = |
| 947 SigninManagerFactory::GetForProfile(profile); | 950 SigninManagerFactory::GetForProfile(profile); |
| 948 signin_manager->SetAuthenticatedUsername(user_context.GetUserID()); | 951 signin_manager->SetAuthenticatedAccountInfo(gaia_id, |
| 952 user_context.GetUserID()); |
| 949 } | 953 } |
| 950 } | 954 } |
| 951 | 955 |
| 952 void UserSessionManager::UserProfileInitialized(Profile* profile, | 956 void UserSessionManager::UserProfileInitialized(Profile* profile, |
| 953 bool is_incognito_profile, | 957 bool is_incognito_profile, |
| 954 const std::string& user_id) { | 958 const std::string& user_id) { |
| 955 // Demo user signed in. | 959 // Demo user signed in. |
| 956 if (is_incognito_profile) { | 960 if (is_incognito_profile) { |
| 957 profile->OnLogin(); | 961 profile->OnLogin(); |
| 958 | 962 |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 if (is_enterprise_managed) | 1653 if (is_enterprise_managed) |
| 1650 display = USER_PODS_DISPLAY_DISABLED_MANAGED; | 1654 display = USER_PODS_DISPLAY_DISABLED_MANAGED; |
| 1651 else | 1655 else |
| 1652 display = USER_PODS_DISPLAY_DISABLED_REGULAR; | 1656 display = USER_PODS_DISPLAY_DISABLED_REGULAR; |
| 1653 } | 1657 } |
| 1654 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display, | 1658 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display, |
| 1655 NUM_USER_PODS_DISPLAY); | 1659 NUM_USER_PODS_DISPLAY); |
| 1656 } | 1660 } |
| 1657 | 1661 |
| 1658 } // namespace chromeos | 1662 } // namespace chromeos |
| OLD | NEW |