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

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 missing files. 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..a36770416ead59c61c07a9d0be6e2beb1135090c 100644
--- a/chromeos/cryptohome/cryptohome_parameters.cc
+++ b/chromeos/cryptohome/cryptohome_parameters.cc
@@ -7,15 +7,37 @@
#include <stddef.h>
#include <stdint.h>
+#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/cryptohome/key.pb.h"
+#include "components/signin/core/account_id/account_id.h"
namespace cryptohome {
+namespace {
-Identification::Identification(const std::string& user_id) : user_id(user_id) {
+const std::string GetCryptohomeId(const AccountId& account_id) {
+ // Guest account has empty GaiaId. Default to email.
xiyuan 2016/02/17 23:14:25 Think this is true all non-Gaia accounts in additi
Alexander Alekseev 2016/02/18 13:45:14 Done.
+ if (account_id.GetGaiaId().empty())
+ return account_id.GetUserEmail(); // Migrated
+
+ const bool is_gaiaid_migration_started =
+ chromeos::switches::IsGaiaIdMigrationStarted();
+ return is_gaiaid_migration_started ? account_id.GetGaiaIdKey()
+ : account_id.GetUserEmail(); // Migrated
+}
+
+} // anonymous namespace
+
+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_;
}
KeyDefinition::AuthorizationData::Secret::Secret() : encrypt(false),

Powered by Google App Engine
This is Rietveld 408576698