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

Unified Diff: components/user_manager/user.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: Fix Win GN build. 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.h ('k') | components/user_manager/user_id.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/user_manager/user.cc
diff --git a/components/user_manager/user.cc b/components/user_manager/user.cc
index defc117308ec1f706098d9a9f2b5d2f069260be3..39ef430d5baef8a8ba9065dbcc384d5ae5c68c92 100644
--- a/components/user_manager/user.cc
+++ b/components/user_manager/user.cc
@@ -9,6 +9,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "chromeos/login/user_names.h"
+#include "components/signin/core/account_id/account_id.h"
#include "components/user_manager/user_image/default_user_images.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -34,10 +35,14 @@ bool User::TypeHasGaiaAccount(UserType user_type) {
user_type == USER_TYPE_CHILD;
}
+const std::string& User::email() const {
+ return account_id_.GetUserEmail();
+}
+
// Also used for regular supervised users.
class RegularUser : public User {
public:
- explicit RegularUser(const std::string& email);
+ explicit RegularUser(const AccountId& account_id);
~RegularUser() override;
// Overridden from User:
@@ -46,7 +51,7 @@ class RegularUser : public User {
void SetIsChild(bool is_child) override;
private:
- bool is_child_;
+ bool is_child_ = false;
DISALLOW_COPY_AND_ASSIGN(RegularUser);
};
@@ -65,7 +70,7 @@ class GuestUser : public User {
class KioskAppUser : public User {
public:
- explicit KioskAppUser(const std::string& app_id);
+ explicit KioskAppUser(const AccountId& kiosk_app_account_id);
~KioskAppUser() override;
// Overridden from User:
@@ -77,7 +82,7 @@ class KioskAppUser : public User {
class SupervisedUser : public User {
public:
- explicit SupervisedUser(const std::string& username);
+ explicit SupervisedUser(const AccountId& account_id);
~SupervisedUser() override;
// Overridden from User:
@@ -90,7 +95,7 @@ class SupervisedUser : public User {
class PublicAccountUser : public User {
public:
- explicit PublicAccountUser(const std::string& email);
+ explicit PublicAccountUser(const AccountId& account_id);
~PublicAccountUser() override;
// Overridden from User:
@@ -118,8 +123,9 @@ const gfx::ImageSkia& User::GetImage() const {
return user_image_.image();
}
-UserID User::GetUserID() const {
- return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email()));
+AccountId User::GetAccountId() const {
+ return AccountId::FromUserEmail(
+ gaia::CanonicalizeEmail(gaia::SanitizeEmail(email())));
}
void User::SetIsChild(bool is_child) {
@@ -144,7 +150,7 @@ std::string User::GetAccountName(bool use_display_email) const {
if (use_display_email && !display_email_.empty())
return GetUserName(display_email_);
else
- return GetUserName(email_);
+ return GetUserName(account_id_.GetUserEmail());
}
bool User::HasDefaultImage() const {
@@ -175,39 +181,27 @@ bool User::is_active() const {
return is_active_;
}
-User* User::CreateRegularUser(const std::string& email) {
- return new RegularUser(email);
+User* User::CreateRegularUser(const AccountId& account_id) {
+ return new RegularUser(account_id);
}
User* User::CreateGuestUser() {
return new GuestUser;
}
-User* User::CreateKioskAppUser(const std::string& kiosk_app_username) {
- return new KioskAppUser(kiosk_app_username);
+User* User::CreateKioskAppUser(const AccountId& kiosk_app_account_id) {
+ return new KioskAppUser(kiosk_app_account_id);
}
-User* User::CreateSupervisedUser(const std::string& username) {
- return new SupervisedUser(username);
+User* User::CreateSupervisedUser(const AccountId& account_id) {
+ return new SupervisedUser(account_id);
}
-User* User::CreatePublicAccountUser(const std::string& email) {
- return new PublicAccountUser(email);
+User* User::CreatePublicAccountUser(const AccountId& account_id) {
+ return new PublicAccountUser(account_id);
}
-User::User(const std::string& email)
- : email_(email),
- oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN),
- force_online_signin_(false),
- image_index_(USER_IMAGE_INVALID),
- image_is_stub_(false),
- image_is_loading_(false),
- can_lock_(false),
- is_logged_in_(false),
- is_active_(false),
- profile_is_created_(false),
- is_affiliated_(false){
-}
+User::User(const AccountId& account_id) : account_id_(account_id) {}
User::~User() {
}
@@ -237,10 +231,9 @@ void User::SetStubImage(const UserImage& stub_user_image,
image_is_loading_ = is_loading;
}
-RegularUser::RegularUser(const std::string& email)
- : User(email), is_child_(false) {
+RegularUser::RegularUser(const AccountId& account_id) : User(account_id) {
set_can_lock(true);
- set_display_email(email);
+ set_display_email(account_id.GetUserEmail());
}
RegularUser::~RegularUser() {
@@ -260,7 +253,7 @@ void RegularUser::SetIsChild(bool is_child) {
is_child_ = is_child;
}
-GuestUser::GuestUser() : User(chromeos::login::kGuestUserName) {
+GuestUser::GuestUser() : User(chromeos::login::GuestAccountId()) {
set_display_email(std::string());
}
@@ -271,9 +264,9 @@ UserType GuestUser::GetType() const {
return user_manager::USER_TYPE_GUEST;
}
-KioskAppUser::KioskAppUser(const std::string& kiosk_app_username)
- : User(kiosk_app_username) {
- set_display_email(kiosk_app_username);
+KioskAppUser::KioskAppUser(const AccountId& kiosk_app_account_id)
+ : User(kiosk_app_account_id) {
+ set_display_email(kiosk_app_account_id.GetUserEmail());
}
KioskAppUser::~KioskAppUser() {
@@ -283,7 +276,7 @@ UserType KioskAppUser::GetType() const {
return user_manager::USER_TYPE_KIOSK_APP;
}
-SupervisedUser::SupervisedUser(const std::string& username) : User(username) {
+SupervisedUser::SupervisedUser(const AccountId& account_id) : User(account_id) {
set_can_lock(true);
}
@@ -298,8 +291,8 @@ std::string SupervisedUser::display_email() const {
return base::UTF16ToUTF8(display_name());
}
-PublicAccountUser::PublicAccountUser(const std::string& email) : User(email) {
-}
+PublicAccountUser::PublicAccountUser(const AccountId& account_id)
+ : User(account_id) {}
PublicAccountUser::~PublicAccountUser() {
}
« no previous file with comments | « components/user_manager/user.h ('k') | components/user_manager/user_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698