OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/known_user.h" | 5 #include "components/user_manager/known_user.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 if (!gaia_id.empty() && GetStringPref(AccountId::FromGaiaId(gaia_id), | 249 if (!gaia_id.empty() && GetStringPref(AccountId::FromGaiaId(gaia_id), |
250 kCanonicalEmail, &stored_email)) { | 250 kCanonicalEmail, &stored_email)) { |
251 return AccountId::FromUserEmailGaiaId(stored_email, gaia_id); | 251 return AccountId::FromUserEmailGaiaId(stored_email, gaia_id); |
252 } | 252 } |
253 | 253 |
254 return (gaia_id.empty() | 254 return (gaia_id.empty() |
255 ? AccountId::FromUserEmail(user_email) | 255 ? AccountId::FromUserEmail(user_email) |
256 : AccountId::FromUserEmailGaiaId(user_email, gaia_id)); | 256 : AccountId::FromUserEmailGaiaId(user_email, gaia_id)); |
257 } | 257 } |
258 | 258 |
259 std::vector<AccountId> GetKnownAccountIds() { | |
260 std::vector<AccountId> result; | |
261 PrefService* local_state = GetLocalState(); | |
262 | |
263 // Local State may not be initialized in tests. | |
264 if (!local_state) | |
265 return result; | |
266 | |
267 const base::ListValue* known_users = local_state->GetList(kKnownUsers); | |
268 for (size_t i = 0; i < known_users->GetSize(); ++i) { | |
269 const base::DictionaryValue* element = nullptr; | |
270 if (known_users->GetDictionary(i, &element)) { | |
271 std::string email; | |
272 std::string gaia_id; | |
273 const bool has_email = element->GetString(kCanonicalEmail, &email); | |
274 const bool has_gaia_id = element->GetString(kGAIAIdKey, &gaia_id); | |
275 if (has_email || has_gaia_id) { | |
dzhioev (left Google)
2016/02/20 07:15:13
No need for {}
dzhioev (left Google)
2016/02/20 07:15:13
when this condition is false?
Alexander Alekseev
2016/02/20 08:07:11
Done.
Alexander Alekseev
2016/02/20 08:07:11
When data is corrupt.
| |
276 result.push_back(AccountId::FromUserEmailGaiaId(email, gaia_id)); | |
277 } | |
278 } | |
279 } | |
280 return result; | |
281 } | |
282 | |
259 bool GetGaiaIdMigrationStatus(const AccountId& account_id, | 283 bool GetGaiaIdMigrationStatus(const AccountId& account_id, |
260 const std::string& subsystem) { | 284 const std::string& subsystem) { |
261 bool migrated = false; | 285 bool migrated = false; |
262 | 286 |
263 if (GetBooleanPref(account_id, | 287 if (GetBooleanPref(account_id, |
264 std::string(kGaiaIdMigration) + "." + subsystem, | 288 std::string(kGaiaIdMigration) + "." + subsystem, |
265 &migrated)) { | 289 &migrated)) { |
266 return migrated; | 290 return migrated; |
267 } | 291 } |
268 | 292 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 } | 373 } |
350 } | 374 } |
351 } | 375 } |
352 | 376 |
353 void RegisterPrefs(PrefRegistrySimple* registry) { | 377 void RegisterPrefs(PrefRegistrySimple* registry) { |
354 registry->RegisterListPref(kKnownUsers); | 378 registry->RegisterListPref(kKnownUsers); |
355 } | 379 } |
356 | 380 |
357 } // namespace known_user | 381 } // namespace known_user |
358 } // namespace user_manager | 382 } // namespace user_manager |
OLD | NEW |