| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 5 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 bool show_tooltip = controllers[i]->is_new_user() || | 110 bool show_tooltip = controllers[i]->is_new_user() || |
| 111 controllers[i]->is_guest() || | 111 controllers[i]->is_guest() || |
| 112 visible_display_names[display_name] > 1; | 112 visible_display_names[display_name] > 1; |
| 113 controllers[i]->EnableNameTooltip(show_tooltip); | 113 controllers[i]->EnableNameTooltip(show_tooltip); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace | 117 } // namespace |
| 118 | 118 |
| 119 ExistingUserController* | 119 ExistingUserController* |
| 120 ExistingUserController::delete_scheduled_instance_ = NULL; | 120 ExistingUserController::current_controller_ = NULL; |
| 121 | 121 |
| 122 // TODO(xiyuan): Wait for the cached settings update before using them. | 122 // TODO(xiyuan): Wait for the cached settings update before using them. |
| 123 ExistingUserController::ExistingUserController( | 123 ExistingUserController::ExistingUserController( |
| 124 const std::vector<UserManager::User>& users, | 124 const std::vector<UserManager::User>& users, |
| 125 const gfx::Rect& background_bounds) | 125 const gfx::Rect& background_bounds) |
| 126 : background_bounds_(background_bounds), | 126 : background_bounds_(background_bounds), |
| 127 background_window_(NULL), | 127 background_window_(NULL), |
| 128 background_view_(NULL), | 128 background_view_(NULL), |
| 129 selected_view_index_(kNotSelected), | 129 selected_view_index_(kNotSelected), |
| 130 num_login_attempts_(0), | 130 num_login_attempts_(0), |
| 131 bubble_(NULL), | 131 bubble_(NULL), |
| 132 user_settings_(new UserCrosSettingsProvider), | 132 user_settings_(new UserCrosSettingsProvider), |
| 133 method_factory_(this) { | 133 method_factory_(this) { |
| 134 if (delete_scheduled_instance_) | 134 if (current_controller_) |
| 135 delete_scheduled_instance_->Delete(); | 135 current_controller_->Delete(); |
| 136 current_controller_ = this; |
| 136 | 137 |
| 137 // Calculate the max number of users from available screen size. | 138 // Calculate the max number of users from available screen size. |
| 138 bool show_guest = UserCrosSettingsProvider::cached_allow_guest(); | 139 bool show_guest = UserCrosSettingsProvider::cached_allow_guest(); |
| 139 bool show_new_user = true; | 140 bool show_new_user = true; |
| 140 if (UserCrosSettingsProvider::cached_show_users_on_signin()) { | 141 if (UserCrosSettingsProvider::cached_show_users_on_signin()) { |
| 141 size_t max_users = kMaxUsers; | 142 size_t max_users = kMaxUsers; |
| 142 int screen_width = background_bounds.width(); | 143 int screen_width = background_bounds.width(); |
| 143 if (screen_width > 0) { | 144 if (screen_width > 0) { |
| 144 size_t users_per_screen = (screen_width - login::kUserImageSize) | 145 size_t users_per_screen = (screen_width - login::kUserImageSize) |
| 145 / (UserController::kUnselectedSize + UserController::kPadding); | 146 / (UserController::kUnselectedSize + UserController::kPadding); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 ExistingUserController::~ExistingUserController() { | 241 ExistingUserController::~ExistingUserController() { |
| 241 ClearErrors(); | 242 ClearErrors(); |
| 242 | 243 |
| 243 if (background_window_) | 244 if (background_window_) |
| 244 background_window_->Close(); | 245 background_window_->Close(); |
| 245 | 246 |
| 246 WmMessageListener::GetInstance()->RemoveObserver(this); | 247 WmMessageListener::GetInstance()->RemoveObserver(this); |
| 247 | 248 |
| 248 STLDeleteElements(&controllers_); | 249 STLDeleteElements(&controllers_); |
| 249 STLDeleteElements(&invisible_controllers_); | 250 STLDeleteElements(&invisible_controllers_); |
| 251 DCHECK(current_controller_ != NULL); |
| 252 current_controller_ = NULL; |
| 250 } | 253 } |
| 251 | 254 |
| 252 void ExistingUserController::Delete() { | 255 void ExistingUserController::Delete() { |
| 253 delete_scheduled_instance_ = NULL; | |
| 254 delete this; | 256 delete this; |
| 255 } | 257 } |
| 256 | 258 |
| 257 void ExistingUserController::ProcessWmMessage(const WmIpc::Message& message, | 259 void ExistingUserController::ProcessWmMessage(const WmIpc::Message& message, |
| 258 GdkWindow* window) { | 260 GdkWindow* window) { |
| 259 if (message.type() != WM_IPC_MESSAGE_CHROME_CREATE_GUEST_WINDOW) | 261 if (message.type() != WM_IPC_MESSAGE_CHROME_CREATE_GUEST_WINDOW) |
| 260 return; | 262 return; |
| 261 | 263 |
| 262 ActivateWizard(std::string()); | 264 ActivateWizard(std::string()); |
| 263 } | 265 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 281 selected_view_index_ = i - controllers_.begin(); | 283 selected_view_index_ = i - controllers_.begin(); |
| 282 num_login_attempts_ = 0; | 284 num_login_attempts_ = 0; |
| 283 } | 285 } |
| 284 | 286 |
| 285 // Disable clicking on other windows. | 287 // Disable clicking on other windows. |
| 286 SendSetLoginState(false); | 288 SendSetLoginState(false); |
| 287 | 289 |
| 288 // Use the same LoginPerformer for subsequent login as it has state | 290 // Use the same LoginPerformer for subsequent login as it has state |
| 289 // such as CAPTCHA challenge token & corresponding user input. | 291 // such as CAPTCHA challenge token & corresponding user input. |
| 290 if (!login_performer_.get() || num_login_attempts_ <= 1) { | 292 if (!login_performer_.get() || num_login_attempts_ <= 1) { |
| 291 login_performer_.reset(new LoginPerformer(this)); | 293 LoginPerformer::Delegate* delegate = this; |
| 294 if (login_performer_delegate_.get()) |
| 295 delegate = login_performer_delegate_.get(); |
| 296 login_performer_.reset(new LoginPerformer(delegate)); |
| 292 } | 297 } |
| 293 login_performer_->Login(controllers_[selected_view_index_]->user().email(), | 298 login_performer_->Login(controllers_[selected_view_index_]->user().email(), |
| 294 UTF16ToUTF8(password)); | 299 UTF16ToUTF8(password)); |
| 295 } | 300 } |
| 296 | 301 |
| 297 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { | 302 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { |
| 298 ShowError(IDS_LOGIN_ERROR_WHITELIST, email); | 303 ShowError(IDS_LOGIN_ERROR_WHITELIST, email); |
| 299 | 304 |
| 300 // Reenable userview and use ClearAndEnablePassword to keep username on | 305 // Reenable userview and use ClearAndEnablePassword to keep username on |
| 301 // screen with the error bubble. | 306 // screen with the error bubble. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 WizardController* controller = new WizardController(); | 359 WizardController* controller = new WizardController(); |
| 355 | 360 |
| 356 // Give the background window to the controller. | 361 // Give the background window to the controller. |
| 357 controller->OwnBackground(background_window_, background_view_); | 362 controller->OwnBackground(background_window_, background_view_); |
| 358 background_window_ = NULL; | 363 background_window_ = NULL; |
| 359 | 364 |
| 360 controller->Init(screen_name, background_bounds_); | 365 controller->Init(screen_name, background_bounds_); |
| 361 controller->set_start_url(start_url_); | 366 controller->set_start_url(start_url_); |
| 362 controller->Show(); | 367 controller->Show(); |
| 363 | 368 |
| 364 // And schedule us for deletion. We delay for a second as the window manager | |
| 365 // is doing an animation with our windows. | |
| 366 DCHECK(!delete_scheduled_instance_); | |
| 367 delete_scheduled_instance_ = this; | |
| 368 | |
| 369 delete_timer_.Start(base::TimeDelta::FromSeconds(1), this, | 369 delete_timer_.Start(base::TimeDelta::FromSeconds(1), this, |
| 370 &ExistingUserController::Delete); | 370 &ExistingUserController::Delete); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void ExistingUserController::RemoveUser(UserController* source) { | 373 void ExistingUserController::RemoveUser(UserController* source) { |
| 374 ClearErrors(); | 374 ClearErrors(); |
| 375 | 375 |
| 376 // Owner is not allowed to be removed from the device. | 376 // Owner is not allowed to be removed from the device. |
| 377 // It must be enforced at upper levels. | 377 // It must be enforced at upper levels. |
| 378 DCHECK(user_settings_->RequestTrustedOwner(NULL)); | 378 DCHECK(user_settings_->RequestTrustedOwner(NULL)); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 login_performer_->RecoverEncryptedData(old_password); | 658 login_performer_->RecoverEncryptedData(old_password); |
| 659 } | 659 } |
| 660 | 660 |
| 661 void ExistingUserController::ResyncEncryptedData() { | 661 void ExistingUserController::ResyncEncryptedData() { |
| 662 // LoginPerformer instance has state of the user so it should exist. | 662 // LoginPerformer instance has state of the user so it should exist. |
| 663 if (login_performer_.get()) | 663 if (login_performer_.get()) |
| 664 login_performer_->ResyncEncryptedData(); | 664 login_performer_->ResyncEncryptedData(); |
| 665 } | 665 } |
| 666 | 666 |
| 667 } // namespace chromeos | 667 } // namespace chromeos |
| OLD | NEW |