| 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 "chromeos/cryptohome/cryptohome_parameters.h" | 5 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "chromeos/dbus/cryptohome/key.pb.h" | 10 #include "chromeos/dbus/cryptohome/key.pb.h" |
| 11 #include "components/signin/core/account_id/account_id.h" | 11 #include "components/signin/core/account_id/account_id.h" |
| 12 #include "components/user_manager/known_user.h" | 12 #include "components/user_manager/known_user.h" |
| 13 | 13 |
| 14 namespace cryptohome { | 14 namespace cryptohome { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // Subsystem name for GaiaId migration status. | 17 // Subsystem name for GaiaId migration status. |
| 18 const char kCryptohome[] = "cryptohome"; | 18 const char kCryptohome[] = "cryptohome"; |
| 19 | 19 |
| 20 const std::string GetCryptohomeId(const AccountId& account_id) { | 20 const std::string GetCryptohomeId(const AccountId& account_id) { |
| 21 // Guest/kiosk/managed/public accounts have empty GaiaId. Default to email. | 21 // Guest/kiosk/managed/public accounts have empty GaiaId. Default to email. |
| 22 if (account_id.GetGaiaId().empty()) | 22 if (account_id.GetAccountType() == AccountType::UNKNOWN) |
| 23 return account_id.GetUserEmail(); // Migrated | 23 return account_id.GetUserEmail(); // Migrated |
| 24 | 24 |
| 25 if (GetGaiaIdMigrationStatus(account_id)) | 25 if (GetGaiaIdMigrationStatus(account_id)) |
| 26 return account_id.GetAccountIdKey(); | 26 return account_id.GetAccountIdKey(); |
| 27 | 27 |
| 28 return account_id.GetUserEmail(); // Migrated | 28 return account_id.GetUserEmail(); // Migrated |
| 29 } | 29 } |
| 30 | 30 |
| 31 } // anonymous namespace | 31 } // anonymous namespace |
| 32 | 32 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 49 return id_ < right.id_; | 49 return id_ < right.id_; |
| 50 } | 50 } |
| 51 | 51 |
| 52 AccountId Identification::GetAccountId() const { | 52 AccountId Identification::GetAccountId() const { |
| 53 const std::vector<AccountId> known_account_ids = | 53 const std::vector<AccountId> known_account_ids = |
| 54 user_manager::known_user::GetKnownAccountIds(); | 54 user_manager::known_user::GetKnownAccountIds(); |
| 55 | 55 |
| 56 // A LOT of tests start with --login_user <user>, and not registing this user | 56 // A LOT of tests start with --login_user <user>, and not registing this user |
| 57 // before. So we might have "known_user" entry without gaia_id. | 57 // before. So we might have "known_user" entry without gaia_id. |
| 58 for (const AccountId& known_id : known_account_ids) { | 58 for (const AccountId& known_id : known_account_ids) { |
| 59 if (!known_id.GetGaiaId().empty() && known_id.GetAccountIdKey() == id_) { | 59 if (known_id.HasAccountIdKey() && known_id.GetAccountIdKey() == id_) { |
| 60 return known_id; | 60 return known_id; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 for (const AccountId& known_id : known_account_ids) { | 64 for (const AccountId& known_id : known_account_ids) { |
| 65 if (known_id.GetUserEmail() == id_) { | 65 if (known_id.GetUserEmail() == id_) { |
| 66 return known_id; | 66 return known_id; |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 return user_manager::known_user::GetAccountId(id_, | 70 return user_manager::known_user::GetAccountId(id_, std::string() /* id */, |
| 71 std::string() /* gaia_id */); | 71 AccountType::UNKNOWN); |
| 72 } | 72 } |
| 73 | 73 |
| 74 KeyDefinition::AuthorizationData::Secret::Secret() : encrypt(false), | 74 KeyDefinition::AuthorizationData::Secret::Secret() : encrypt(false), |
| 75 sign(false), | 75 sign(false), |
| 76 wrapped(false) { | 76 wrapped(false) { |
| 77 } | 77 } |
| 78 | 78 |
| 79 KeyDefinition::AuthorizationData::Secret::Secret( | 79 KeyDefinition::AuthorizationData::Secret::Secret( |
| 80 bool encrypt, | 80 bool encrypt, |
| 81 bool sign, | 81 bool sign, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } // namespace cryptohome | 255 } // namespace cryptohome |
| 256 | 256 |
| 257 namespace BASE_HASH_NAMESPACE { | 257 namespace BASE_HASH_NAMESPACE { |
| 258 | 258 |
| 259 std::size_t hash<cryptohome::Identification>::operator()( | 259 std::size_t hash<cryptohome::Identification>::operator()( |
| 260 const cryptohome::Identification& cryptohome_id) const { | 260 const cryptohome::Identification& cryptohome_id) const { |
| 261 return hash<std::string>()(cryptohome_id.id()); | 261 return hash<std::string>()(cryptohome_id.id()); |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace BASE_HASH_NAMESPACE | 264 } // namespace BASE_HASH_NAMESPACE |
| OLD | NEW |