Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(869)

Side by Side Diff: chromeos/cryptohome/cryptohome_parameters.cc

Issue 2529103002: Add account_type into AccountId (Closed)
Patch Set: more tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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::GOOGLE &&
23 !account_id.HasAccountIdKey())
23 return account_id.GetUserEmail(); // Migrated 24 return account_id.GetUserEmail(); // Migrated
24 25
25 if (GetGaiaIdMigrationStatus(account_id)) 26 if (GetGaiaIdMigrationStatus(account_id))
26 return account_id.GetAccountIdKey(); 27 return account_id.GetAccountIdKey();
27 28
28 return account_id.GetUserEmail(); // Migrated 29 return account_id.GetUserEmail(); // Migrated
29 } 30 }
30 31
31 } // anonymous namespace 32 } // anonymous namespace
32 33
(...skipping 16 matching lines...) Expand all
49 return id_ < right.id_; 50 return id_ < right.id_;
50 } 51 }
51 52
52 AccountId Identification::GetAccountId() const { 53 AccountId Identification::GetAccountId() const {
53 const std::vector<AccountId> known_account_ids = 54 const std::vector<AccountId> known_account_ids =
54 user_manager::known_user::GetKnownAccountIds(); 55 user_manager::known_user::GetKnownAccountIds();
55 56
56 // A LOT of tests start with --login_user <user>, and not registing this user 57 // 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. 58 // before. So we might have "known_user" entry without gaia_id.
58 for (const AccountId& known_id : known_account_ids) { 59 for (const AccountId& known_id : known_account_ids) {
59 if (!known_id.GetGaiaId().empty() && known_id.GetAccountIdKey() == id_) { 60 if (known_id.HasAccountIdKey() && known_id.GetAccountIdKey() == id_) {
60 return known_id; 61 return known_id;
61 } 62 }
62 } 63 }
63 64
64 for (const AccountId& known_id : known_account_ids) { 65 for (const AccountId& known_id : known_account_ids) {
65 if (known_id.GetUserEmail() == id_) { 66 if (known_id.GetUserEmail() == id_) {
66 return known_id; 67 return known_id;
67 } 68 }
68 } 69 }
69 70
70 return user_manager::known_user::GetAccountId(id_, 71 return user_manager::known_user::GetAccountId(id_, std::string() /* id */,
71 std::string() /* gaia_id */); 72 AccountType::UNKNOWN);
72 } 73 }
73 74
74 KeyDefinition::AuthorizationData::Secret::Secret() : encrypt(false), 75 KeyDefinition::AuthorizationData::Secret::Secret() : encrypt(false),
75 sign(false), 76 sign(false),
76 wrapped(false) { 77 wrapped(false) {
77 } 78 }
78 79
79 KeyDefinition::AuthorizationData::Secret::Secret( 80 KeyDefinition::AuthorizationData::Secret::Secret(
80 bool encrypt, 81 bool encrypt,
81 bool sign, 82 bool sign,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } // namespace cryptohome 256 } // namespace cryptohome
256 257
257 namespace BASE_HASH_NAMESPACE { 258 namespace BASE_HASH_NAMESPACE {
258 259
259 std::size_t hash<cryptohome::Identification>::operator()( 260 std::size_t hash<cryptohome::Identification>::operator()(
260 const cryptohome::Identification& cryptohome_id) const { 261 const cryptohome::Identification& cryptohome_id) const {
261 return hash<std::string>()(cryptohome_id.id()); 262 return hash<std::string>()(cryptohome_id.id());
262 } 263 }
263 264
264 } // namespace BASE_HASH_NAMESPACE 265 } // namespace BASE_HASH_NAMESPACE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698