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

Unified Diff: components/user_manager/user_manager_base.cc

Issue 1455263002: Reland of This CL replaces e-mail with AccountId on user selection screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « components/user_manager/user_manager_base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/user_manager/user_manager_base.cc
diff --git a/components/user_manager/user_manager_base.cc b/components/user_manager/user_manager_base.cc
index 81a68ffa244db2abf0d2c52e61e5eaeb26075dea..f51d9b14f18f5538ce0b4bc0a4c265610a32b278 100644
--- a/components/user_manager/user_manager_base.cc
+++ b/components/user_manager/user_manager_base.cc
@@ -120,13 +120,13 @@
const base::DictionaryValue& dict) {
std::string value;
+ // TODO(alemate): update code once user id is really a struct.
+ bool has_gaia_id = dict.GetString(kGAIAIdKey, &value);
+ if (has_gaia_id && account_id.GetGaiaId() == value)
+ return true;
+
bool has_email = dict.GetString(kCanonicalEmail, &value);
if (has_email && account_id.GetUserEmail() == value)
- return true;
-
- // TODO(antrim): update code once user id is really a struct.
- bool has_gaia_id = dict.GetString(kGAIAIdKey, &value);
- if (has_gaia_id && account_id.GetUserEmail() == value)
return true;
return false;
@@ -582,7 +582,6 @@
UpdateUserAccountLocale(account_id, account_data.locale());
}
-// static
void UserManagerBase::ParseUserList(const base::ListValue& users_list,
const std::set<AccountId>& existing_users,
std::vector<AccountId>* users_vector,
@@ -595,7 +594,21 @@
LOG(ERROR) << "Corrupt entry in user list at index " << i << ".";
continue;
}
- const AccountId account_id(AccountId::FromUserEmail(email));
+
+ const AccountId partial_account_id = AccountId::FromUserEmail(email);
+ AccountId account_id = EmptyAccountId();
+
+ const bool lookup_result =
+ GetKnownUserAccountId(partial_account_id, &account_id);
+ // TODO(alemate):
+ // DCHECK(lookup_result) << "KnownUser lookup falied for '" << email << "'";
+ // (tests do not initialize KnownUserData)
+
+ if (!lookup_result) {
+ account_id = partial_account_id;
+ LOG(WARNING) << "KnownUser lookup falied for '" << email << "'";
+ }
+
if (existing_users.find(account_id) != existing_users.end() ||
!users_set->insert(account_id).second) {
LOG(ERROR) << "Duplicate user: " << email;
@@ -849,6 +862,7 @@
ChangeUserChildStatus(user, true /* is child */);
}
}
+ const AccountId account_id = user->GetAccountId();
user->set_oauth_token_status(LoadUserOAuthStatus(*it));
user->set_force_online_signin(LoadForceOnlineSignin(*it));
user->set_using_saml(FindUsingSAML(*it));
@@ -1152,15 +1166,25 @@
bool UserManagerBase::GetKnownUserAccountId(
const AccountId& authenticated_account_id,
AccountId* out_account_id) {
- DCHECK(!authenticated_account_id.GetGaiaId().empty());
- std::string canonical_email;
- if (!GetKnownUserStringPref(
- AccountId::FromGaiaId(authenticated_account_id.GetGaiaId()),
- kCanonicalEmail, &canonical_email))
+ if (!authenticated_account_id.GetGaiaId().empty()) {
+ std::string canonical_email;
+ if (!GetKnownUserStringPref(
+ AccountId::FromGaiaId(authenticated_account_id.GetGaiaId()),
+ kCanonicalEmail, &canonical_email)) {
+ return false;
+ }
+
+ *out_account_id = AccountId::FromUserEmailGaiaId(
+ canonical_email, authenticated_account_id.GetGaiaId());
+ return true;
+ }
+ DCHECK(!authenticated_account_id.GetUserEmail().empty());
+ std::string gaia_id;
+ if (!GetKnownUserStringPref(authenticated_account_id, kGAIAIdKey, &gaia_id))
return false;
- *out_account_id = authenticated_account_id;
- out_account_id->SetUserEmail(canonical_email);
+ *out_account_id = AccountId::FromUserEmailGaiaId(
+ authenticated_account_id.GetUserEmail(), gaia_id);
return true;
}
« no previous file with comments | « components/user_manager/user_manager_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698