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

Unified Diff: components/user_manager/fake_user_manager.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: Update after review. 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: components/user_manager/fake_user_manager.cc
diff --git a/components/user_manager/fake_user_manager.cc b/components/user_manager/fake_user_manager.cc
index 39f63f1eae4493c0525b1378d7ec5ffa204caa24..e3807593bba5fa0207a2375002f0eb788c1429d8 100644
--- a/components/user_manager/fake_user_manager.cc
+++ b/components/user_manager/fake_user_manager.cc
@@ -31,28 +31,30 @@ namespace user_manager {
FakeUserManager::FakeUserManager()
: UserManagerBase(new FakeTaskRunner(), new FakeTaskRunner()),
- primary_user_(NULL),
- owner_email_(std::string()) {
-}
+ primary_user_(NULL) {}
achuithb 2015/10/28 23:11:46 switch to nullptr for this file as well, since the
Alexander Alekseev 2015/10/29 02:00:42 Done.
FakeUserManager::~FakeUserManager() {
}
-const user_manager::User* FakeUserManager::AddUser(const std::string& email) {
- return AddUserWithAffiliation(email, false);
+const user_manager::User* FakeUserManager::AddUser(
+ const AccountId& account_id) {
+ return AddUserWithAffiliation(account_id, false);
}
const user_manager::User* FakeUserManager::AddUserWithAffiliation(
- const std::string& email, bool is_affiliated) {
- user_manager::User* user = user_manager::User::CreateRegularUser(email);
+ const AccountId& account_id,
+ bool is_affiliated) {
+ user_manager::User* user = user_manager::User::CreateRegularUser(account_id);
user->set_affiliation(is_affiliated);
users_.push_back(user);
return user;
}
-void FakeUserManager::RemoveUserFromList(const std::string& email) {
+void FakeUserManager::RemoveUserFromList(const AccountId& account_id) {
user_manager::UserList::iterator it = users_.begin();
- while (it != users_.end() && (*it)->email() != email)
+ // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId is
+ // passed. crbug.com/546876
+ while (it != users_.end() && (*it)->GetEmail() != account_id.GetUserEmail())
++it;
if (it != users_.end()) {
delete *it;
@@ -79,7 +81,7 @@ const user_manager::UserList& FakeUserManager::GetLoggedInUsers() const {
return logged_in_users_;
}
-void FakeUserManager::UserLoggedIn(const std::string& email,
+void FakeUserManager::UserLoggedIn(const AccountId& account_id,
const std::string& username_hash,
bool browser_restart) {
for (user_manager::UserList::const_iterator it = users_.begin();
@@ -98,10 +100,13 @@ void FakeUserManager::UserLoggedIn(const std::string& email,
user_manager::User* FakeUserManager::GetActiveUserInternal() const {
if (users_.size()) {
achuithb 2015/10/28 23:11:46 if (!users_.empty()) since you are here
Alexander Alekseev 2015/10/29 02:00:42 Done.
- if (!active_user_id_.empty()) {
+ if (active_account_id_.is_valid()) {
for (user_manager::UserList::const_iterator it = users_.begin();
it != users_.end(); ++it) {
- if ((*it)->email() == active_user_id_)
+ // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId
+ // is
+ // passed. crbug.com/546876
+ if ((*it)->GetEmail() == active_account_id_.GetUserEmail())
return *it;
}
}
@@ -118,14 +123,15 @@ user_manager::User* FakeUserManager::GetActiveUser() {
return GetActiveUserInternal();
}
-void FakeUserManager::SwitchActiveUser(const std::string& email) {
-}
+void FakeUserManager::SwitchActiveUser(const AccountId& account_id) {}
-void FakeUserManager::SaveUserDisplayName(const std::string& username,
+void FakeUserManager::SaveUserDisplayName(const AccountId& account_id,
const base::string16& display_name) {
for (user_manager::UserList::iterator it = users_.begin(); it != users_.end();
++it) {
- if ((*it)->email() == username) {
+ // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId is
+ // passed. crbug.com/546876
+ if ((*it)->GetEmail() == account_id.GetUserEmail()) {
(*it)->set_display_name(display_name);
return;
}
@@ -140,27 +146,29 @@ user_manager::UserList FakeUserManager::GetUnlockUsers() const {
return users_;
}
-const std::string& FakeUserManager::GetOwnerEmail() const {
- return owner_email_;
+const AccountId& FakeUserManager::GetOwnerAccountId() const {
+ return owner_account_id_;
}
-bool FakeUserManager::IsKnownUser(const std::string& email) const {
+bool FakeUserManager::IsKnownUser(const AccountId& account_id) const {
return true;
}
const user_manager::User* FakeUserManager::FindUser(
- const std::string& email) const {
+ const AccountId& account_id) const {
const user_manager::UserList& users = GetUsers();
for (user_manager::UserList::const_iterator it = users.begin();
it != users.end(); ++it) {
- if ((*it)->email() == email)
+ // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId is
+ // passed. crbug.com/546876
+ if ((*it)->GetEmail() == account_id.GetUserEmail())
return *it;
}
return NULL;
}
user_manager::User* FakeUserManager::FindUserAndModify(
- const std::string& email) {
+ const AccountId& account_id) {
return NULL;
}
@@ -177,12 +185,12 @@ const user_manager::User* FakeUserManager::GetPrimaryUser() const {
}
base::string16 FakeUserManager::GetUserDisplayName(
- const std::string& username) const {
+ const AccountId& account_id) const {
return base::string16();
}
std::string FakeUserManager::GetUserDisplayEmail(
- const std::string& username) const {
+ const AccountId& account_id) const {
return std::string();
}
@@ -238,7 +246,7 @@ bool FakeUserManager::IsSessionStarted() const {
}
bool FakeUserManager::IsUserNonCryptohomeDataEphemeral(
- const std::string& email) const {
+ const AccountId& account_id) const {
return false;
}
@@ -263,16 +271,16 @@ bool FakeUserManager::IsEnterpriseManaged() const {
return false;
}
-bool FakeUserManager::IsDemoApp(const std::string& user_id) const {
+bool FakeUserManager::IsDemoApp(const AccountId& account_id) const {
return false;
}
-bool FakeUserManager::IsKioskApp(const std::string& user_id) const {
+bool FakeUserManager::IsKioskApp(const AccountId& account_id) const {
return false;
}
bool FakeUserManager::IsPublicAccountMarkedForRemoval(
- const std::string& user_id) const {
+ const AccountId& account_id) const {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698