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

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

Issue 1693383003: ChromeOS cryptohome should be able to use gaia id as user identifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better condition in LOG_ASSERT in AccountId. Created 4 years, 10 months 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"
12 #include "components/user_manager/known_user.h"
11 13
12 namespace cryptohome { 14 namespace cryptohome {
15 namespace {
13 16
14 Identification::Identification(const std::string& user_id) : user_id(user_id) { 17 // Subsystem name for GaiaId migration status.
18 const char kCryptohome[] = "cryptohome";
19
20 const std::string GetCryptohomeId(const AccountId& account_id) {
21 // Guest/kiosk/managed/public accounts have empty GaiaId. Default to email.
22 if (account_id.GetGaiaId().empty())
23 return account_id.GetUserEmail(); // Migrated
24
25 if (GetGaiaIdMigrationStatus(account_id))
26 return account_id.GetGaiaIdKey();
27
28 return account_id.GetUserEmail(); // Migrated
29 }
30
31 } // anonymous namespace
32
33 Identification::Identification() {}
34
35 Identification::Identification(const AccountId& account_id)
36 : id_(GetCryptohomeId(account_id)) {}
37
38 Identification::Identification(const std::string& id) : id_(id) {}
39
40 Identification Identification::FromString(const std::string& id) {
41 return Identification(id);
15 } 42 }
16 43
17 bool Identification::operator==(const Identification& other) const { 44 bool Identification::operator==(const Identification& other) const {
18 return user_id == other.user_id; 45 return id_ == other.id_;
46 }
47
48 bool Identification::operator<(const Identification& right) const {
49 return id_ < right.id_;
19 } 50 }
20 51
21 KeyDefinition::AuthorizationData::Secret::Secret() : encrypt(false), 52 KeyDefinition::AuthorizationData::Secret::Secret() : encrypt(false),
22 sign(false), 53 sign(false),
23 wrapped(false) { 54 wrapped(false) {
24 } 55 }
25 56
26 KeyDefinition::AuthorizationData::Secret::Secret( 57 KeyDefinition::AuthorizationData::Secret::Secret(
27 bool encrypt, 58 bool encrypt,
28 bool sign, 59 bool sign,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 MountParameters::MountParameters(bool ephemeral) : ephemeral(ephemeral) { 207 MountParameters::MountParameters(bool ephemeral) : ephemeral(ephemeral) {
177 } 208 }
178 209
179 bool MountParameters::operator==(const MountParameters& other) const { 210 bool MountParameters::operator==(const MountParameters& other) const {
180 return ephemeral == other.ephemeral && create_keys == other.create_keys; 211 return ephemeral == other.ephemeral && create_keys == other.create_keys;
181 } 212 }
182 213
183 MountParameters::~MountParameters() { 214 MountParameters::~MountParameters() {
184 } 215 }
185 216
217 bool GetGaiaIdMigrationStatus(const AccountId& account_id) {
218 return user_manager::known_user::GetGaiaIdMigrationStatus(account_id,
219 kCryptohome);
220 }
221
222 void SetGaiaIdMigrationStatusDone(const AccountId& account_id) {
223 user_manager::known_user::SetGaiaIdMigrationStatusDone(account_id,
224 kCryptohome);
225 }
226
186 } // namespace cryptohome 227 } // namespace cryptohome
228
229 namespace BASE_HASH_NAMESPACE {
230
231 std::size_t hash<cryptohome::Identification>::operator()(
232 const cryptohome::Identification& cryptohome_id) const {
233 return hash<std::string>()(cryptohome_id.id());
234 }
235
236 } // namespace BASE_HASH_NAMESPACE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698