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), |