Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/ui/webui/chromeos/login/login_ui.h" | 9 #include "chrome/browser/ui/webui/chromeos/login/login_ui.h" |
| 10 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 10 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" |
| 11 #include "content/browser/webui/web_ui.h" | 11 #include "content/browser/webui/web_ui.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 class DictionaryValue; | 14 class DictionaryValue; |
| 15 class ListValue; | 15 class ListValue; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 // Signin screen handler. | 20 // An interface for WebUILoginDisplay to call SigninScreenHandler. |
| 21 class SigninScreenHandler : public OobeMessageHandler, | 21 class LoginDisplayWebUIHandler { |
| 22 public BaseLoginUIHandler { | 22 public: |
| 23 virtual void ClearAndEnablePassword() = 0; | |
| 24 virtual void ShowError(const std::string& error_text, | |
| 25 const std::string& help_link_text, | |
| 26 HelpAppLauncher::HelpTopic help_topic_id) = 0; | |
| 27 }; | |
| 28 | |
| 29 // An interface for SigninScreenHandler to call WebUILoginDisplay. | |
|
Nikita (slow)
2011/07/15 07:11:02
nit: It has private data members so technically it
xiyuan
2011/07/15 18:26:23
You are right. Made it an interface.
| |
| 30 class SigninScreenHandlerDelegate { | |
| 31 public: | |
| 32 SigninScreenHandlerDelegate() | |
| 33 : webui_handler_(NULL) { } | |
| 34 | |
| 35 // Sign in using |username| and |password| specified. | |
| 36 // Used for both known and new users. | |
| 37 virtual void Login(const std::string& username, | |
| 38 const std::string& password) = 0; | |
| 39 | |
| 40 // Sign in into Guest session. | |
| 41 virtual void LoginAsGuest() = 0; | |
| 42 | |
| 43 // Let the delegate know about the handler it is supposed to be using. | |
| 44 void set_webui_handler(LoginDisplayWebUIHandler* webui_handler); | |
|
Nikita (slow)
2011/07/15 07:11:02
nit: Setter implementation should be located in .h
xiyuan
2011/07/15 18:26:23
Renamed to SetWebUIHandler and made it pure virtua
| |
| 45 | |
| 46 protected: | |
| 47 // Reference to the WebUI handling layer for the login screen | |
| 48 LoginDisplayWebUIHandler* webui_handler_; | |
| 49 | |
| 50 virtual ~SigninScreenHandlerDelegate(); | |
| 51 }; | |
| 52 | |
| 53 // A class that handles the WebUI hooks in sign-in screen in OobeDisplay | |
| 54 // and LoginDisplay. | |
| 55 class SigninScreenHandler : public BaseScreenHandler, | |
| 56 public LoginDisplayWebUIHandler { | |
| 23 public: | 57 public: |
| 24 SigninScreenHandler(); | 58 SigninScreenHandler(); |
| 25 | 59 |
| 26 // Shows the sign in screen. | 60 // Shows the sign in screen. |
| 27 void Show(); | 61 void Show(); |
| 28 | 62 |
| 29 private: | 63 private: |
| 30 // OobeMessageHandler implementation: | 64 // BaseScreenHandler implementation: |
| 31 virtual void GetLocalizedStrings( | 65 virtual void GetLocalizedStrings( |
| 32 base::DictionaryValue* localized_strings) OVERRIDE; | 66 base::DictionaryValue* localized_strings) OVERRIDE; |
| 33 virtual void Initialize() OVERRIDE; | 67 virtual void Initialize() OVERRIDE; |
| 34 | 68 |
| 35 // WebUIMessageHandler implementation: | 69 // WebUIMessageHandler implementation: |
| 36 virtual void RegisterMessages() OVERRIDE; | 70 virtual void RegisterMessages() OVERRIDE; |
| 37 | 71 |
| 38 // BaseLoginUIHandler implementation. | 72 // BaseLoginUIHandler implementation. |
| 39 virtual void ClearAndEnablePassword() OVERRIDE; | 73 virtual void ClearAndEnablePassword() OVERRIDE; |
| 40 virtual void ShowError(const std::string& error_text, | 74 virtual void ShowError(const std::string& error_text, |
| 41 const std::string& help_link_text, | 75 const std::string& help_link_text, |
| 42 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; | 76 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; |
| 43 | 77 |
| 44 // Handles authenticate user request from javascript. | 78 // Callbacks from javascript. |
| 79 void HandleGetUsers(const base::ListValue* args); | |
| 45 void HandleAuthenticateUser(const base::ListValue* args); | 80 void HandleAuthenticateUser(const base::ListValue* args); |
| 81 void HandleLaunchIncognito(const base::ListValue* args); | |
| 82 void HandleShutdownSystem(const base::ListValue* args); | |
| 83 void HandleRemoveUser(const base::ListValue* args); | |
| 46 | 84 |
| 47 // A delegate that glues this handler with backend LoginDisplay. | 85 // A delegate that glues this handler with backend LoginDisplay. |
| 48 LoginUIHandlerDelegate* delegate_; | 86 SigninScreenHandlerDelegate* delegate_; |
| 49 | 87 |
| 50 // Keeps whether screen should be shown right after initialization. | 88 // Whether screen should be shown right after initialization. |
| 51 bool show_on_init_; | 89 bool show_on_init_; |
| 52 | 90 |
| 53 DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler); | 91 DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler); |
| 54 }; | 92 }; |
| 55 | 93 |
| 56 } // namespae chromeoc | 94 } // namespae chromeoc |
| 57 | 95 |
| 58 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ | 96 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ |
| OLD | NEW |