Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/user_controller.h" | 5 #include "chrome/browser/chromeos/login/user_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "chrome/browser/chromeos/login/wizard_controller.h" | 22 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 23 #include "chrome/common/notification_service.h" | 23 #include "chrome/common/notification_service.h" |
| 24 #include "chrome/common/notification_type.h" | 24 #include "chrome/common/notification_type.h" |
| 25 #include "cros/chromeos_wm_ipc_enums.h" | 25 #include "cros/chromeos_wm_ipc_enums.h" |
| 26 #include "gfx/canvas.h" | 26 #include "gfx/canvas.h" |
| 27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 28 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 29 #include "views/background.h" | 29 #include "views/background.h" |
| 30 #include "views/controls/button/native_button.h" | 30 #include "views/controls/button/native_button.h" |
| 31 #include "views/controls/label.h" | 31 #include "views/controls/label.h" |
| 32 #include "views/controls/throbber.h" | |
| 32 #include "views/grid_layout.h" | 33 #include "views/grid_layout.h" |
| 33 #include "views/painter.h" | 34 #include "views/painter.h" |
| 34 #include "views/screen.h" | 35 #include "views/screen.h" |
| 35 #include "views/widget/root_view.h" | 36 #include "views/widget/root_view.h" |
| 36 #include "views/widget/widget_gtk.h" | 37 #include "views/widget/widget_gtk.h" |
| 37 | 38 |
| 38 using views::ColumnSet; | 39 using views::ColumnSet; |
| 39 using views::GridLayout; | 40 using views::GridLayout; |
| 40 using views::WidgetGtk; | 41 using views::WidgetGtk; |
| 41 | 42 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 63 public: | 64 public: |
| 64 ClickNotifyingWidget(views::WidgetGtk::Type type, | 65 ClickNotifyingWidget(views::WidgetGtk::Type type, |
| 65 UserController* controller) | 66 UserController* controller) |
| 66 : WidgetGtk(type), | 67 : WidgetGtk(type), |
| 67 controller_(controller) { | 68 controller_(controller) { |
| 68 } | 69 } |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) { | 72 gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) { |
| 72 if (!controller_->is_user_selected()) | 73 if (!controller_->is_user_selected()) |
| 73 controller_->SelectUser(controller_->user_index()); | 74 controller_->SelectUserRelative(0); |
| 74 | 75 |
| 75 return views::WidgetGtk::OnButtonPress(widget, event); | 76 return views::WidgetGtk::OnButtonPress(widget, event); |
| 76 } | 77 } |
| 77 | 78 |
| 78 UserController* controller_; | 79 UserController* controller_; |
| 79 | 80 |
| 80 DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget); | 81 DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget); |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 void CloseWindow(views::WidgetGtk* window) { | 84 void CloseWindow(views::WidgetGtk* window) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 is_guest_(is_guest), | 138 is_guest_(is_guest), |
| 138 is_owner_(false), | 139 is_owner_(false), |
| 139 show_name_tooltip_(false), | 140 show_name_tooltip_(false), |
| 140 delegate_(delegate), | 141 delegate_(delegate), |
| 141 controls_window_(NULL), | 142 controls_window_(NULL), |
| 142 image_window_(NULL), | 143 image_window_(NULL), |
| 143 border_window_(NULL), | 144 border_window_(NULL), |
| 144 label_window_(NULL), | 145 label_window_(NULL), |
| 145 unselected_label_window_(NULL), | 146 unselected_label_window_(NULL), |
| 146 user_view_(NULL), | 147 user_view_(NULL), |
| 147 new_user_view_(NULL), | |
| 148 existing_user_view_(NULL), | |
| 149 guest_user_view_(NULL), | |
| 150 label_view_(NULL), | 148 label_view_(NULL), |
| 151 unselected_label_view_(NULL), | 149 unselected_label_view_(NULL), |
| 150 throbber_manager_(new ThrobberManager), | |
| 152 method_factory_(this) { | 151 method_factory_(this) { |
| 153 registrar_.Add( | 152 registrar_.Add( |
| 154 this, | 153 this, |
| 155 NotificationType::LOGIN_USER_IMAGE_CHANGED, | 154 NotificationType::LOGIN_USER_IMAGE_CHANGED, |
| 156 NotificationService::AllSources()); | 155 NotificationService::AllSources()); |
| 157 } | 156 } |
| 158 | 157 |
| 159 UserController::UserController(Delegate* delegate, | 158 UserController::UserController(Delegate* delegate, |
| 160 const UserManager::User& user) | 159 const UserManager::User& user) |
| 161 : user_index_(-1), | 160 : user_index_(-1), |
| 162 is_user_selected_(false), | 161 is_user_selected_(false), |
| 163 is_new_user_(false), | 162 is_new_user_(false), |
| 164 is_guest_(false), | 163 is_guest_(false), |
| 165 // Empty 'cached_owner()' means that owner hasn't been cached yet, not | 164 // Empty 'cached_owner()' means that owner hasn't been cached yet, not |
| 166 // that owner has an empty email. | 165 // that owner has an empty email. |
| 167 is_owner_(user.email() == UserCrosSettingsProvider::cached_owner()), | 166 is_owner_(user.email() == UserCrosSettingsProvider::cached_owner()), |
| 168 show_name_tooltip_(false), | 167 show_name_tooltip_(false), |
| 169 user_(user), | 168 user_(user), |
| 170 delegate_(delegate), | 169 delegate_(delegate), |
| 171 controls_window_(NULL), | 170 controls_window_(NULL), |
| 172 image_window_(NULL), | 171 image_window_(NULL), |
| 173 border_window_(NULL), | 172 border_window_(NULL), |
| 174 label_window_(NULL), | 173 label_window_(NULL), |
| 175 unselected_label_window_(NULL), | 174 unselected_label_window_(NULL), |
| 176 user_view_(NULL), | 175 user_view_(NULL), |
| 177 new_user_view_(NULL), | |
| 178 existing_user_view_(NULL), | |
| 179 guest_user_view_(NULL), | |
| 180 label_view_(NULL), | 176 label_view_(NULL), |
| 181 unselected_label_view_(NULL), | 177 unselected_label_view_(NULL), |
| 178 throbber_manager_(new ThrobberManager), | |
|
whywhat
2010/12/09 16:20:18
Please, use () when creating objects using the def
altimofeev
2010/12/10 16:37:40
Done.
| |
| 182 method_factory_(this) { | 179 method_factory_(this) { |
| 183 DCHECK(!user.email().empty()); | 180 DCHECK(!user.email().empty()); |
| 184 registrar_.Add( | 181 registrar_.Add( |
| 185 this, | 182 this, |
| 186 NotificationType::LOGIN_USER_IMAGE_CHANGED, | 183 NotificationType::LOGIN_USER_IMAGE_CHANGED, |
| 187 NotificationService::AllSources()); | 184 NotificationService::AllSources()); |
| 188 } | 185 } |
| 189 | 186 |
| 190 UserController::~UserController() { | 187 UserController::~UserController() { |
| 191 // Reset the widget delegate of every window to NULL, so the user | 188 // Reset the widget delegate of every window to NULL, so the user |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 206 controls_window_ = | 203 controls_window_ = |
| 207 CreateControlsWindow(index, &controls_width, &controls_height, | 204 CreateControlsWindow(index, &controls_width, &controls_height, |
| 208 need_browse_without_signin); | 205 need_browse_without_signin); |
| 209 image_window_ = CreateImageWindow(index); | 206 image_window_ = CreateImageWindow(index); |
| 210 CreateBorderWindow(index, total_user_count, controls_width, controls_height); | 207 CreateBorderWindow(index, total_user_count, controls_width, controls_height); |
| 211 label_window_ = CreateLabelWindow(index, WM_IPC_WINDOW_LOGIN_LABEL); | 208 label_window_ = CreateLabelWindow(index, WM_IPC_WINDOW_LOGIN_LABEL); |
| 212 unselected_label_window_ = | 209 unselected_label_window_ = |
| 213 CreateLabelWindow(index, WM_IPC_WINDOW_LOGIN_UNSELECTED_LABEL); | 210 CreateLabelWindow(index, WM_IPC_WINDOW_LOGIN_UNSELECTED_LABEL); |
| 214 } | 211 } |
| 215 | 212 |
| 216 void UserController::SetPasswordEnabled(bool enable) { | 213 void UserController::StartThrobber() { |
| 217 DCHECK(!is_new_user_); | 214 views::Throbber* throbber = CreateDefaultSmoothedThrobber(); |
| 218 existing_user_view_->password_field()->SetEnabled(enable); | 215 gfx::Rect bounds; |
| 219 if (enable) { | 216 if (user_input_-> |
| 220 user_view_->StopThrobber(); | 217 UseCustomBoundsForThrobber(throbber->GetPreferredSize(), &bounds)) { |
|
whywhat
2010/12/09 16:20:18
Why not split the line between ( and t?
altimofeev
2010/12/10 16:37:40
Done.
| |
| 221 delegate_->SetStatusAreaEnabled(enable); | 218 throbber_manager_->StartShow(controls_window_, throbber, bounds); |
| 222 } else { | 219 } else { |
| 223 delegate_->SetStatusAreaEnabled(enable); | 220 throbber_manager_->StartShow(controls_window_, |
| 224 user_view_->StartThrobber(); | 221 throbber, |
| 222 login::kThrobberRightShift); | |
|
whywhat
2010/12/09 16:20:18
Maybe this constant should be defined here rather
altimofeev
2010/12/10 16:37:40
It is also used by ScreenLockView.
| |
| 225 } | 223 } |
| 226 } | 224 } |
| 227 | 225 |
| 226 void UserController::StopThrobber() { | |
| 227 throbber_manager_->Stop(); | |
| 228 } | |
| 229 | |
| 228 std::wstring UserController::GetNameTooltip() const { | 230 std::wstring UserController::GetNameTooltip() const { |
| 229 if (is_new_user_) | 231 if (is_new_user_) |
| 230 return l10n_util::GetString(IDS_ADD_USER); | 232 return l10n_util::GetString(IDS_ADD_USER); |
| 231 if (is_guest_) | 233 if (is_guest_) |
| 232 return l10n_util::GetString(IDS_GO_INCOGNITO_BUTTON); | 234 return l10n_util::GetString(IDS_GO_INCOGNITO_BUTTON); |
| 233 | 235 |
| 234 // Tooltip contains user's display name and his email domain to distinguish | 236 // Tooltip contains user's display name and his email domain to distinguish |
| 235 // this user from the other one with the same display name. | 237 // this user from the other one with the same display name. |
| 236 const std::string& email = user_.email(); | 238 const std::string& email = user_.email(); |
| 237 size_t at_pos = email.rfind('@'); | 239 size_t at_pos = email.rfind('@'); |
| 238 if (at_pos == std::string::npos) { | 240 if (at_pos == std::string::npos) { |
| 239 NOTREACHED(); | 241 NOTREACHED(); |
| 240 return std::wstring(); | 242 return std::wstring(); |
| 241 } | 243 } |
| 242 size_t domain_start = at_pos + 1; | 244 size_t domain_start = at_pos + 1; |
| 243 std::string domain = email.substr(domain_start, | 245 std::string domain = email.substr(domain_start, |
| 244 email.length() - domain_start); | 246 email.length() - domain_start); |
| 245 return UTF8ToWide(base::StringPrintf("%s (%s)", | 247 return UTF8ToWide(base::StringPrintf("%s (%s)", |
| 246 user_.GetDisplayName().c_str(), | 248 user_.GetDisplayName().c_str(), |
| 247 domain.c_str())); | 249 domain.c_str())); |
| 248 } | 250 } |
| 249 | 251 |
| 250 void UserController::ClearAndEnablePassword() { | 252 void UserController::ClearAndEnableFields() { |
| 251 if (is_new_user_) { | 253 user_input_->ClearAndFocusControls(); |
| 252 // TODO(avayvod): This code seems not reachable to me. | 254 user_input_->EnableInputControls(true); |
| 253 new_user_view_->ClearAndEnablePassword(); | 255 SetStatusAreaEnabled(true); |
| 254 } else { | 256 StopThrobber(); |
| 255 existing_user_view_->password_field()->SetText(string16()); | |
| 256 SetPasswordEnabled(true); | |
| 257 FocusPasswordField(); | |
| 258 } | |
| 259 } | 257 } |
| 260 | 258 |
| 261 void UserController::ClearAndEnableFields() { | 259 void UserController::ClearAndEnablePassword() { |
| 262 if (is_new_user_) { | 260 user_input_->ClearAndFocusPassword(); |
| 263 new_user_view_->ClearAndEnableFields(); | 261 user_input_->EnableInputControls(true); |
| 264 } else if (is_guest_) { | 262 SetStatusAreaEnabled(true); |
| 265 guest_user_view_->FocusSignInButton(); | 263 StopThrobber(); |
| 266 } else { | 264 } |
| 267 ClearAndEnablePassword(); | 265 |
| 268 } | 266 gfx::Rect UserController::GetScreenBounds() { |
| 267 return user_input_->GetControlWithErrorBounds(); | |
| 269 } | 268 } |
| 270 | 269 |
| 271 void UserController::EnableNameTooltip(bool enable) { | 270 void UserController::EnableNameTooltip(bool enable) { |
| 272 std::wstring tooltip_text; | 271 std::wstring tooltip_text; |
| 273 if (enable) | 272 if (enable) |
| 274 tooltip_text = GetNameTooltip(); | 273 tooltip_text = GetNameTooltip(); |
| 275 | 274 |
| 276 if (user_view_) | 275 if (user_view_) |
| 277 user_view_->SetTooltipText(tooltip_text); | 276 user_view_->SetTooltipText(tooltip_text); |
| 278 if (label_view_) | 277 if (label_view_) |
| 279 label_view_->SetTooltipText(tooltip_text); | 278 label_view_->SetTooltipText(tooltip_text); |
| 280 if (unselected_label_view_) | 279 if (unselected_label_view_) |
| 281 unselected_label_view_->SetTooltipText(tooltip_text); | 280 unselected_label_view_->SetTooltipText(tooltip_text); |
| 282 } | 281 } |
| 283 | 282 |
| 284 void UserController::ButtonPressed(views::Button* sender, | |
| 285 const views::Event& event) { | |
| 286 Login(); | |
| 287 } | |
| 288 | |
| 289 bool UserController::HandleKeystroke( | |
| 290 views::Textfield* sender, | |
| 291 const views::Textfield::Keystroke& keystroke) { | |
| 292 if (keystroke.GetKeyboardCode() == app::VKEY_RETURN) { | |
| 293 Login(); | |
| 294 return true; | |
| 295 } else if (keystroke.GetKeyboardCode() == app::VKEY_LEFT) { | |
| 296 SelectUser(user_index() - 1); | |
| 297 return true; | |
| 298 } else if (keystroke.GetKeyboardCode() == app::VKEY_RIGHT) { | |
| 299 SelectUser(user_index() + 1); | |
| 300 return true; | |
| 301 } | |
| 302 delegate_->ClearErrors(); | |
| 303 return false; | |
| 304 } | |
| 305 | |
| 306 void UserController::ContentsChanged(views::Textfield* sender, | |
| 307 const string16& new_contents) { | |
| 308 } | |
| 309 | |
| 310 void UserController::Observe( | 283 void UserController::Observe( |
| 311 NotificationType type, | 284 NotificationType type, |
| 312 const NotificationSource& source, | 285 const NotificationSource& source, |
| 313 const NotificationDetails& details) { | 286 const NotificationDetails& details) { |
| 314 if (type != NotificationType::LOGIN_USER_IMAGE_CHANGED || | 287 if (type != NotificationType::LOGIN_USER_IMAGE_CHANGED || |
| 315 !user_view_) | 288 !user_view_) |
| 316 return; | 289 return; |
| 317 | 290 |
| 318 UserManager::User* user = Details<UserManager::User>(details).ptr(); | 291 UserManager::User* user = Details<UserManager::User>(details).ptr(); |
| 319 if (user_.email() != user->email()) | 292 if (user_.email() != user->email()) |
| 320 return; | 293 return; |
| 321 | 294 |
| 322 user_.set_image(user->image()); | 295 user_.set_image(user->image()); |
| 323 user_view_->SetImage(user_.image(), user_.image()); | 296 user_view_->SetImage(user_.image(), user_.image()); |
| 324 } | 297 } |
| 325 | 298 |
| 326 void UserController::Login() { | |
| 327 if (is_guest_) { | |
| 328 delegate_->LoginOffTheRecord(); | |
| 329 } else { | |
| 330 // Delegate will reenable as necessary. | |
| 331 SetPasswordEnabled(false); | |
| 332 | |
| 333 delegate_->Login(this, existing_user_view_->password_field()->text()); | |
| 334 } | |
| 335 } | |
| 336 | |
| 337 void UserController::IsActiveChanged(bool active) { | 299 void UserController::IsActiveChanged(bool active) { |
| 338 is_user_selected_ = active; | 300 is_user_selected_ = active; |
| 339 if (active) { | 301 if (active) { |
| 340 delegate_->OnUserSelected(this); | 302 delegate_->OnUserSelected(this); |
| 341 user_view_->SetRemoveButtonVisible( | 303 user_view_->SetRemoveButtonVisible( |
| 342 !is_new_user_ && !is_guest_ && !is_owner_); | 304 !is_new_user_ && !is_guest_ && !is_owner_); |
| 343 } else { | 305 } else { |
| 344 user_view_->SetRemoveButtonVisible(false); | 306 user_view_->SetRemoveButtonVisible(false); |
| 345 delegate_->ClearErrors(); | 307 delegate_->ClearErrors(); |
| 346 } | 308 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 368 | 330 |
| 369 window->Show(); | 331 window->Show(); |
| 370 } | 332 } |
| 371 | 333 |
| 372 WidgetGtk* UserController::CreateControlsWindow( | 334 WidgetGtk* UserController::CreateControlsWindow( |
| 373 int index, | 335 int index, |
| 374 int* width, int* height, | 336 int* width, int* height, |
| 375 bool need_browse_without_signin) { | 337 bool need_browse_without_signin) { |
| 376 views::View* control_view; | 338 views::View* control_view; |
| 377 if (is_new_user_) { | 339 if (is_new_user_) { |
| 378 new_user_view_ = | 340 NewUserView* new_user_view = |
| 379 new NewUserView(this, true, need_browse_without_signin); | 341 new NewUserView(this, true, need_browse_without_signin); |
| 380 new_user_view_->Init(); | 342 new_user_view->Init(); |
| 381 control_view = new_user_view_; | 343 control_view = new_user_view; |
| 344 user_input_ = new_user_view; | |
| 382 } else if (is_guest_) { | 345 } else if (is_guest_) { |
| 383 guest_user_view_ = new GuestUserView(this); | 346 GuestUserView* guest_user_view = new GuestUserView(this); |
| 384 guest_user_view_->RecreateFields(); | 347 guest_user_view->RecreateFields(); |
| 385 control_view = guest_user_view_; | 348 control_view = guest_user_view; |
| 349 user_input_ = guest_user_view; | |
| 386 } else { | 350 } else { |
| 387 existing_user_view_ = new ExistingUserView(this); | 351 ExistingUserView* existing_user_view = new ExistingUserView(this); |
| 388 existing_user_view_->RecreateFields(); | 352 existing_user_view->RecreateFields(); |
| 389 control_view = existing_user_view_; | 353 control_view = existing_user_view; |
| 354 user_input_ = existing_user_view; | |
| 390 } | 355 } |
| 391 | 356 |
| 392 *height = kControlsHeight; | 357 *height = kControlsHeight; |
| 393 *width = kUserImageSize; | 358 *width = kUserImageSize; |
| 394 if (is_new_user_) { | 359 if (is_new_user_) { |
| 395 DCHECK(new_user_view_); | 360 gfx::Size size = control_view->GetPreferredSize(); |
| 396 gfx::Size size = new_user_view_->GetPreferredSize(); | |
| 397 *width = size.width(); | 361 *width = size.width(); |
| 398 *height = size.height(); | 362 *height = size.height(); |
| 399 } | 363 } |
| 400 | 364 |
| 401 WidgetGtk* window = new WidgetGtk(WidgetGtk::TYPE_WINDOW); | 365 WidgetGtk* window = new WidgetGtk(WidgetGtk::TYPE_WINDOW); |
| 402 ConfigureLoginWindow(window, | 366 ConfigureLoginWindow(window, |
| 403 index, | 367 index, |
| 404 gfx::Rect(*width, *height), | 368 gfx::Rect(*width, *height), |
| 405 WM_IPC_WINDOW_LOGIN_CONTROLS, | 369 WM_IPC_WINDOW_LOGIN_CONTROLS, |
| 406 control_view); | 370 control_view); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 login::kSelectedLabelHeight : login::kUnselectedLabelHeight; | 480 login::kSelectedLabelHeight : login::kUnselectedLabelHeight; |
| 517 WidgetGtk* window = new ClickNotifyingWidget(WidgetGtk::TYPE_WINDOW, this); | 481 WidgetGtk* window = new ClickNotifyingWidget(WidgetGtk::TYPE_WINDOW, this); |
| 518 ConfigureLoginWindow(window, | 482 ConfigureLoginWindow(window, |
| 519 index, | 483 index, |
| 520 gfx::Rect(0, 0, width, height), | 484 gfx::Rect(0, 0, width, height), |
| 521 type, | 485 type, |
| 522 label); | 486 label); |
| 523 return window; | 487 return window; |
| 524 } | 488 } |
| 525 | 489 |
| 526 gfx::Rect UserController::GetScreenBounds() const { | |
| 527 if (is_new_user_) | |
| 528 return new_user_view_->GetUsernameBounds(); | |
| 529 else | |
| 530 return existing_user_view_->password_field()->GetScreenBounds(); | |
| 531 } | |
| 532 | |
| 533 void UserController::OnLogin(const std::string& username, | 490 void UserController::OnLogin(const std::string& username, |
| 534 const std::string& password) { | 491 const std::string& password) { |
| 535 user_.set_email(username); | 492 if (is_new_user_) |
| 493 user_.set_email(username); | |
| 494 | |
| 495 user_input_->EnableInputControls(false); | |
| 496 SetStatusAreaEnabled(false); | |
| 497 StartThrobber(); | |
| 498 | |
| 536 delegate_->Login(this, UTF8ToUTF16(password)); | 499 delegate_->Login(this, UTF8ToUTF16(password)); |
| 537 } | 500 } |
| 538 | 501 |
| 539 void UserController::OnCreateAccount() { | 502 void UserController::OnCreateAccount() { |
| 540 delegate_->ActivateWizard(WizardController::kAccountScreenName); | 503 delegate_->ActivateWizard(WizardController::kAccountScreenName); |
| 541 } | 504 } |
| 542 | 505 |
| 543 void UserController::OnLoginOffTheRecord() { | 506 void UserController::OnLoginOffTheRecord() { |
| 507 user_input_->EnableInputControls(false); | |
| 508 SetStatusAreaEnabled(false); | |
| 509 StartThrobber(); | |
| 510 | |
| 544 delegate_->LoginOffTheRecord(); | 511 delegate_->LoginOffTheRecord(); |
| 545 } | 512 } |
| 546 | 513 |
| 547 void UserController::ClearErrors() { | 514 void UserController::ClearErrors() { |
| 548 delegate_->ClearErrors(); | 515 delegate_->ClearErrors(); |
| 549 } | 516 } |
| 550 | 517 |
| 551 void UserController::NavigateAway() { | 518 void UserController::NavigateAway() { |
| 552 SelectUser(user_index() - 1); | 519 SelectUserRelative(-1); |
| 553 } | 520 } |
| 554 | 521 |
| 555 void UserController::OnRemoveUser() { | 522 void UserController::OnRemoveUser() { |
| 556 // Must not proceed without signature verification. | 523 // Must not proceed without signature verification. |
| 557 UserCrosSettingsProvider user_settings; | 524 UserCrosSettingsProvider user_settings; |
| 558 bool trusted_owner_available = user_settings.RequestTrustedOwner( | 525 bool trusted_owner_available = user_settings.RequestTrustedOwner( |
| 559 method_factory_.NewRunnableMethod(&UserController::OnRemoveUser)); | 526 method_factory_.NewRunnableMethod(&UserController::OnRemoveUser)); |
| 560 if (!trusted_owner_available) { | 527 if (!trusted_owner_available) { |
| 561 // Value of owner email is still not verified. | 528 // Value of owner email is still not verified. |
| 562 // Another attempt will be invoked after verification completion. | 529 // Another attempt will be invoked after verification completion. |
| 563 return; | 530 return; |
| 564 } | 531 } |
| 565 if (user().email() == UserCrosSettingsProvider::cached_owner()) { | 532 if (user().email() == UserCrosSettingsProvider::cached_owner()) { |
| 566 // Owner is not allowed to be removed from the device. | 533 // Owner is not allowed to be removed from the device. |
| 567 return; | 534 return; |
| 568 } | 535 } |
| 569 delegate_->RemoveUser(this); | 536 delegate_->RemoveUser(this); |
| 570 } | 537 } |
| 571 | 538 |
| 572 void UserController::SelectUser(int index) { | 539 void UserController::SelectUserRelative(int shift) { |
| 573 delegate_->SelectUser(index); | 540 delegate_->SelectUser(user_index() + shift); |
| 574 } | |
| 575 | |
| 576 void UserController::FocusPasswordField() { | |
| 577 existing_user_view_->FocusPasswordField(); | |
| 578 } | 541 } |
| 579 | 542 |
| 580 } // namespace chromeos | 543 } // namespace chromeos |
| OLD | NEW |