summaryrefslogtreecommitdiffstats
path: root/components/user_manager
diff options
context:
space:
mode:
Diffstat (limited to 'components/user_manager')
-rw-r--r--components/user_manager/empty_user_info.cc2
-rw-r--r--components/user_manager/empty_user_info.h2
-rw-r--r--components/user_manager/user.cc5
-rw-r--r--components/user_manager/user.h2
-rw-r--r--components/user_manager/user_info.h2
-rw-r--r--components/user_manager/user_info_impl.cc10
-rw-r--r--components/user_manager/user_info_impl.h4
-rw-r--r--components/user_manager/user_manager_base.cc52
-rw-r--r--components/user_manager/user_manager_base.h10
9 files changed, 57 insertions, 32 deletions
diff --git a/components/user_manager/empty_user_info.cc b/components/user_manager/empty_user_info.cc
index 08d4a19..07b4087 100644
--- a/components/user_manager/empty_user_info.cc
+++ b/components/user_manager/empty_user_info.cc
@@ -31,7 +31,7 @@ std::string EmptyUserInfo::GetEmail() const {
return std::string();
}
-AccountId EmptyUserInfo::GetAccountId() const {
+const AccountId& EmptyUserInfo::GetAccountId() const {
NOTIMPLEMENTED();
return EmptyAccountId();
}
diff --git a/components/user_manager/empty_user_info.h b/components/user_manager/empty_user_info.h
index 76c0d16..5fb41c9 100644
--- a/components/user_manager/empty_user_info.h
+++ b/components/user_manager/empty_user_info.h
@@ -25,7 +25,7 @@ class USER_MANAGER_EXPORT EmptyUserInfo : public UserInfo {
base::string16 GetDisplayName() const override;
base::string16 GetGivenName() const override;
std::string GetEmail() const override;
- AccountId GetAccountId() const override;
+ const AccountId& GetAccountId() const override;
const gfx::ImageSkia& GetImage() const override;
private:
diff --git a/components/user_manager/user.cc b/components/user_manager/user.cc
index 39ef430..3ead416 100644
--- a/components/user_manager/user.cc
+++ b/components/user_manager/user.cc
@@ -123,9 +123,8 @@ const gfx::ImageSkia& User::GetImage() const {
return user_image_.image();
}
-AccountId User::GetAccountId() const {
- return AccountId::FromUserEmail(
- gaia::CanonicalizeEmail(gaia::SanitizeEmail(email())));
+const AccountId& User::GetAccountId() const {
+ return account_id_;
}
void User::SetIsChild(bool is_child) {
diff --git a/components/user_manager/user.h b/components/user_manager/user.h
index fe0899e..71d7016 100644
--- a/components/user_manager/user.h
+++ b/components/user_manager/user.h
@@ -97,7 +97,7 @@ class USER_MANAGER_EXPORT User : public UserInfo {
base::string16 GetDisplayName() const override;
base::string16 GetGivenName() const override;
const gfx::ImageSkia& GetImage() const override;
- AccountId GetAccountId() const override;
+ const AccountId& GetAccountId() const override;
// Allows managing child status of the user. Used for RegularUser.
virtual void SetIsChild(bool is_child);
diff --git a/components/user_manager/user_info.h b/components/user_manager/user_info.h
index 2f0cf19..6a692d6 100644
--- a/components/user_manager/user_info.h
+++ b/components/user_manager/user_info.h
@@ -36,7 +36,7 @@ class USER_MANAGER_EXPORT UserInfo {
virtual std::string GetEmail() const = 0;
// Returns AccountId for the user.
- virtual AccountId GetAccountId() const = 0;
+ virtual const AccountId& GetAccountId() const = 0;
// Gets the avatar image for the user.
virtual const gfx::ImageSkia& GetImage() const = 0;
diff --git a/components/user_manager/user_info_impl.cc b/components/user_manager/user_info_impl.cc
index cf6d2ad..afb2e9d 100644
--- a/components/user_manager/user_info_impl.cc
+++ b/components/user_manager/user_info_impl.cc
@@ -10,8 +10,8 @@
namespace user_manager {
-UserInfoImpl::UserInfoImpl() {
-}
+UserInfoImpl::UserInfoImpl()
+ : account_id_(AccountId::FromUserEmail("stub-user@domain.com")) {}
UserInfoImpl::~UserInfoImpl() {
}
@@ -25,11 +25,11 @@ base::string16 UserInfoImpl::GetGivenName() const {
}
std::string UserInfoImpl::GetEmail() const {
- return "stub-user@domain.com";
+ return account_id_.GetUserEmail();
}
-AccountId UserInfoImpl::GetAccountId() const {
- return AccountId::FromUserEmail(GetEmail());
+const AccountId& UserInfoImpl::GetAccountId() const {
+ return account_id_;
}
const gfx::ImageSkia& UserInfoImpl::GetImage() const {
diff --git a/components/user_manager/user_info_impl.h b/components/user_manager/user_info_impl.h
index 4922e36..d2733eb 100644
--- a/components/user_manager/user_info_impl.h
+++ b/components/user_manager/user_info_impl.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/strings/string16.h"
+#include "components/signin/core/account_id/account_id.h"
#include "components/user_manager/user_info.h"
#include "components/user_manager/user_manager_export.h"
#include "ui/gfx/image/image_skia.h"
@@ -24,10 +25,11 @@ class USER_MANAGER_EXPORT UserInfoImpl : public UserInfo {
base::string16 GetDisplayName() const override;
base::string16 GetGivenName() const override;
std::string GetEmail() const override;
- AccountId GetAccountId() const override;
+ const AccountId& GetAccountId() const override;
const gfx::ImageSkia& GetImage() const override;
private:
+ const AccountId account_id_;
gfx::ImageSkia user_image_;
DISALLOW_COPY_AND_ASSIGN(UserInfoImpl);
diff --git a/components/user_manager/user_manager_base.cc b/components/user_manager/user_manager_base.cc
index 81a68ff..f51d9b1 100644
--- a/components/user_manager/user_manager_base.cc
+++ b/components/user_manager/user_manager_base.cc
@@ -120,13 +120,13 @@ bool UserMatches(const AccountId& account_id,
const base::DictionaryValue& dict) {
std::string value;
- bool has_email = dict.GetString(kCanonicalEmail, &value);
- if (has_email && account_id.GetUserEmail() == 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;
- // 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)
+ bool has_email = dict.GetString(kCanonicalEmail, &value);
+ if (has_email && account_id.GetUserEmail() == value)
return true;
return false;
@@ -582,7 +582,6 @@ void UserManagerBase::UpdateUserAccountData(
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 @@ void UserManagerBase::ParseUserList(const base::ListValue& users_list,
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 @@ void UserManagerBase::EnsureUsersLoaded() {
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 @@ void UserManagerBase::SetKnownUserIntegerPref(const AccountId& account_id,
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;
}
diff --git a/components/user_manager/user_manager_base.h b/components/user_manager/user_manager_base.h
index ead7d44..dd46c5d 100644
--- a/components/user_manager/user_manager_base.h
+++ b/components/user_manager/user_manager_base.h
@@ -154,13 +154,13 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
// TODO(xiyuan): Figure out a better way to expose this info.
virtual bool HasPendingBootstrap(const AccountId& account_id) const;
- // Helper function that copies users from |users_list| to |users_vector| and
+ // Helper function that converts users from |users_list| to |users_vector| and
// |users_set|. Duplicates and users already present in |existing_users| are
// skipped.
- static void ParseUserList(const base::ListValue& users_list,
- const std::set<AccountId>& existing_users,
- std::vector<AccountId>* users_vector,
- std::set<AccountId>* users_set);
+ void ParseUserList(const base::ListValue& users_list,
+ const std::set<AccountId>& existing_users,
+ std::vector<AccountId>* users_vector,
+ std::set<AccountId>* users_set);
// Returns true if trusted device policies have successfully been retrieved
// and ephemeral users are enabled.