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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 if (activity_detector->HasObserver(this)) | 39 if (activity_detector->HasObserver(this)) |
40 activity_detector->RemoveObserver(this); | 40 activity_detector->RemoveObserver(this); |
41 } | 41 } |
42 | 42 |
43 // LoginDisplay implementation: ------------------------------------------------ | 43 // LoginDisplay implementation: ------------------------------------------------ |
44 | 44 |
45 WebUILoginDisplay::WebUILoginDisplay(LoginDisplay::Delegate* delegate) | 45 WebUILoginDisplay::WebUILoginDisplay(LoginDisplay::Delegate* delegate) |
46 : LoginDisplay(delegate, gfx::Rect()), | 46 : LoginDisplay(delegate, gfx::Rect()), |
47 show_guest_(false), | 47 show_guest_(false), |
48 show_new_user_(false), | 48 show_new_user_(false), |
49 webui_handler_(NULL), | 49 webui_handler_(NULL) { |
50 gaia_screen_(new GaiaScreen()), | |
51 user_selection_screen_(new UserSelectionScreen()) { | |
52 } | 50 } |
53 | 51 |
54 void WebUILoginDisplay::ClearAndEnablePassword() { | 52 void WebUILoginDisplay::ClearAndEnablePassword() { |
55 if (webui_handler_) | 53 if (webui_handler_) |
56 webui_handler_->ClearAndEnablePassword(); | 54 webui_handler_->ClearAndEnablePassword(); |
57 } | 55 } |
58 | 56 |
59 void WebUILoginDisplay::Init(const UserList& users, | 57 void WebUILoginDisplay::Init(const UserList& users, |
60 bool show_guest, | 58 bool show_guest, |
61 bool show_users, | 59 bool show_users, |
62 bool show_new_user) { | 60 bool show_new_user) { |
63 // Testing that the delegate has been set. | 61 // Testing that the delegate has been set. |
64 DCHECK(delegate_); | 62 DCHECK(delegate_); |
65 | 63 |
66 user_selection_screen_->Init(users); | 64 users_ = users; |
67 show_guest_ = show_guest; | 65 show_guest_ = show_guest; |
68 show_users_ = show_users; | 66 show_users_ = show_users; |
69 show_new_user_ = show_new_user; | 67 show_new_user_ = show_new_user; |
70 | 68 |
71 wm::UserActivityDetector* activity_detector = ash::Shell::GetInstance()-> | 69 wm::UserActivityDetector* activity_detector = ash::Shell::GetInstance()-> |
72 user_activity_detector(); | 70 user_activity_detector(); |
73 if (!activity_detector->HasObserver(this)) | 71 if (!activity_detector->HasObserver(this)) |
74 activity_detector->AddObserver(this); | 72 activity_detector->AddObserver(this); |
75 } | 73 } |
76 | 74 |
77 // ---- Common methods | |
78 | |
79 // ---- User selection screen methods | |
80 | |
81 void WebUILoginDisplay::OnBeforeUserRemoved(const std::string& username) { | |
82 user_selection_screen_->OnBeforeUserRemoved(username); | |
83 } | |
84 | |
85 void WebUILoginDisplay::OnUserRemoved(const std::string& username) { | |
86 user_selection_screen_->OnUserRemoved(username); | |
87 } | |
88 | |
89 void WebUILoginDisplay::OnUserImageChanged(const User& user) { | |
90 user_selection_screen_->OnUserImageChanged(user); | |
91 } | |
92 | |
93 // User selection screen, screen lock API | |
94 | |
95 const UserList& WebUILoginDisplay::GetUsers() const { | |
96 return user_selection_screen_->GetUsers(); | |
97 } | |
98 | |
99 // ---- Gaia screen methods | |
100 | |
101 // ---- Not yet classified methods | |
102 | |
103 void WebUILoginDisplay::OnPreferencesChanged() { | 75 void WebUILoginDisplay::OnPreferencesChanged() { |
104 if (webui_handler_) | 76 if (webui_handler_) |
105 webui_handler_->OnPreferencesChanged(); | 77 webui_handler_->OnPreferencesChanged(); |
106 } | 78 } |
107 | 79 |
| 80 void WebUILoginDisplay::OnBeforeUserRemoved(const std::string& username) { |
| 81 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { |
| 82 if ((*it)->email() == username) { |
| 83 users_.erase(it); |
| 84 break; |
| 85 } |
| 86 } |
| 87 } |
| 88 |
| 89 void WebUILoginDisplay::OnUserImageChanged(const User& user) { |
| 90 if (webui_handler_) |
| 91 webui_handler_->OnUserImageChanged(user); |
| 92 } |
| 93 |
| 94 void WebUILoginDisplay::OnUserRemoved(const std::string& username) { |
| 95 if (webui_handler_) |
| 96 webui_handler_->OnUserRemoved(username); |
| 97 } |
| 98 |
| 99 void WebUILoginDisplay::OnFadeOut() { |
| 100 } |
| 101 |
| 102 void WebUILoginDisplay::OnLoginSuccess(const std::string& username) { |
| 103 if (webui_handler_) |
| 104 webui_handler_->OnLoginSuccess(username); |
| 105 } |
| 106 |
108 void WebUILoginDisplay::SetUIEnabled(bool is_enabled) { | 107 void WebUILoginDisplay::SetUIEnabled(bool is_enabled) { |
109 // TODO(nkostylev): Cleanup this condition, | 108 // TODO(nkostylev): Cleanup this condition, |
110 // see http://crbug.com/157885 and http://crbug.com/158255. | 109 // see http://crbug.com/157885 and http://crbug.com/158255. |
111 // Allow this call only before user sign in or at lock screen. | 110 // Allow this call only before user sign in or at lock screen. |
112 // If this call is made after new user signs in but login screen is still | 111 // If this call is made after new user signs in but login screen is still |
113 // around that would trigger a sign in extension refresh. | 112 // around that would trigger a sign in extension refresh. |
114 if (is_enabled && (!UserManager::Get()->IsUserLoggedIn() || | 113 if (is_enabled && |
115 ScreenLocker::default_screen_locker())) { | 114 (!UserManager::Get()->IsUserLoggedIn() || |
| 115 ScreenLocker::default_screen_locker())) { |
116 ClearAndEnablePassword(); | 116 ClearAndEnablePassword(); |
117 } | 117 } |
118 | 118 |
119 if (chromeos::LoginDisplayHost* host = | 119 if (chromeos::LoginDisplayHost* host = |
120 chromeos::LoginDisplayHostImpl::default_host()) { | 120 chromeos::LoginDisplayHostImpl::default_host()) { |
121 if (chromeos::WebUILoginView* login_view = host->GetWebUILoginView()) | 121 if (chromeos::WebUILoginView* login_view = host->GetWebUILoginView()) |
122 login_view->SetUIEnabled(is_enabled); | 122 login_view->SetUIEnabled(is_enabled); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
| 126 void WebUILoginDisplay::SelectPod(int index) { |
| 127 } |
| 128 |
126 void WebUILoginDisplay::ShowError(int error_msg_id, | 129 void WebUILoginDisplay::ShowError(int error_msg_id, |
127 int login_attempts, | 130 int login_attempts, |
128 HelpAppLauncher::HelpTopic help_topic_id) { | 131 HelpAppLauncher::HelpTopic help_topic_id) { |
129 VLOG(1) << "Show error, error_id: " << error_msg_id | 132 VLOG(1) << "Show error, error_id: " << error_msg_id |
130 << ", attempts:" << login_attempts | 133 << ", attempts:" << login_attempts |
131 << ", help_topic_id: " << help_topic_id; | 134 << ", help_topic_id: " << help_topic_id; |
132 if (!webui_handler_) | 135 if (!webui_handler_) |
133 return; | 136 return; |
134 | 137 |
135 std::string error_text; | 138 std::string error_text; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 315 } |
313 | 316 |
314 void WebUILoginDisplay::ShowWrongHWIDScreen() { | 317 void WebUILoginDisplay::ShowWrongHWIDScreen() { |
315 if (delegate_) | 318 if (delegate_) |
316 delegate_->ShowWrongHWIDScreen(); | 319 delegate_->ShowWrongHWIDScreen(); |
317 } | 320 } |
318 | 321 |
319 void WebUILoginDisplay::SetWebUIHandler( | 322 void WebUILoginDisplay::SetWebUIHandler( |
320 LoginDisplayWebUIHandler* webui_handler) { | 323 LoginDisplayWebUIHandler* webui_handler) { |
321 webui_handler_ = webui_handler; | 324 webui_handler_ = webui_handler; |
322 gaia_screen_->SetHandler(webui_handler_); | |
323 user_selection_screen_->SetHandler(webui_handler_); | |
324 } | 325 } |
325 | 326 |
326 void WebUILoginDisplay::ShowSigninScreenForCreds( | 327 void WebUILoginDisplay::ShowSigninScreenForCreds( |
327 const std::string& username, | 328 const std::string& username, |
328 const std::string& password) { | 329 const std::string& password) { |
329 if (webui_handler_) | 330 if (webui_handler_) |
330 webui_handler_->ShowSigninScreenForCreds(username, password); | 331 webui_handler_->ShowSigninScreenForCreds(username, password); |
331 } | 332 } |
332 | 333 |
| 334 const UserList& WebUILoginDisplay::GetUsers() const { |
| 335 return users_; |
| 336 } |
| 337 |
333 bool WebUILoginDisplay::IsShowGuest() const { | 338 bool WebUILoginDisplay::IsShowGuest() const { |
334 return show_guest_; | 339 return show_guest_; |
335 } | 340 } |
336 | 341 |
337 bool WebUILoginDisplay::IsShowUsers() const { | 342 bool WebUILoginDisplay::IsShowUsers() const { |
338 return show_users_; | 343 return show_users_; |
339 } | 344 } |
340 | 345 |
341 bool WebUILoginDisplay::IsShowNewUser() const { | 346 bool WebUILoginDisplay::IsShowNewUser() const { |
342 return show_new_user_; | 347 return show_new_user_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), this, | 383 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), this, |
379 &WebUILoginDisplay::OnPasswordClearTimerExpired); | 384 &WebUILoginDisplay::OnPasswordClearTimerExpired); |
380 } | 385 } |
381 | 386 |
382 void WebUILoginDisplay::OnPasswordClearTimerExpired() { | 387 void WebUILoginDisplay::OnPasswordClearTimerExpired() { |
383 if (webui_handler_) | 388 if (webui_handler_) |
384 webui_handler_->ClearUserPodPassword(); | 389 webui_handler_->ClearUserPodPassword(); |
385 } | 390 } |
386 | 391 |
387 } // namespace chromeos | 392 } // namespace chromeos |
OLD | NEW |