| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui_login_display.h" | 5 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 8 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 9 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 9 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 10 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 10 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 11 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 11 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 12 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 12 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 13 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 13 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chromeos/ime/ime_keyboard.h" | 16 #include "chromeos/ime/ime_keyboard.h" |
| 17 #include "chromeos/ime/input_method_manager.h" | 17 #include "chromeos/ime/input_method_manager.h" |
| 18 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
| 19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 22 #include "ui/wm/core/user_activity_detector.h" | 22 #include "ui/wm/core/user_activity_detector.h" |
| 23 | 23 |
| 24 namespace chromeos { | 24 namespace chromeos { |
| 25 | 25 |
| 26 namespace { | |
| 27 | |
| 28 const int kPasswordClearTimeoutSec = 60; | |
| 29 | |
| 30 } | |
| 31 | |
| 32 // WebUILoginDisplay, public: -------------------------------------------------- | 26 // WebUILoginDisplay, public: -------------------------------------------------- |
| 33 | 27 |
| 34 WebUILoginDisplay::~WebUILoginDisplay() { | 28 WebUILoginDisplay::~WebUILoginDisplay() { |
| 35 if (webui_handler_) | 29 if (webui_handler_) |
| 36 webui_handler_->ResetSigninScreenHandlerDelegate(); | 30 webui_handler_->ResetSigninScreenHandlerDelegate(); |
| 37 wm::UserActivityDetector* activity_detector = ash::Shell::GetInstance()-> | 31 wm::UserActivityDetector* activity_detector = ash::Shell::GetInstance()-> |
| 38 user_activity_detector(); | 32 user_activity_detector(); |
| 39 if (activity_detector->HasObserver(this)) | 33 if (activity_detector->HasObserver(this)) |
| 40 activity_detector->RemoveObserver(this); | 34 activity_detector->RemoveObserver(this); |
| 41 } | 35 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 56 webui_handler_->ClearAndEnablePassword(); | 50 webui_handler_->ClearAndEnablePassword(); |
| 57 } | 51 } |
| 58 | 52 |
| 59 void WebUILoginDisplay::Init(const UserList& users, | 53 void WebUILoginDisplay::Init(const UserList& users, |
| 60 bool show_guest, | 54 bool show_guest, |
| 61 bool show_users, | 55 bool show_users, |
| 62 bool show_new_user) { | 56 bool show_new_user) { |
| 63 // Testing that the delegate has been set. | 57 // Testing that the delegate has been set. |
| 64 DCHECK(delegate_); | 58 DCHECK(delegate_); |
| 65 | 59 |
| 66 user_selection_screen_->Init(users); | 60 user_selection_screen_->Init(users, show_guest); |
| 67 show_guest_ = show_guest; | 61 show_guest_ = show_guest; |
| 68 show_users_ = show_users; | 62 show_users_ = show_users; |
| 69 show_new_user_ = show_new_user; | 63 show_new_user_ = show_new_user; |
| 70 | 64 |
| 71 wm::UserActivityDetector* activity_detector = ash::Shell::GetInstance()-> | 65 wm::UserActivityDetector* activity_detector = ash::Shell::GetInstance()-> |
| 72 user_activity_detector(); | 66 user_activity_detector(); |
| 73 if (!activity_detector->HasObserver(this)) | 67 if (!activity_detector->HasObserver(this)) |
| 74 activity_detector->AddObserver(this); | 68 activity_detector->AddObserver(this); |
| 75 } | 69 } |
| 76 | 70 |
| 77 // ---- Common methods | 71 // ---- Common methods |
| 78 | 72 |
| 79 // ---- User selection screen methods | 73 // ---- User selection screen methods |
| 80 | 74 |
| 81 void WebUILoginDisplay::OnBeforeUserRemoved(const std::string& username) { | 75 void WebUILoginDisplay::OnBeforeUserRemoved(const std::string& username) { |
| 82 user_selection_screen_->OnBeforeUserRemoved(username); | 76 user_selection_screen_->OnBeforeUserRemoved(username); |
| 83 } | 77 } |
| 84 | 78 |
| 85 void WebUILoginDisplay::OnUserRemoved(const std::string& username) { | 79 void WebUILoginDisplay::OnUserRemoved(const std::string& username) { |
| 86 user_selection_screen_->OnUserRemoved(username); | 80 user_selection_screen_->OnUserRemoved(username); |
| 87 } | 81 } |
| 88 | 82 |
| 89 void WebUILoginDisplay::OnUserImageChanged(const User& user) { | 83 void WebUILoginDisplay::OnUserImageChanged(const User& user) { |
| 90 user_selection_screen_->OnUserImageChanged(user); | 84 user_selection_screen_->OnUserImageChanged(user); |
| 91 } | 85 } |
| 92 | 86 |
| 93 // User selection screen, screen lock API | 87 void WebUILoginDisplay::HandleGetUsers() { |
| 88 user_selection_screen_->HandleGetUsers(); |
| 89 } |
| 94 | 90 |
| 95 const UserList& WebUILoginDisplay::GetUsers() const { | 91 const UserList& WebUILoginDisplay::GetUsers() const { |
| 96 return user_selection_screen_->GetUsers(); | 92 return user_selection_screen_->GetUsers(); |
| 97 } | 93 } |
| 98 | 94 |
| 95 // User selection screen, screen lock API |
| 96 |
| 97 void WebUILoginDisplay::SetAuthType( |
| 98 const std::string& username, |
| 99 ScreenlockBridge::LockHandler::AuthType auth_type) { |
| 100 user_selection_screen_->SetAuthType(username, auth_type); |
| 101 } |
| 102 |
| 103 ScreenlockBridge::LockHandler::AuthType WebUILoginDisplay::GetAuthType( |
| 104 const std::string& username) const { |
| 105 return user_selection_screen_->GetAuthType(username); |
| 106 } |
| 107 |
| 99 // ---- Gaia screen methods | 108 // ---- Gaia screen methods |
| 100 | 109 |
| 101 // ---- Not yet classified methods | 110 // ---- Not yet classified methods |
| 102 | 111 |
| 103 void WebUILoginDisplay::OnPreferencesChanged() { | 112 void WebUILoginDisplay::OnPreferencesChanged() { |
| 104 if (webui_handler_) | 113 if (webui_handler_) |
| 105 webui_handler_->OnPreferencesChanged(); | 114 webui_handler_->OnPreferencesChanged(); |
| 106 } | 115 } |
| 107 | 116 |
| 108 void WebUILoginDisplay::SetUIEnabled(bool is_enabled) { | 117 void WebUILoginDisplay::SetUIEnabled(bool is_enabled) { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 335 } |
| 327 | 336 |
| 328 bool WebUILoginDisplay::IsShowGuest() const { | 337 bool WebUILoginDisplay::IsShowGuest() const { |
| 329 return show_guest_; | 338 return show_guest_; |
| 330 } | 339 } |
| 331 | 340 |
| 332 bool WebUILoginDisplay::IsShowUsers() const { | 341 bool WebUILoginDisplay::IsShowUsers() const { |
| 333 return show_users_; | 342 return show_users_; |
| 334 } | 343 } |
| 335 | 344 |
| 336 bool WebUILoginDisplay::IsShowNewUser() const { | |
| 337 return show_new_user_; | |
| 338 } | |
| 339 | |
| 340 bool WebUILoginDisplay::IsSigninInProgress() const { | 345 bool WebUILoginDisplay::IsSigninInProgress() const { |
| 341 return delegate_->IsSigninInProgress(); | 346 return delegate_->IsSigninInProgress(); |
| 342 } | 347 } |
| 343 | 348 |
| 344 bool WebUILoginDisplay::IsUserSigninCompleted() const { | 349 bool WebUILoginDisplay::IsUserSigninCompleted() const { |
| 345 return is_signin_completed(); | 350 return is_signin_completed(); |
| 346 } | 351 } |
| 347 | 352 |
| 348 void WebUILoginDisplay::SetDisplayEmail(const std::string& email) { | 353 void WebUILoginDisplay::SetDisplayEmail(const std::string& email) { |
| 349 if (delegate_) | 354 if (delegate_) |
| 350 delegate_->SetDisplayEmail(email); | 355 delegate_->SetDisplayEmail(email); |
| 351 } | 356 } |
| 352 | 357 |
| 353 void WebUILoginDisplay::Signout() { | 358 void WebUILoginDisplay::Signout() { |
| 354 delegate_->Signout(); | 359 delegate_->Signout(); |
| 355 } | 360 } |
| 356 | 361 |
| 357 void WebUILoginDisplay::LoginAsKioskApp(const std::string& app_id, | 362 void WebUILoginDisplay::LoginAsKioskApp(const std::string& app_id, |
| 358 bool diagnostic_mode) { | 363 bool diagnostic_mode) { |
| 359 delegate_->LoginAsKioskApp(app_id, diagnostic_mode); | 364 delegate_->LoginAsKioskApp(app_id, diagnostic_mode); |
| 360 } | 365 } |
| 361 | 366 |
| 362 void WebUILoginDisplay::OnUserActivity(const ui::Event* event) { | 367 void WebUILoginDisplay::OnUserActivity(const ui::Event* event) { |
| 363 if (!password_clear_timer_.IsRunning()) | |
| 364 StartPasswordClearTimer(); | |
| 365 password_clear_timer_.Reset(); | |
| 366 if (delegate_) | 368 if (delegate_) |
| 367 delegate_->ResetPublicSessionAutoLoginTimer(); | 369 delegate_->ResetPublicSessionAutoLoginTimer(); |
| 368 } | 370 } |
| 369 | 371 |
| 370 void WebUILoginDisplay::StartPasswordClearTimer() { | |
| 371 DCHECK(!password_clear_timer_.IsRunning()); | |
| 372 password_clear_timer_.Start(FROM_HERE, | |
| 373 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), this, | |
| 374 &WebUILoginDisplay::OnPasswordClearTimerExpired); | |
| 375 } | |
| 376 | |
| 377 void WebUILoginDisplay::OnPasswordClearTimerExpired() { | |
| 378 if (webui_handler_) | |
| 379 webui_handler_->ClearUserPodPassword(); | |
| 380 } | |
| 381 | 372 |
| 382 } // namespace chromeos | 373 } // namespace chromeos |
| OLD | NEW |