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()) { |
50 } | 52 } |
51 | 53 |
52 void WebUILoginDisplay::ClearAndEnablePassword() { | 54 void WebUILoginDisplay::ClearAndEnablePassword() { |
53 if (webui_handler_) | 55 if (webui_handler_) |
54 webui_handler_->ClearAndEnablePassword(); | 56 webui_handler_->ClearAndEnablePassword(); |
55 } | 57 } |
56 | 58 |
57 void WebUILoginDisplay::Init(const UserList& users, | 59 void WebUILoginDisplay::Init(const UserList& users, |
58 bool show_guest, | 60 bool show_guest, |
59 bool show_users, | 61 bool show_users, |
60 bool show_new_user) { | 62 bool show_new_user) { |
61 // Testing that the delegate has been set. | 63 // Testing that the delegate has been set. |
62 DCHECK(delegate_); | 64 DCHECK(delegate_); |
63 | 65 |
64 users_ = users; | 66 user_selection_screen_->Init(users); |
65 show_guest_ = show_guest; | 67 show_guest_ = show_guest; |
66 show_users_ = show_users; | 68 show_users_ = show_users; |
67 show_new_user_ = show_new_user; | 69 show_new_user_ = show_new_user; |
68 | 70 |
69 wm::UserActivityDetector* activity_detector = ash::Shell::GetInstance()-> | 71 wm::UserActivityDetector* activity_detector = ash::Shell::GetInstance()-> |
70 user_activity_detector(); | 72 user_activity_detector(); |
71 if (!activity_detector->HasObserver(this)) | 73 if (!activity_detector->HasObserver(this)) |
72 activity_detector->AddObserver(this); | 74 activity_detector->AddObserver(this); |
73 } | 75 } |
74 | 76 |
| 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 |
75 void WebUILoginDisplay::OnPreferencesChanged() { | 103 void WebUILoginDisplay::OnPreferencesChanged() { |
76 if (webui_handler_) | 104 if (webui_handler_) |
77 webui_handler_->OnPreferencesChanged(); | 105 webui_handler_->OnPreferencesChanged(); |
78 } | 106 } |
79 | 107 |
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 | |
107 void WebUILoginDisplay::SetUIEnabled(bool is_enabled) { | 108 void WebUILoginDisplay::SetUIEnabled(bool is_enabled) { |
108 // TODO(nkostylev): Cleanup this condition, | 109 // TODO(nkostylev): Cleanup this condition, |
109 // see http://crbug.com/157885 and http://crbug.com/158255. | 110 // see http://crbug.com/157885 and http://crbug.com/158255. |
110 // Allow this call only before user sign in or at lock screen. | 111 // Allow this call only before user sign in or at lock screen. |
111 // If this call is made after new user signs in but login screen is still | 112 // If this call is made after new user signs in but login screen is still |
112 // around that would trigger a sign in extension refresh. | 113 // around that would trigger a sign in extension refresh. |
113 if (is_enabled && | 114 if (is_enabled && (!UserManager::Get()->IsUserLoggedIn() || |
114 (!UserManager::Get()->IsUserLoggedIn() || | 115 ScreenLocker::default_screen_locker())) { |
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 | |
129 void WebUILoginDisplay::ShowError(int error_msg_id, | 126 void WebUILoginDisplay::ShowError(int error_msg_id, |
130 int login_attempts, | 127 int login_attempts, |
131 HelpAppLauncher::HelpTopic help_topic_id) { | 128 HelpAppLauncher::HelpTopic help_topic_id) { |
132 VLOG(1) << "Show error, error_id: " << error_msg_id | 129 VLOG(1) << "Show error, error_id: " << error_msg_id |
133 << ", attempts:" << login_attempts | 130 << ", attempts:" << login_attempts |
134 << ", help_topic_id: " << help_topic_id; | 131 << ", help_topic_id: " << help_topic_id; |
135 if (!webui_handler_) | 132 if (!webui_handler_) |
136 return; | 133 return; |
137 | 134 |
138 std::string error_text; | 135 std::string error_text; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 312 } |
316 | 313 |
317 void WebUILoginDisplay::ShowWrongHWIDScreen() { | 314 void WebUILoginDisplay::ShowWrongHWIDScreen() { |
318 if (delegate_) | 315 if (delegate_) |
319 delegate_->ShowWrongHWIDScreen(); | 316 delegate_->ShowWrongHWIDScreen(); |
320 } | 317 } |
321 | 318 |
322 void WebUILoginDisplay::SetWebUIHandler( | 319 void WebUILoginDisplay::SetWebUIHandler( |
323 LoginDisplayWebUIHandler* webui_handler) { | 320 LoginDisplayWebUIHandler* webui_handler) { |
324 webui_handler_ = webui_handler; | 321 webui_handler_ = webui_handler; |
| 322 gaia_screen_->SetHandler(webui_handler_); |
| 323 user_selection_screen_->SetHandler(webui_handler_); |
325 } | 324 } |
326 | 325 |
327 void WebUILoginDisplay::ShowSigninScreenForCreds( | 326 void WebUILoginDisplay::ShowSigninScreenForCreds( |
328 const std::string& username, | 327 const std::string& username, |
329 const std::string& password) { | 328 const std::string& password) { |
330 if (webui_handler_) | 329 if (webui_handler_) |
331 webui_handler_->ShowSigninScreenForCreds(username, password); | 330 webui_handler_->ShowSigninScreenForCreds(username, password); |
332 } | 331 } |
333 | 332 |
334 const UserList& WebUILoginDisplay::GetUsers() const { | |
335 return users_; | |
336 } | |
337 | |
338 bool WebUILoginDisplay::IsShowGuest() const { | 333 bool WebUILoginDisplay::IsShowGuest() const { |
339 return show_guest_; | 334 return show_guest_; |
340 } | 335 } |
341 | 336 |
342 bool WebUILoginDisplay::IsShowUsers() const { | 337 bool WebUILoginDisplay::IsShowUsers() const { |
343 return show_users_; | 338 return show_users_; |
344 } | 339 } |
345 | 340 |
346 bool WebUILoginDisplay::IsShowNewUser() const { | 341 bool WebUILoginDisplay::IsShowNewUser() const { |
347 return show_new_user_; | 342 return show_new_user_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), this, | 378 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), this, |
384 &WebUILoginDisplay::OnPasswordClearTimerExpired); | 379 &WebUILoginDisplay::OnPasswordClearTimerExpired); |
385 } | 380 } |
386 | 381 |
387 void WebUILoginDisplay::OnPasswordClearTimerExpired() { | 382 void WebUILoginDisplay::OnPasswordClearTimerExpired() { |
388 if (webui_handler_) | 383 if (webui_handler_) |
389 webui_handler_->ClearUserPodPassword(); | 384 webui_handler_->ClearUserPodPassword(); |
390 } | 385 } |
391 | 386 |
392 } // namespace chromeos | 387 } // namespace chromeos |
OLD | NEW |