| 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_LOGIN_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LOGIN_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LOGIN_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LOGIN_UI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/chromeos/login/help_app_launcher.h" | 12 #include "chrome/browser/chromeos/login/help_app_launcher.h" |
| 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | |
| 14 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 13 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 15 | 14 |
| 15 class RefCountedMemory; |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 class HTMLOperationsInterface; | |
| 21 | |
| 22 // Boilerplate class that is used to associate the LoginUI code with the URL | |
| 23 // "chrome://login" | |
| 24 class LoginUIHTMLSource : public ChromeURLDataManager::DataSource { | |
| 25 public: | |
| 26 explicit LoginUIHTMLSource(MessageLoop* message_loop); | |
| 27 virtual ~LoginUIHTMLSource(); | |
| 28 | |
| 29 virtual void StartDataRequest(const std::string& path, | |
| 30 bool is_incognito, | |
| 31 int request_id); | |
| 32 virtual std::string GetMimeType(const std::string&) const; | |
| 33 | |
| 34 private: | |
| 35 scoped_ptr<HTMLOperationsInterface> html_operations_; | |
| 36 | |
| 37 DISALLOW_COPY_AND_ASSIGN(LoginUIHTMLSource); | |
| 38 }; | |
| 39 | |
| 40 // An interface between WebUILoginDisplay and LoginUIHandler. | |
| 41 class BaseLoginUIHandler { | |
| 42 public: | |
| 43 virtual void ClearAndEnablePassword() = 0; | |
| 44 virtual void ShowError(const std::string& error_text, | |
| 45 const std::string& help_link_text, | |
| 46 HelpAppLauncher::HelpTopic help_topic_id) = 0; | |
| 47 }; | |
| 48 | |
| 49 class LoginUIHandlerDelegate { | |
| 50 public: | |
| 51 LoginUIHandlerDelegate() | |
| 52 : login_handler_(NULL) { } | |
| 53 | |
| 54 // Sign in using |username| and |password| specified. | |
| 55 // Used for both known and new users. | |
| 56 virtual void Login(const std::string& username, | |
| 57 const std::string& password) = 0; | |
| 58 | |
| 59 // Sign in into Guest session. | |
| 60 virtual void LoginAsGuest() = 0; | |
| 61 | |
| 62 // Let the delegate know about the handler it is supposed to be using. | |
| 63 virtual void set_login_handler(BaseLoginUIHandler* login_handler); | |
| 64 | |
| 65 protected: | |
| 66 // Reference to the WebUI handling layer for the login screen | |
| 67 BaseLoginUIHandler* login_handler_; | |
| 68 | |
| 69 virtual ~LoginUIHandlerDelegate(); | |
| 70 }; | |
| 71 | |
| 72 // Main LoginUI handling function. It handles the WebUI hooks that are supplied | |
| 73 // for the login page to use for authentication. | |
| 74 class LoginUIHandler : public WebUIMessageHandler, | |
| 75 public BaseLoginUIHandler { | |
| 76 public: | |
| 77 LoginUIHandler(); | |
| 78 virtual ~LoginUIHandler(); | |
| 79 | |
| 80 // WebUIMessageHandler implementation. | |
| 81 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; | |
| 82 virtual void RegisterMessages() OVERRIDE; | |
| 83 | |
| 84 protected: | |
| 85 LoginUIHandlerDelegate* delegate_; | |
| 86 | |
| 87 private: | |
| 88 // BaseLoginUIHandler implementation. | |
| 89 virtual void ClearAndEnablePassword() OVERRIDE; | |
| 90 virtual void ShowError(const std::string& error_text, | |
| 91 const std::string& help_link_text, | |
| 92 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; | |
| 93 | |
| 94 // Callbacks from javascript. | |
| 95 void HandleGetUsers(const base::ListValue* args); | |
| 96 void HandleAuthenticateUser(const base::ListValue* args); | |
| 97 void HandleLaunchIncognito(const base::ListValue* args); | |
| 98 void HandleShutdownSystem(const base::ListValue* args); | |
| 99 void HandleRemoveUser(const base::ListValue* args); | |
| 100 | |
| 101 DISALLOW_COPY_AND_ASSIGN(LoginUIHandler); | |
| 102 }; | |
| 103 | |
| 104 // Boilerplate class that is used to associate the LoginUI code with the WebUI | 20 // Boilerplate class that is used to associate the LoginUI code with the WebUI |
| 105 // code. | 21 // code. |
| 106 class LoginUI : public ChromeWebUI { | 22 class LoginUI : public ChromeWebUI { |
| 107 public: | 23 public: |
| 108 explicit LoginUI(TabContents* contents); | 24 explicit LoginUI(TabContents* contents); |
| 109 | 25 |
| 110 // Return the URL for a given search term. | 26 // Return the URL for a given search term. |
| 111 static const GURL GetLoginURLWithSearchText(const string16& text); | 27 static const GURL GetLoginURLWithSearchText(const string16& text); |
| 112 | 28 |
| 113 static RefCountedMemory* GetFaviconResourceBytes(); | 29 static RefCountedMemory* GetFaviconResourceBytes(); |
| 114 | 30 |
| 115 private: | 31 private: |
| 116 DISALLOW_COPY_AND_ASSIGN(LoginUI); | 32 DISALLOW_COPY_AND_ASSIGN(LoginUI); |
| 117 }; | 33 }; |
| 118 | 34 |
| 119 } // namespace chromeos | 35 } // namespace chromeos |
| 120 | 36 |
| 121 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LOGIN_UI_H_ | 37 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LOGIN_UI_H_ |
| OLD | NEW |