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

Unified 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: Add cryptohome::Identification() . 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/cryptohome/cryptohome_parameters.cc
diff --git a/chromeos/cryptohome/cryptohome_parameters.cc b/chromeos/cryptohome/cryptohome_parameters.cc
index 8b65a710e471f53b8ba07dbf8719901bd53b1643..89cd651825f3730d08839abbe2cde77af6b8c14b 100644
--- a/chromeos/cryptohome/cryptohome_parameters.cc
+++ b/chromeos/cryptohome/cryptohome_parameters.cc
@@ -8,14 +8,45 @@
#include <stdint.h>
#include "chromeos/dbus/cryptohome/key.pb.h"
+#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/known_user.h"
namespace cryptohome {
+namespace {
-Identification::Identification(const std::string& user_id) : user_id(user_id) {
+// Subsystem name for GaiaId migration status.
+const char kCryptohome[] = "cryptohome";
+
+const std::string GetCryptohomeId(const AccountId& account_id) {
+ // Guest/kiosk/managed/public accounts have empty GaiaId. Default to email.
+ if (account_id.GetGaiaId().empty())
+ return account_id.GetUserEmail(); // Migrated
+
+ if (GetGaiaIdMigrationStatus(account_id))
+ return account_id.GetGaiaIdKey();
+
+ return account_id.GetUserEmail(); // Migrated
+}
+
+} // anonymous namespace
+
+Identification::Identification() {}
+
+Identification::Identification(const AccountId& account_id)
+ : id_(GetCryptohomeId(account_id)) {}
+
+Identification::Identification(const std::string& id) : id_(id) {}
+
+Identification Identification::FromString(const std::string& id) {
+ return Identification(id);
}
bool Identification::operator==(const Identification& other) const {
- return user_id == other.user_id;
+ return id_ == other.id_;
+}
+
+bool Identification::operator<(const Identification& right) const {
+ return id_ < right.id_;
}
KeyDefinition::AuthorizationData::Secret::Secret() : encrypt(false),
@@ -183,4 +214,23 @@ bool MountParameters::operator==(const MountParameters& other) const {
MountParameters::~MountParameters() {
}
+bool GetGaiaIdMigrationStatus(const AccountId& account_id) {
+ return user_manager::known_user::GetGaiaIdMigrationStatus(account_id,
+ kCryptohome);
+}
+
+void SetGaiaIdMigrationStatusDone(const AccountId& account_id) {
+ user_manager::known_user::SetGaiaIdMigrationStatusDone(account_id,
+ kCryptohome);
+}
+
} // namespace cryptohome
+
+namespace BASE_HASH_NAMESPACE {
+
+std::size_t hash<cryptohome::Identification>::operator()(
+ const cryptohome::Identification& cryptohome_id) const {
+ return hash<std::string>()(cryptohome_id.id());
+}
+
+} // namespace BASE_HASH_NAMESPACE

Powered by Google App Engine
This is Rietveld 408576698