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

Side by Side Diff: chrome/browser/chromeos/login/ui/webui_login_display.cc

Issue 296823009: ChromeOS login webui refactoring: split user selection/gaia login screens. (Closed) Base URL: http://git.chromium.org/chromium/src.git@refactoring-1
Patch Set: Created 6 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 unified diff | Download patch
OLDNEW
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
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
(...skipping 24 matching lines...) Expand all
101 } 95 }
102 96
103 // User selection screen, screen lock API 97 // User selection screen, screen lock API
104 98
105 void WebUILoginDisplay::ShowBannerMessage(const std::string& message) { 99 void WebUILoginDisplay::ShowBannerMessage(const std::string& message) {
106 if (!webui_handler_) 100 if (!webui_handler_)
107 return; 101 return;
108 webui_handler_->ShowBannerMessage(message); 102 webui_handler_->ShowBannerMessage(message);
109 } 103 }
110 104
111
112 void WebUILoginDisplay::SetAuthType(const std::string& username, 105 void WebUILoginDisplay::SetAuthType(const std::string& username,
113 AuthType auth_type, 106 AuthType auth_type,
114 const std::string& initial_value) { 107 const std::string& initial_value) {
115 if (!webui_handler_) 108 user_selection_screen_->SetAuthType(username, auth_type, initial_value);
116 return;
117 webui_handler_->SetAuthType(username, auth_type, initial_value);
118 } 109 }
119 110
120 LoginDisplay::AuthType WebUILoginDisplay::GetAuthType( 111 LoginDisplay::AuthType WebUILoginDisplay::GetAuthType(
121 const std::string& username) const { 112 const std::string& username) const {
122 // Return default auth type if WebUI hander is not ready. 113 return user_selection_screen_->GetAuthType(username);
123 if (!webui_handler_)
124 return OFFLINE_PASSWORD;
125 return webui_handler_->GetAuthType(username);
126 } 114 }
127 115
128 const UserList& WebUILoginDisplay::GetUsers() const { 116 const UserList& WebUILoginDisplay::GetUsers() const {
129 return user_selection_screen_->GetUsers(); 117 return user_selection_screen_->GetUsers();
130 } 118 }
131 119
120 void WebUILoginDisplay::HandleCustomButtonClicked(const std::string& user_id) {
121 user_selection_screen_->HandleCustomButtonClicked(user_id);
122 }
123
124 void WebUILoginDisplay::HandleGetUsers() {
125 user_selection_screen_->HandleGetUsers();
126 }
127
132 // ---- Gaia screen methods 128 // ---- Gaia screen methods
133 129
134 // ---- Not yet classified methods 130 // ---- Not yet classified methods
135 131
136 void WebUILoginDisplay::OnPreferencesChanged() { 132 void WebUILoginDisplay::OnPreferencesChanged() {
137 if (webui_handler_) 133 if (webui_handler_)
138 webui_handler_->OnPreferencesChanged(); 134 webui_handler_->OnPreferencesChanged();
139 } 135 }
140 136
141 void WebUILoginDisplay::SetUIEnabled(bool is_enabled) { 137 void WebUILoginDisplay::SetUIEnabled(bool is_enabled) {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 360 }
365 361
366 bool WebUILoginDisplay::IsShowGuest() const { 362 bool WebUILoginDisplay::IsShowGuest() const {
367 return show_guest_; 363 return show_guest_;
368 } 364 }
369 365
370 bool WebUILoginDisplay::IsShowUsers() const { 366 bool WebUILoginDisplay::IsShowUsers() const {
371 return show_users_; 367 return show_users_;
372 } 368 }
373 369
374 bool WebUILoginDisplay::IsShowNewUser() const {
375 return show_new_user_;
376 }
377
378 bool WebUILoginDisplay::IsSigninInProgress() const { 370 bool WebUILoginDisplay::IsSigninInProgress() const {
379 return delegate_->IsSigninInProgress(); 371 return delegate_->IsSigninInProgress();
380 } 372 }
381 373
382 bool WebUILoginDisplay::IsUserSigninCompleted() const { 374 bool WebUILoginDisplay::IsUserSigninCompleted() const {
383 return is_signin_completed(); 375 return is_signin_completed();
384 } 376 }
385 377
386 void WebUILoginDisplay::SetDisplayEmail(const std::string& email) { 378 void WebUILoginDisplay::SetDisplayEmail(const std::string& email) {
387 if (delegate_) 379 if (delegate_)
388 delegate_->SetDisplayEmail(email); 380 delegate_->SetDisplayEmail(email);
389 } 381 }
390 382
391 void WebUILoginDisplay::Signout() { 383 void WebUILoginDisplay::Signout() {
392 delegate_->Signout(); 384 delegate_->Signout();
393 } 385 }
394 386
395 void WebUILoginDisplay::LoginAsKioskApp(const std::string& app_id, 387 void WebUILoginDisplay::LoginAsKioskApp(const std::string& app_id,
396 bool diagnostic_mode) { 388 bool diagnostic_mode) {
397 delegate_->LoginAsKioskApp(app_id, diagnostic_mode); 389 delegate_->LoginAsKioskApp(app_id, diagnostic_mode);
398 } 390 }
399 391
400 void WebUILoginDisplay::OnUserActivity(const ui::Event* event) { 392 void WebUILoginDisplay::OnUserActivity(const ui::Event* event) {
401 if (!password_clear_timer_.IsRunning())
402 StartPasswordClearTimer();
403 password_clear_timer_.Reset();
404 if (delegate_) 393 if (delegate_)
405 delegate_->ResetPublicSessionAutoLoginTimer(); 394 delegate_->ResetPublicSessionAutoLoginTimer();
406 } 395 }
407 396
408 void WebUILoginDisplay::StartPasswordClearTimer() {
409 DCHECK(!password_clear_timer_.IsRunning());
410 password_clear_timer_.Start(FROM_HERE,
411 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), this,
412 &WebUILoginDisplay::OnPasswordClearTimerExpired);
413 }
414
415 void WebUILoginDisplay::OnPasswordClearTimerExpired() {
416 if (webui_handler_)
417 webui_handler_->ClearUserPodPassword();
418 }
419 397
420 } // namespace chromeos 398 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698