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

Unified Diff: chrome/browser/chromeos/login/user_manager_impl.cc

Issue 14756019: Adding new user menu section to the SystemTrayMenu & refactoring of user access (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 7 years, 7 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/chromeos/login/user_manager_impl.cc
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
index 7a4ab3efe9677be769a50e1a951c067bb0316d68..6ca3439af251982dafc03aafe88982101c6bc670 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -221,6 +221,8 @@ UserManagerImpl::~UserManagerImpl() {
}
// These are pointers to the same User instances that were in users_ list.
logged_in_users_.clear();
+ lru_logged_in_users_.clear();
+
delete active_user_;
}
@@ -248,6 +250,17 @@ const UserList& UserManagerImpl::GetLoggedInUsers() const {
return logged_in_users_;
}
+const UserList& UserManagerImpl::GetLRULoggedInUsers() {
+ // If there is no user logged in, we return the active user as the only one.
+ if (lru_logged_in_users_.empty() && active_user_) {
+ temp_single_logged_in_users_.clear();
Nikita (slow) 2013/05/17 17:00:32 Why not use the same lru_logged_in_users_?
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Because as I was looking at the code it appears th
Nikita (slow) 2013/05/17 19:15:47 When does this happen?
Mr4D (OOO till 08-26) 2013/05/17 20:04:43 Okay, let's address that then with the second patc
+ temp_single_logged_in_users_.insert(temp_single_logged_in_users_.begin(),
+ active_user_);
+ return temp_single_logged_in_users_;
+ }
+ return lru_logged_in_users_;
+}
+
void UserManagerImpl::UserLoggedIn(const std::string& email,
const std::string& username_hash,
bool browser_restart) {
@@ -299,6 +312,7 @@ void UserManagerImpl::UserLoggedIn(const std::string& email,
// Place user who just signed in to the top of the logged in users.
logged_in_users_.insert(logged_in_users_.begin(), active_user_);
+ SetLRUUser(active_user_);
NotifyOnLogin();
}
@@ -334,6 +348,9 @@ void UserManagerImpl::SwitchActiveUser(const std::string& email) {
user->set_is_active(true);
active_user_ = user;
+ // Move the user to the front.
+ SetLRUUser(active_user_);
+
NotifyActiveUserHashChanged(active_user_->username_hash());
// TODO(nkostylev): Notify session_manager on active user change.
@@ -1010,6 +1027,7 @@ void UserManagerImpl::RegularUserLoggedIn(const std::string& email,
kRegularUsers);
prefs_users_update->Insert(0, new base::StringValue(email));
users_.insert(users_.begin(), active_user_);
+ SetLRUUser(active_user_);
Nikita (slow) 2013/05/17 17:00:32 You already move this user in UserLoggedIn().
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Following all calls - indeed! Done!
user_image_manager_->UserLoggedIn(email, is_current_user_new_, false);
@@ -1059,6 +1077,7 @@ void UserManagerImpl::LocallyManagedUserLoggedIn(
kRegularUsers);
prefs_users_update->Insert(0, new base::StringValue(username));
users_.insert(users_.begin(), active_user_);
+ SetLRUUser(active_user_);
Nikita (slow) 2013/05/17 17:00:32 Not needed, is handled in UserLoggedIn()
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Ditto.
// Now that user is in the list, save display name.
if (is_current_user_new_) {
@@ -1494,4 +1513,13 @@ void UserManagerImpl::ReadPublicAccounts(base::ListValue* public_accounts) {
}
}
+void UserManagerImpl::SetLRUUser(User* user) {
+ UserList::iterator it = std::find(lru_logged_in_users_.begin(),
+ lru_logged_in_users_.end(),
+ user);
+ if (it != lru_logged_in_users_.end())
+ lru_logged_in_users_.erase(it);
+ lru_logged_in_users_.insert(lru_logged_in_users_.begin(), user);
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698