OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <set> | 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
18 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" | 19 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" |
19 #include "chrome/browser/chromeos/login/login_display.h" | 20 #include "chrome/browser/chromeos/login/login_display.h" |
20 #include "chrome/browser/chromeos/login/screens/error_screen_actor.h" | 21 #include "chrome/browser/chromeos/login/screens/error_screen_actor.h" |
21 #include "chrome/browser/chromeos/login/user_manager.h" | 22 #include "chrome/browser/chromeos/login/user_manager.h" |
22 #include "chrome/browser/chromeos/net/network_portal_detector.h" | 23 #include "chrome/browser/chromeos/net/network_portal_detector.h" |
23 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 25 #include "chrome/browser/signin/screenlock_bridge.h" |
24 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" | 26 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" |
25 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" | 27 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" |
26 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" | 28 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
27 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 29 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
28 #include "content/public/browser/notification_observer.h" | 30 #include "content/public/browser/notification_observer.h" |
29 #include "content/public/browser/notification_registrar.h" | 31 #include "content/public/browser/notification_registrar.h" |
30 #include "content/public/browser/web_ui.h" | 32 #include "content/public/browser/web_ui.h" |
31 #include "net/base/net_errors.h" | 33 #include "net/base/net_errors.h" |
32 #include "ui/events/event_handler.h" | 34 #include "ui/events/event_handler.h" |
33 | 35 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // An interface for WebUILoginDisplay to call SigninScreenHandler. | 70 // An interface for WebUILoginDisplay to call SigninScreenHandler. |
69 class LoginDisplayWebUIHandler { | 71 class LoginDisplayWebUIHandler { |
70 public: | 72 public: |
71 virtual void ClearAndEnablePassword() = 0; | 73 virtual void ClearAndEnablePassword() = 0; |
72 virtual void ClearUserPodPassword() = 0; | 74 virtual void ClearUserPodPassword() = 0; |
73 virtual void OnLoginSuccess(const std::string& username) = 0; | 75 virtual void OnLoginSuccess(const std::string& username) = 0; |
74 virtual void OnUserRemoved(const std::string& username) = 0; | 76 virtual void OnUserRemoved(const std::string& username) = 0; |
75 virtual void OnUserImageChanged(const User& user) = 0; | 77 virtual void OnUserImageChanged(const User& user) = 0; |
76 virtual void OnPreferencesChanged() = 0; | 78 virtual void OnPreferencesChanged() = 0; |
77 virtual void ResetSigninScreenHandlerDelegate() = 0; | 79 virtual void ResetSigninScreenHandlerDelegate() = 0; |
78 virtual void ShowBannerMessage(const std::string& message) = 0; | |
79 virtual void ShowUserPodButton(const std::string& username, | |
80 const std::string& iconURL, | |
81 const base::Closure& click_callback) = 0; | |
82 virtual void HideUserPodButton(const std::string& username) = 0; | |
83 virtual void SetAuthType(const std::string& username, | |
84 LoginDisplay::AuthType auth_type, | |
85 const std::string& initial_value) = 0; | |
86 virtual LoginDisplay::AuthType GetAuthType(const std::string& username) | |
87 const = 0; | |
88 virtual void ShowError(int login_attempts, | 80 virtual void ShowError(int login_attempts, |
89 const std::string& error_text, | 81 const std::string& error_text, |
90 const std::string& help_link_text, | 82 const std::string& help_link_text, |
91 HelpAppLauncher::HelpTopic help_topic_id) = 0; | 83 HelpAppLauncher::HelpTopic help_topic_id) = 0; |
92 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0; | 84 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0; |
93 virtual void ShowGaiaPasswordChanged(const std::string& username) = 0; | 85 virtual void ShowGaiaPasswordChanged(const std::string& username) = 0; |
94 virtual void ShowSigninUI(const std::string& email) = 0; | 86 virtual void ShowSigninUI(const std::string& email) = 0; |
95 virtual void ShowControlBar(bool show) = 0; | 87 virtual void ShowControlBar(bool show) = 0; |
96 virtual void ShowPasswordChangedDialog(bool show_password_error) = 0; | 88 virtual void ShowPasswordChangedDialog(bool show_password_error) = 0; |
97 // Show sign-in screen for the given credentials. | 89 // Show sign-in screen for the given credentials. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 virtual ~SigninScreenHandlerDelegate() {} | 191 virtual ~SigninScreenHandlerDelegate() {} |
200 }; | 192 }; |
201 | 193 |
202 // A class that handles the WebUI hooks in sign-in screen in OobeDisplay | 194 // A class that handles the WebUI hooks in sign-in screen in OobeDisplay |
203 // and LoginDisplay. | 195 // and LoginDisplay. |
204 class SigninScreenHandler | 196 class SigninScreenHandler |
205 : public BaseScreenHandler, | 197 : public BaseScreenHandler, |
206 public LoginDisplayWebUIHandler, | 198 public LoginDisplayWebUIHandler, |
207 public content::NotificationObserver, | 199 public content::NotificationObserver, |
208 public ui::EventHandler, | 200 public ui::EventHandler, |
| 201 public ScreenlockBridge::LockHandler, |
209 public NetworkStateInformer::NetworkStateInformerObserver { | 202 public NetworkStateInformer::NetworkStateInformerObserver { |
210 public: | 203 public: |
211 SigninScreenHandler( | 204 SigninScreenHandler( |
212 const scoped_refptr<NetworkStateInformer>& network_state_informer, | 205 const scoped_refptr<NetworkStateInformer>& network_state_informer, |
213 ErrorScreenActor* error_screen_actor, | 206 ErrorScreenActor* error_screen_actor, |
214 CoreOobeActor* core_oobe_actor, | 207 CoreOobeActor* core_oobe_actor, |
215 GaiaScreenHandler* gaia_screen_handler); | 208 GaiaScreenHandler* gaia_screen_handler); |
216 virtual ~SigninScreenHandler(); | 209 virtual ~SigninScreenHandler(); |
217 | 210 |
218 // Shows the sign in screen. | 211 // Shows the sign in screen. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 virtual void RegisterMessages() OVERRIDE; | 266 virtual void RegisterMessages() OVERRIDE; |
274 | 267 |
275 // LoginDisplayWebUIHandler implementation: | 268 // LoginDisplayWebUIHandler implementation: |
276 virtual void ClearAndEnablePassword() OVERRIDE; | 269 virtual void ClearAndEnablePassword() OVERRIDE; |
277 virtual void ClearUserPodPassword() OVERRIDE; | 270 virtual void ClearUserPodPassword() OVERRIDE; |
278 virtual void OnLoginSuccess(const std::string& username) OVERRIDE; | 271 virtual void OnLoginSuccess(const std::string& username) OVERRIDE; |
279 virtual void OnUserRemoved(const std::string& username) OVERRIDE; | 272 virtual void OnUserRemoved(const std::string& username) OVERRIDE; |
280 virtual void OnUserImageChanged(const User& user) OVERRIDE; | 273 virtual void OnUserImageChanged(const User& user) OVERRIDE; |
281 virtual void OnPreferencesChanged() OVERRIDE; | 274 virtual void OnPreferencesChanged() OVERRIDE; |
282 virtual void ResetSigninScreenHandlerDelegate() OVERRIDE; | 275 virtual void ResetSigninScreenHandlerDelegate() OVERRIDE; |
283 virtual void ShowBannerMessage(const std::string& message) OVERRIDE; | |
284 virtual void ShowUserPodButton(const std::string& username, | |
285 const std::string& iconURL, | |
286 const base::Closure& click_callback) OVERRIDE; | |
287 virtual void HideUserPodButton(const std::string& username) OVERRIDE; | |
288 virtual void SetAuthType(const std::string& username, | |
289 LoginDisplay::AuthType auth_type, | |
290 const std::string& initial_value) OVERRIDE; | |
291 virtual LoginDisplay::AuthType GetAuthType(const std::string& username) | |
292 const OVERRIDE; | |
293 virtual void ShowError(int login_attempts, | 276 virtual void ShowError(int login_attempts, |
294 const std::string& error_text, | 277 const std::string& error_text, |
295 const std::string& help_link_text, | 278 const std::string& help_link_text, |
296 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; | 279 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; |
297 virtual void ShowGaiaPasswordChanged(const std::string& username) OVERRIDE; | 280 virtual void ShowGaiaPasswordChanged(const std::string& username) OVERRIDE; |
298 virtual void ShowSigninUI(const std::string& email) OVERRIDE; | 281 virtual void ShowSigninUI(const std::string& email) OVERRIDE; |
299 virtual void ShowControlBar(bool show) OVERRIDE; | 282 virtual void ShowControlBar(bool show) OVERRIDE; |
300 virtual void ShowPasswordChangedDialog(bool show_password_error) OVERRIDE; | 283 virtual void ShowPasswordChangedDialog(bool show_password_error) OVERRIDE; |
301 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) OVERRIDE; | 284 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) OVERRIDE; |
302 virtual void ShowSigninScreenForCreds(const std::string& username, | 285 virtual void ShowSigninScreenForCreds(const std::string& username, |
303 const std::string& password) OVERRIDE; | 286 const std::string& password) OVERRIDE; |
304 | 287 |
305 // ui::EventHandler implementation: | 288 // ui::EventHandler implementation: |
306 virtual void OnKeyEvent(ui::KeyEvent* key) OVERRIDE; | 289 virtual void OnKeyEvent(ui::KeyEvent* key) OVERRIDE; |
307 | 290 |
308 // content::NotificationObserver implementation: | 291 // content::NotificationObserver implementation: |
309 virtual void Observe(int type, | 292 virtual void Observe(int type, |
310 const content::NotificationSource& source, | 293 const content::NotificationSource& source, |
311 const content::NotificationDetails& details) OVERRIDE; | 294 const content::NotificationDetails& details) OVERRIDE; |
312 | 295 |
| 296 // ScreenlockBridge::LockHandler implementation: |
| 297 virtual void ShowBannerMessage(const std::string& message) OVERRIDE; |
| 298 virtual void ShowUserPodButton(const std::string& username, |
| 299 const gfx::Image& icon) OVERRIDE; |
| 300 virtual void HideUserPodButton(const std::string& username) OVERRIDE; |
| 301 virtual void EnableInput() OVERRIDE; |
| 302 virtual void SetAuthType(const std::string& username, |
| 303 ScreenlockBridge::LockHandler::AuthType auth_type, |
| 304 const std::string& initial_value) OVERRIDE; |
| 305 virtual ScreenlockBridge::LockHandler::AuthType GetAuthType( |
| 306 const std::string& username) const OVERRIDE; |
| 307 virtual void Unlock(const std::string& user_email) OVERRIDE; |
| 308 |
313 // Shows signin screen after dns cache and cookie cleanup operations finish. | 309 // Shows signin screen after dns cache and cookie cleanup operations finish. |
314 void ShowSigninScreenIfReady(); | 310 void ShowSigninScreenIfReady(); |
315 | 311 |
316 // Tells webui to load authentication extension. |force| is used to force the | 312 // Tells webui to load authentication extension. |force| is used to force the |
317 // extension reloading, if it has already been loaded. |silent_load| is true | 313 // extension reloading, if it has already been loaded. |silent_load| is true |
318 // for cases when extension should be loaded in the background and it | 314 // for cases when extension should be loaded in the background and it |
319 // shouldn't grab the focus. |offline| is true when offline version of the | 315 // shouldn't grab the focus. |offline| is true when offline version of the |
320 // extension should be used. | 316 // extension should be used. |
321 void LoadAuthExtension(bool force, bool silent_load, bool offline); | 317 void LoadAuthExtension(bool force, bool silent_load, bool offline); |
322 | 318 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 void HandleMigrateUserData(const std::string& password); | 362 void HandleMigrateUserData(const std::string& password); |
367 void HandleResyncUserData(); | 363 void HandleResyncUserData(); |
368 void HandleLoginUIStateChanged(const std::string& source, bool new_value); | 364 void HandleLoginUIStateChanged(const std::string& source, bool new_value); |
369 void HandleUnlockOnLoginSuccess(); | 365 void HandleUnlockOnLoginSuccess(); |
370 void HandleLoginScreenUpdate(); | 366 void HandleLoginScreenUpdate(); |
371 void HandleShowLoadingTimeoutError(); | 367 void HandleShowLoadingTimeoutError(); |
372 void HandleUpdateOfflineLogin(bool offline_login_active); | 368 void HandleUpdateOfflineLogin(bool offline_login_active); |
373 void HandleShowLocallyManagedUserCreationScreen(); | 369 void HandleShowLocallyManagedUserCreationScreen(); |
374 void HandleFocusPod(const std::string& user_id); | 370 void HandleFocusPod(const std::string& user_id); |
375 void HandleLaunchKioskApp(const std::string& app_id, bool diagnostic_mode); | 371 void HandleLaunchKioskApp(const std::string& app_id, bool diagnostic_mode); |
376 void HandleCustomButtonClicked(const std::string& username); | |
377 void HandleRetrieveAuthenticatedUserEmail(double attempt_token); | 372 void HandleRetrieveAuthenticatedUserEmail(double attempt_token); |
378 | 373 |
379 // Fills |user_dict| with information about |user|. | 374 // Fills |user_dict| with information about |user|. |
380 static void FillUserDictionary(User* user, | 375 static void FillUserDictionary( |
381 bool is_owner, | 376 User* user, |
382 bool is_signin_to_add, | 377 bool is_owner, |
383 LoginDisplay::AuthType auth_type, | 378 bool is_signin_to_add, |
384 base::DictionaryValue* user_dict); | 379 ScreenlockBridge::LockHandler::AuthType auth_type, |
| 380 base::DictionaryValue* user_dict); |
385 | 381 |
386 // Sends user list to account picker. | 382 // Sends user list to account picker. |
387 void SendUserList(bool animated); | 383 void SendUserList(bool animated); |
388 | 384 |
389 // Kick off cookie / local storage cleanup. | 385 // Kick off cookie / local storage cleanup. |
390 void StartClearingCookies(const base::Closure& on_clear_callback); | 386 void StartClearingCookies(const base::Closure& on_clear_callback); |
391 void OnCookiesCleared(base::Closure on_clear_callback); | 387 void OnCookiesCleared(base::Closure on_clear_callback); |
392 | 388 |
393 // Kick off DNS cache flushing. | 389 // Kick off DNS cache flushing. |
394 void StartClearingDnsCache(); | 390 void StartClearingDnsCache(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 522 |
527 scoped_ptr<CrosSettings::ObserverSubscription> allow_new_user_subscription_; | 523 scoped_ptr<CrosSettings::ObserverSubscription> allow_new_user_subscription_; |
528 scoped_ptr<CrosSettings::ObserverSubscription> allow_guest_subscription_; | 524 scoped_ptr<CrosSettings::ObserverSubscription> allow_guest_subscription_; |
529 scoped_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription> | 525 scoped_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription> |
530 auto_enrollment_progress_subscription_; | 526 auto_enrollment_progress_subscription_; |
531 | 527 |
532 bool caps_lock_enabled_; | 528 bool caps_lock_enabled_; |
533 | 529 |
534 base::Closure kiosk_enable_flow_aborted_callback_for_test_; | 530 base::Closure kiosk_enable_flow_aborted_callback_for_test_; |
535 | 531 |
536 // Map of callbacks run when the custom button on a user pod is clicked. | |
537 std::map<std::string, base::Closure> user_pod_button_callback_map_; | |
538 | |
539 // Map of usernames to their current authentication type. If a user is not | 532 // Map of usernames to their current authentication type. If a user is not |
540 // contained in the map, it is using the default authentication type. | 533 // contained in the map, it is using the default authentication type. |
541 std::map<std::string, LoginDisplay::AuthType> user_auth_type_map_; | 534 std::map<std::string, ScreenlockBridge::LockHandler::AuthType> |
| 535 user_auth_type_map_; |
542 | 536 |
543 // Non-owning ptr. | 537 // Non-owning ptr. |
544 // TODO (ygorshenin@): remove this dependency. | 538 // TODO (ygorshenin@): remove this dependency. |
545 GaiaScreenHandler* gaia_screen_handler_; | 539 GaiaScreenHandler* gaia_screen_handler_; |
546 | 540 |
547 // Helper that retrieves the authenticated user's e-mail address. | 541 // Helper that retrieves the authenticated user's e-mail address. |
548 scoped_ptr<AuthenticatedUserEmailRetriever> email_retriever_; | 542 scoped_ptr<AuthenticatedUserEmailRetriever> email_retriever_; |
549 | 543 |
550 DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler); | 544 DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler); |
551 }; | 545 }; |
552 | 546 |
553 } // namespace chromeos | 547 } // namespace chromeos |
554 | 548 |
555 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ | 549 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ |
OLD | NEW |