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

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

Issue 6060005: Show invisible user on login screen if there is space after other user removal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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 | « chrome/browser/chromeos/login/existing_user_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/existing_user_controller.cc
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 83aa156bac4aee5508e2c35cf60175818475b67d..66a9f43b95cceca2358862be6e2c22386bc9fdfb 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -48,7 +48,7 @@ namespace {
// Max number of users we'll show. The true max is the min of this and the
// number of windows that fit on the screen.
-const size_t kMaxUsers = 5;
+const size_t kMaxUsers = 6;
// Used to indicate no user has been selected.
const size_t kNotSelected = -1;
@@ -131,36 +131,40 @@ ExistingUserController::ExistingUserController(
if (delete_scheduled_instance_)
delete_scheduled_instance_->Delete();
- // Caclulate the max number of users from available screen size.
+ // Calculate the max number of users from available screen size.
+ bool show_guest = UserCrosSettingsProvider::cached_allow_guest();
+ bool show_new_user = true;
if (UserCrosSettingsProvider::cached_show_users_on_signin()) {
size_t max_users = kMaxUsers;
int screen_width = background_bounds.width();
if (screen_width > 0) {
- max_users = std::max(static_cast<size_t>(2), std::min(kMaxUsers,
+ max_users = std::max(static_cast<size_t>(3), std::min(kMaxUsers,
whywhat 2010/12/27 14:28:13 Magic constant?
Dmitry Polukhin 2010/12/27 15:09:36 Done.
static_cast<size_t>((screen_width - login::kUserImageSize)
whywhat 2010/12/27 14:28:13 Could you assign this formula to a separate variab
Dmitry Polukhin 2010/12/27 15:09:36 Done.
/ (UserController::kUnselectedSize +
UserController::kPadding))));
}
- size_t visible_users_count = std::min(users.size(), max_users - 1);
+ size_t visible_users_count = std::min(users.size(), max_users -
+ static_cast<int>(show_guest) - static_cast<int>(show_new_user));
for (size_t i = 0; i < users.size(); ++i) {
- if (controllers_.size() == visible_users_count)
- break;
-
// TODO(xiyuan): Clean user profile whose email is not in whitelist.
if (UserCrosSettingsProvider::cached_allow_new_user() ||
UserCrosSettingsProvider::IsEmailInCachedWhitelist(
users[i].email())) {
- controllers_.push_back(new UserController(this, users[i]));
+ UserController* user_controller = new UserController(this, users[i]);
+ if (controllers_.size() < visible_users_count)
+ controllers_.push_back(user_controller);
+ else
+ invisible_controllers_.push_back(user_controller);
}
}
}
- if (!controllers_.empty() && UserCrosSettingsProvider::cached_allow_guest())
+ if (!controllers_.empty() && show_guest)
controllers_.push_back(new UserController(this, true));
- // Add the view representing the new user.
- controllers_.push_back(new UserController(this, false));
+ if (show_new_user)
+ controllers_.push_back(new UserController(this, false));
}
void ExistingUserController::Init() {
@@ -240,6 +244,7 @@ ExistingUserController::~ExistingUserController() {
WmMessageListener::GetInstance()->RemoveObserver(this);
STLDeleteElements(&controllers_);
+ STLDeleteElements(&invisible_controllers_);
}
void ExistingUserController::Delete() {
@@ -373,6 +378,7 @@ void ExistingUserController::RemoveUser(UserController* source) {
UserManager::Get()->RemoveUser(source->user().email());
+ int removed_user_position = source->user_index();
controllers_.erase(controllers_.begin() + source->user_index());
EnableTooltipsIfNeeded(controllers_);
@@ -387,6 +393,35 @@ void ExistingUserController::RemoveUser(UserController* source) {
new RemoveAttempt(source->user().email());
// We need to unmap entry windows, the windows will be unmapped in destructor.
delete source;
+
+ // Nothing to insert.
+ if (invisible_controllers_.empty())
+ return;
+
+ // Insert just before guest or add new user pods if any.
+ int insert_position = new_size;
+ while (insert_position > 0 &&
+ (controllers_[insert_position - 1]->is_new_user() ||
+ controllers_[insert_position - 1]->is_guest()))
+ --insert_position;
+
+ controllers_.insert(controllers_.begin() + insert_position,
+ invisible_controllers_[0]);
+ invisible_controllers_.erase(invisible_controllers_.begin());
+
+ // Update counts for exiting pods.
+ new_size = static_cast<int>(controllers_.size());
+ for (int i = 0; i < new_size; ++i) {
+ if (i != insert_position)
+ controllers_[i]->UpdateUserCount(i, new_size);
+ }
+
+ // And initialize new one that was invisible.
+ controllers_[insert_position]->Init(insert_position, new_size, false);
+
+ EnableTooltipsIfNeeded(controllers_);
+
+ SelectUser(removed_user_position);
}
void ExistingUserController::SelectUser(int index) {
« no previous file with comments | « chrome/browser/chromeos/login/existing_user_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698