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" | |
9 #include "components/signin/core/account_id/account_id.h" | |
8 | 10 |
9 namespace user_manager { | 11 namespace user_manager { |
10 | 12 |
11 UserManager* UserManager::instance = NULL; | 13 UserManager* UserManager::instance = NULL; |
12 | 14 |
13 UserManager::Observer::~Observer() { | 15 UserManager::Observer::~Observer() { |
14 } | 16 } |
15 | 17 |
16 void UserManager::Observer::LocalStateChanged(UserManager* user_manager) { | 18 void UserManager::Observer::LocalStateChanged(UserManager* user_manager) { |
17 } | 19 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 return UserManager::instance; | 80 return UserManager::instance; |
79 } | 81 } |
80 | 82 |
81 // static | 83 // static |
82 UserManager* UserManager::SetForTesting(UserManager* user_manager) { | 84 UserManager* UserManager::SetForTesting(UserManager* user_manager) { |
83 UserManager* previous_instance = UserManager::instance; | 85 UserManager* previous_instance = UserManager::instance; |
84 UserManager::instance = user_manager; | 86 UserManager::instance = user_manager; |
85 return previous_instance; | 87 return previous_instance; |
86 } | 88 } |
87 | 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() | |
achuithb
2015/11/23 22:26:10
Is this the right formatting? Shouldn't it be:
gai
Alexander Alekseev
2015/11/24 04:26:54
This is the result of recent clang-format.
| |
109 ? AccountId::FromUserEmail(user_email) | |
110 : AccountId::FromUserEmailGaiaId(user_email, gaia_id)); | |
111 } | |
112 | |
88 } // namespace user_manager | 113 } // namespace user_manager |
OLD | NEW |