| 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_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "chrome/browser/chromeos/login/login_display.h" | 14 #include "chrome/browser/chromeos/login/login_display.h" |
| 15 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/login/user_manager.h" |
| 16 #include "chrome/browser/ui/webui/chromeos/login/login_ui.h" | 16 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 17 #include "views/widget/widget.h" | 17 #include "views/widget/widget.h" |
| 18 | 18 |
| 19 namespace gfx { | 19 namespace gfx { |
| 20 class Rect; | 20 class Rect; |
| 21 } // namespace gfx | 21 } // namespace gfx |
| 22 | 22 |
| 23 namespace chromeos { | 23 namespace chromeos { |
| 24 // WebUI-based login UI implementation. | 24 // WebUI-based login UI implementation. |
| 25 // This class is a Singleton. It allows the LoginDisplayHost and LoginUIHandler | 25 // This class is a Singleton. It allows the LoginDisplayHost and LoginUIHandler |
| 26 // to access it without having to be coupled with each other. It is created with | 26 // to access it without having to be coupled with each other. It is created with |
| 27 // NULL for the delegate and a 0-size rectangle for the background | 27 // NULL for the delegate and a 0-size rectangle for the background |
| 28 // bounds. Before use these values should be set to a sane value. When done with | 28 // bounds. Before use these values should be set to a sane value. When done with |
| 29 // the object, the ExistingUserController should call Destroy and not free the | 29 // the object, the ExistingUserController should call Destroy and not free the |
| 30 // pointer, where as accessing classes should do nothing with the pointer. | 30 // pointer, where as accessing classes should do nothing with the pointer. |
| 31 // | 31 // |
| 32 // Expected order of commands to setup for LoginDisplayHost: | 32 // Expected order of commands to setup for LoginDisplayHost: |
| 33 // WebUILoginDisplay::GetInstance(); | 33 // WebUILoginDisplay::GetInstance(); |
| 34 // set_delegate(delegate); | 34 // set_delegate(delegate); |
| 35 // set_background_bounds(background_bounds()); | 35 // set_background_bounds(background_bounds()); |
| 36 // Init(); | 36 // Init(); |
| 37 // | 37 // |
| 38 // Expected order of commands to setup for LoginUIHandler: | 38 // Expected order of commands to setup for LoginUIHandler: |
| 39 // WebUILoginDisplay::GetInstance(); | 39 // WebUILoginDisplay::GetInstance(); |
| 40 // set_login_handler(this); | 40 // set_login_handler(this); |
| 41 | 41 |
| 42 class WebUILoginDisplay : public LoginDisplay, | 42 class WebUILoginDisplay : public LoginDisplay, |
| 43 public LoginUIHandlerDelegate { | 43 public SigninScreenHandlerDelegate { |
| 44 public: | 44 public: |
| 45 virtual ~WebUILoginDisplay(); | 45 virtual ~WebUILoginDisplay(); |
| 46 | 46 |
| 47 // Singleton implementation: | 47 // Singleton implementation: |
| 48 static WebUILoginDisplay* GetInstance(); | 48 static WebUILoginDisplay* GetInstance(); |
| 49 | 49 |
| 50 // Wrapper used to help in routing keyboard key presses into the login | 50 // Wrapper used to help in routing keyboard key presses into the login |
| 51 // screen. This gets the Login Window widget from the Singleton, so that other | 51 // screen. This gets the Login Window widget from the Singleton, so that other |
| 52 // classes don't need to know we are a Singleton | 52 // classes don't need to know we are a Singleton |
| 53 static views::Widget* GetLoginWindow(); | 53 static views::Widget* GetLoginWindow(); |
| 54 views::Widget* LoginWindow(); | 54 views::Widget* LoginWindow(); |
| 55 | 55 |
| 56 // LoginDisplay implementation: | 56 // LoginDisplay implementation: |
| 57 virtual void Destroy() OVERRIDE; | 57 virtual void Destroy() OVERRIDE; |
| 58 virtual void Init(const std::vector<UserManager::User>& users, | 58 virtual void Init(const std::vector<UserManager::User>& users, |
| 59 bool show_guest, | 59 bool show_guest, |
| 60 bool show_new_user) OVERRIDE; | 60 bool show_new_user) OVERRIDE; |
| 61 virtual void OnBeforeUserRemoved(const std::string& username) OVERRIDE; | 61 virtual void OnBeforeUserRemoved(const std::string& username) OVERRIDE; |
| 62 virtual void OnUserImageChanged(UserManager::User* user) OVERRIDE; | 62 virtual void OnUserImageChanged(UserManager::User* user) OVERRIDE; |
| 63 virtual void OnUserRemoved(const std::string& username) OVERRIDE; | 63 virtual void OnUserRemoved(const std::string& username) OVERRIDE; |
| 64 virtual void OnFadeOut() OVERRIDE; | 64 virtual void OnFadeOut() OVERRIDE; |
| 65 virtual void SetUIEnabled(bool is_enabled) OVERRIDE; | 65 virtual void SetUIEnabled(bool is_enabled) OVERRIDE; |
| 66 virtual void SelectPod(int index) OVERRIDE; | 66 virtual void SelectPod(int index) OVERRIDE; |
| 67 virtual void ShowError(int error_msg_id, | 67 virtual void ShowError(int error_msg_id, |
| 68 int login_attempts, | 68 int login_attempts, |
| 69 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; | 69 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; |
| 70 | 70 |
| 71 // LoginUIHandlerDelegate | 71 // SigninScreenHandlerDelegate implementation: |
| 72 virtual void SetWebUIHandler( |
| 73 LoginDisplayWebUIHandler* webui_handler) OVERRIDE; |
| 72 virtual void Login(const std::string& username, | 74 virtual void Login(const std::string& username, |
| 73 const std::string& password) OVERRIDE; | 75 const std::string& password) OVERRIDE; |
| 74 virtual void LoginAsGuest() OVERRIDE; | 76 virtual void LoginAsGuest() OVERRIDE; |
| 75 | 77 |
| 76 void set_login_window(views::Widget* login_window) { | 78 void set_login_window(views::Widget* login_window) { |
| 77 login_window_ = login_window; | 79 login_window_ = login_window; |
| 78 } | 80 } |
| 79 | 81 |
| 80 private: | 82 private: |
| 81 // Singleton implementation: | 83 // Singleton implementation: |
| 82 friend struct DefaultSingletonTraits<WebUILoginDisplay>; | 84 friend struct DefaultSingletonTraits<WebUILoginDisplay>; |
| 83 WebUILoginDisplay(); | 85 WebUILoginDisplay(); |
| 84 | 86 |
| 85 // Set of Users in the systemvisible UserControllers. | 87 // Set of Users in the systemvisible UserControllers. |
| 86 std::vector<UserManager::User> users_; | 88 std::vector<UserManager::User> users_; |
| 87 | 89 |
| 88 // Container of the screen we are displaying | 90 // Container of the screen we are displaying |
| 89 views::Widget* login_window_; | 91 views::Widget* login_window_; |
| 90 | 92 |
| 93 // Reference to the WebUI handling layer for the login screen |
| 94 LoginDisplayWebUIHandler* webui_handler_; |
| 95 |
| 91 DISALLOW_COPY_AND_ASSIGN(WebUILoginDisplay); | 96 DISALLOW_COPY_AND_ASSIGN(WebUILoginDisplay); |
| 92 }; | 97 }; |
| 93 | 98 |
| 94 } // namespace chromeos | 99 } // namespace chromeos |
| 95 | 100 |
| 96 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_ | 101 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_ |
| OLD | NEW |