| 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 "components/user_manager/user_manager.h" | 5 #include "components/user_manager/user_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chromeos/login/user_names.h" | 8 #include "chromeos/login/user_names.h" |
| 9 #include "components/signin/core/account_id/account_id.h" | 9 #include "components/signin/core/account_id/account_id.h" |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return UserManager::instance; | 80 return UserManager::instance; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // static | 83 // static |
| 84 UserManager* UserManager::SetForTesting(UserManager* user_manager) { | 84 UserManager* UserManager::SetForTesting(UserManager* user_manager) { |
| 85 UserManager* previous_instance = UserManager::instance; | 85 UserManager* previous_instance = UserManager::instance; |
| 86 UserManager::instance = user_manager; | 86 UserManager::instance = user_manager; |
| 87 return previous_instance; | 87 return previous_instance; |
| 88 } | 88 } |
| 89 | 89 |
| 90 // static | |
| 91 AccountId UserManager::GetKnownUserAccountId(const std::string& user_email, | |
| 92 const std::string& gaia_id) { | |
| 93 // In tests empty accounts are possible. | |
| 94 if (user_email.empty() && gaia_id.empty()) | |
| 95 return EmptyAccountId(); | |
| 96 | |
| 97 if (user_email == chromeos::login::kStubUser) | |
| 98 return chromeos::login::StubAccountId(); | |
| 99 | |
| 100 if (user_email == chromeos::login::kGuestUserName) | |
| 101 return chromeos::login::GuestAccountId(); | |
| 102 | |
| 103 UserManager* user_manager = Get(); | |
| 104 if (user_manager) | |
| 105 return user_manager->GetKnownUserAccountIdImpl(user_email, gaia_id); | |
| 106 | |
| 107 // This is fallback for tests. | |
| 108 return (gaia_id.empty() | |
| 109 ? AccountId::FromUserEmail(user_email) | |
| 110 : AccountId::FromUserEmailGaiaId(user_email, gaia_id)); | |
| 111 } | |
| 112 | |
| 113 } // namespace user_manager | 90 } // namespace user_manager |
| OLD | NEW |