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

Unified Diff: chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Rebased. Created 5 years, 2 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: chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
index 224dbdac9ef9a04b4d59322d9d61b11b92faa442..23db972ddbc9f5587f8cfbadadb1b558496ccb7b 100644
--- a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
@@ -428,27 +428,29 @@ void GaiaScreenHandler::HandleWebviewLoadAborted(
UpdateState(error_reason);
}
-std::string GaiaScreenHandler::GetCanonicalEmail(
+AccountId GaiaScreenHandler::GetAccountId(
const std::string& authenticated_email,
const std::string& gaia_id) const {
const std::string sanitized_email = gaia::SanitizeEmail(authenticated_email);
const std::string canonicalized_email =
gaia::CanonicalizeEmail(sanitized_email);
+ const AccountId authenticated_id(
+ AccountId::FromUserEmailGaiaId(canonicalized_email, gaia_id));
+
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
- if (user_manager && !user_manager->IsKnownUser(canonicalized_email)) {
- std::string old_canonical_email;
- if (user_manager->GetKnownUserCanonicalEmail(gaia_id,
- &old_canonical_email)) {
- if (old_canonical_email != canonicalized_email) {
- LOG(WARNING) << "Existing user '" << old_canonical_email
+ if (user_manager && !user_manager->IsKnownUser(authenticated_id)) {
stevenjb 2015/10/22 17:52:36 nit: invert and early exit
Alexander Alekseev 2015/10/23 09:11:23 Done.
+ AccountId old_account_id(EmptyAccountId());
stevenjb 2015/10/22 17:52:36 It looks like this ship has sailed, but it is a bi
Alexander Alekseev 2015/10/23 09:11:23 The reason for this is to make EmptyAccountId() lo
+ if (user_manager->GetKnownUserAccountId(authenticated_id,
+ &old_account_id)) {
stevenjb 2015/10/22 17:52:36 nit: invert and early exit (same below, maybe comb
Alexander Alekseev 2015/10/23 09:11:23 Done.
+ if (old_account_id.GetUserEmail() != canonicalized_email) {
+ LOG(WARNING) << "Existing user '" << old_account_id.GetUserEmail()
<< "' authenticated by alias '" << sanitized_email << "'.";
- return old_canonical_email;
+ return old_account_id;
}
}
}
- // For compatibility reasons, sanitized email is used.
- return sanitized_email;
+ return authenticated_id;
}
void GaiaScreenHandler::HandleCompleteAuthentication(
@@ -466,8 +468,8 @@ void GaiaScreenHandler::HandleCompleteAuthentication(
const std::string sanitized_email = gaia::SanitizeEmail(email);
Delegate()->SetDisplayEmail(sanitized_email);
- const std::string canonical_email = GetCanonicalEmail(email, gaia_id);
- UserContext user_context(canonical_email);
+ const AccountId account_id(GetAccountId(email, gaia_id));
+ UserContext user_context(account_id);
achuithb 2015/10/23 00:08:51 Just inline invocation to GetAccountId(email, gaia
Alexander Alekseev 2015/10/23 09:11:23 Done.
user_context.SetGaiaID(gaia_id);
user_context.SetKey(Key(password));
user_context.SetAuthCode(auth_code);
@@ -500,7 +502,7 @@ void GaiaScreenHandler::HandleCompleteLogin(const std::string& gaia_id,
// Consumer management enrollment is in progress.
const std::string owner_email =
- user_manager::UserManager::Get()->GetOwnerEmail();
+ user_manager::UserManager::Get()->GetOwnerId().GetUserEmail();
if (typed_email != owner_email) {
// Show Gaia sign-in screen again, since we only allow the owner to sign
// in.
@@ -588,8 +590,8 @@ void GaiaScreenHandler::DoCompleteLogin(const std::string& gaia_id,
DCHECK(!gaia_id.empty());
const std::string sanitized_email = gaia::SanitizeEmail(typed_email);
Delegate()->SetDisplayEmail(sanitized_email);
- const std::string canonical_email = GetCanonicalEmail(typed_email, gaia_id);
- UserContext user_context(canonical_email);
+ const AccountId account_id(GetAccountId(typed_email, gaia_id));
+ UserContext user_context(account_id);
achuithb 2015/10/23 00:08:51 inline GetAccountId
Alexander Alekseev 2015/10/23 09:11:23 Done.
user_context.SetGaiaID(gaia_id);
user_context.SetKey(Key(password));
user_context.SetAuthFlow(using_saml
@@ -748,7 +750,7 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() {
std::vector<std::string> input_methods =
imm->GetInputMethodUtil()->GetHardwareLoginInputMethodIds();
const std::string owner_im = SigninScreenHandler::GetUserLRUInputMethod(
- user_manager::UserManager::Get()->GetOwnerEmail());
+ user_manager::UserManager::Get()->GetOwnerId().GetUserEmail());
const std::string system_im = g_browser_process->local_state()->GetString(
language_prefs::kPreferredKeyboardLayout);
@@ -836,7 +838,8 @@ void GaiaScreenHandler::LoadAuthExtension(bool force,
context.is_enrolling_consumer_management = is_enrolling_consumer_management_;
std::string gaia_id;
- if (user_manager::UserManager::Get()->FindGaiaID(context.email, &gaia_id))
+ if (user_manager::UserManager::Get()->FindGaiaID(
+ AccountId::FromUserEmail(context.email), &gaia_id))
context.gaia_id = gaia_id;
if (Delegate()) {
@@ -846,7 +849,7 @@ void GaiaScreenHandler::LoadAuthExtension(bool force,
if (!context.email.empty()) {
context.gaps_cookie =
user_manager::UserManager::Get()->GetKnownUserGAPSCookie(
- gaia::CanonicalizeEmail(context.email));
+ AccountId::FromUserEmail(gaia::CanonicalizeEmail(context.email)));
}
populated_email_.clear();

Powered by Google App Engine
This is Rietveld 408576698