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

Unified Diff: components/signin/core/account_id/account_id.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: Fixed unit tests. 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
« no previous file with comments | « chromeos/tpm/tpm_token_info_getter_unittest.cc ('k') | components/user_manager/known_user.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/signin/core/account_id/account_id.cc
diff --git a/components/signin/core/account_id/account_id.cc b/components/signin/core/account_id/account_id.cc
index 45dee4d0796e5ff99c6bafc34ddfa1af5cab00a8..c2a8a39c1a6a563d3f09c48504df60c5396ff4c7 100644
--- a/components/signin/core/account_id/account_id.cc
+++ b/components/signin/core/account_id/account_id.cc
@@ -9,6 +9,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/singleton.h"
+#include "base/strings/string_util.h"
#include "base/values.h"
#include "google_apis/gaia/gaia_auth_util.h"
@@ -49,6 +50,12 @@ AccountId::AccountId() {}
AccountId::AccountId(const std::string& gaia_id, const std::string& user_email)
: gaia_id_(gaia_id), user_email_(user_email) {
+ // Fail if e-mail looks similar to GaiaIdKey.
+ LOG_ASSERT(!base::StartsWith(user_email, kKeyGaiaIdPrefix,
+ base::CompareCase::SENSITIVE) ||
+ user_email.find('@') != std::string::npos)
+ << "Bad e-mail: '" << user_email << "' with gaia_id='" << gaia_id << "'";
+
// TODO(alemate): DCHECK(!email.empty());
// TODO(alemate): check gaia_id is not empty once it is required.
}
@@ -98,7 +105,14 @@ const std::string& AccountId::GetUserEmail() const {
}
const std::string AccountId::GetGaiaIdKey() const {
+#ifdef NDEBUG
+ if (gaia_id_.empty())
+ LOG(FATAL) << "GetGaiaIdKey(): no gaia id for " << Serialize();
+
+#else
CHECK(!gaia_id_.empty());
+#endif
+
return std::string(kKeyGaiaIdPrefix) + gaia_id_;
}
« no previous file with comments | « chromeos/tpm/tpm_token_info_getter_unittest.cc ('k') | components/user_manager/known_user.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698