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" | |
14 #include "chrome/browser/chromeos/login/login_display.h" | 13 #include "chrome/browser/chromeos/login/login_display.h" |
15 #include "chrome/browser/chromeos/login/user_manager.h" | 14 #include "chrome/browser/chromeos/login/user_manager.h" |
16 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 15 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
17 #include "views/widget/widget.h" | 16 #include "views/widget/widget.h" |
18 | 17 |
19 namespace gfx { | 18 namespace gfx { |
20 class Rect; | 19 class Rect; |
21 } // namespace gfx | 20 } // namespace gfx |
22 | 21 |
23 namespace chromeos { | 22 namespace chromeos { |
24 // WebUI-based login UI implementation. | 23 // WebUI-based login UI implementation. |
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 | |
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 | |
29 // the object, the ExistingUserController should call Destroy and not free the | |
30 // pointer, where as accessing classes should do nothing with the pointer. | |
31 // | |
32 // Expected order of commands to setup for LoginDisplayHost: | |
33 // WebUILoginDisplay::GetInstance(); | |
34 // set_delegate(delegate); | |
35 // set_background_bounds(background_bounds()); | |
36 // Init(); | |
37 // | |
38 // Expected order of commands to setup for LoginUIHandler: | |
39 // WebUILoginDisplay::GetInstance(); | |
40 // set_login_handler(this); | |
41 | |
42 class WebUILoginDisplay : public LoginDisplay, | 24 class WebUILoginDisplay : public LoginDisplay, |
43 public SigninScreenHandlerDelegate { | 25 public SigninScreenHandlerDelegate { |
44 public: | 26 public: |
| 27 explicit WebUILoginDisplay(LoginDisplay::Delegate* delegate); |
45 virtual ~WebUILoginDisplay(); | 28 virtual ~WebUILoginDisplay(); |
46 | 29 |
47 // Singleton implementation: | |
48 static WebUILoginDisplay* GetInstance(); | |
49 | |
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 | |
52 // classes don't need to know we are a Singleton | |
53 static views::Widget* GetLoginWindow(); | |
54 views::Widget* LoginWindow(); | |
55 | |
56 // LoginDisplay implementation: | 30 // LoginDisplay implementation: |
57 virtual void Destroy() OVERRIDE; | |
58 virtual void Init(const std::vector<UserManager::User>& users, | 31 virtual void Init(const std::vector<UserManager::User>& users, |
59 bool show_guest, | 32 bool show_guest, |
60 bool show_new_user) OVERRIDE; | 33 bool show_new_user) OVERRIDE; |
61 virtual void OnBeforeUserRemoved(const std::string& username) OVERRIDE; | 34 virtual void OnBeforeUserRemoved(const std::string& username) OVERRIDE; |
62 virtual void OnUserImageChanged(UserManager::User* user) OVERRIDE; | 35 virtual void OnUserImageChanged(UserManager::User* user) OVERRIDE; |
63 virtual void OnUserRemoved(const std::string& username) OVERRIDE; | 36 virtual void OnUserRemoved(const std::string& username) OVERRIDE; |
64 virtual void OnFadeOut() OVERRIDE; | 37 virtual void OnFadeOut() OVERRIDE; |
65 virtual void OnLoginSuccess(const std::string& username) OVERRIDE; | 38 virtual void OnLoginSuccess(const std::string& username) OVERRIDE; |
66 virtual void SetUIEnabled(bool is_enabled) OVERRIDE; | 39 virtual void SetUIEnabled(bool is_enabled) OVERRIDE; |
67 virtual void SelectPod(int index) OVERRIDE; | 40 virtual void SelectPod(int index) OVERRIDE; |
68 virtual void ShowError(int error_msg_id, | 41 virtual void ShowError(int error_msg_id, |
69 int login_attempts, | 42 int login_attempts, |
70 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; | 43 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; |
71 | 44 |
72 // SigninScreenHandlerDelegate implementation: | 45 // SigninScreenHandlerDelegate implementation: |
73 virtual void CompleteLogin(const std::string& username, | 46 virtual void CompleteLogin(const std::string& username, |
74 const std::string& password) OVERRIDE; | 47 const std::string& password) OVERRIDE; |
75 virtual void Login(const std::string& username, | 48 virtual void Login(const std::string& username, |
76 const std::string& password) OVERRIDE; | 49 const std::string& password) OVERRIDE; |
77 virtual void LoginAsGuest() OVERRIDE; | 50 virtual void LoginAsGuest() OVERRIDE; |
78 virtual void FixCaptivePortal() OVERRIDE; | 51 virtual void FixCaptivePortal() OVERRIDE; |
79 virtual void CreateAccount() OVERRIDE; | 52 virtual void CreateAccount() OVERRIDE; |
80 virtual void RemoveUser(const std::string& username) OVERRIDE; | 53 virtual void RemoveUser(const std::string& username) OVERRIDE; |
81 virtual void ShowEnterpriseEnrollmentScreen() OVERRIDE; | 54 virtual void ShowEnterpriseEnrollmentScreen() OVERRIDE; |
82 virtual void SetWebUIHandler( | 55 virtual void SetWebUIHandler( |
83 LoginDisplayWebUIHandler* webui_handler) OVERRIDE; | 56 LoginDisplayWebUIHandler* webui_handler) OVERRIDE; |
84 virtual void ShowSigninScreenForCreds(const std::string& username, | 57 virtual void ShowSigninScreenForCreds(const std::string& username, |
85 const std::string& password); | 58 const std::string& password); |
86 | 59 virtual const std::vector<UserManager::User>& GetUsers() const OVERRIDE; |
87 void set_login_window(views::Widget* login_window) { | 60 virtual bool IsShowGuest() const OVERRIDE; |
88 login_window_ = login_window; | 61 virtual bool IsShowNewUser() const OVERRIDE; |
89 } | |
90 | |
91 const std::vector<UserManager::User>& users() const { | |
92 return users_; | |
93 } | |
94 | |
95 bool show_guest() const { | |
96 return show_guest_; | |
97 } | |
98 | |
99 bool show_new_user() const { | |
100 return show_new_user_; | |
101 } | |
102 | 62 |
103 private: | 63 private: |
104 // Singleton implementation: | |
105 friend struct DefaultSingletonTraits<WebUILoginDisplay>; | |
106 WebUILoginDisplay(); | |
107 | |
108 // Set of Users that are visible. | 64 // Set of Users that are visible. |
109 std::vector<UserManager::User> users_; | 65 std::vector<UserManager::User> users_; |
110 | 66 |
111 // Whether to show guest login. | 67 // Whether to show guest login. |
112 bool show_guest_; | 68 bool show_guest_; |
113 | 69 |
114 // Whether to show add new user. | 70 // Whether to show add new user. |
115 bool show_new_user_; | 71 bool show_new_user_; |
116 | 72 |
117 // Container of the screen we are displaying | |
118 views::Widget* login_window_; | |
119 | |
120 // Reference to the WebUI handling layer for the login screen | 73 // Reference to the WebUI handling layer for the login screen |
121 LoginDisplayWebUIHandler* webui_handler_; | 74 LoginDisplayWebUIHandler* webui_handler_; |
122 | 75 |
123 DISALLOW_COPY_AND_ASSIGN(WebUILoginDisplay); | 76 DISALLOW_COPY_AND_ASSIGN(WebUILoginDisplay); |
124 }; | 77 }; |
125 | 78 |
126 } // namespace chromeos | 79 } // namespace chromeos |
127 | 80 |
128 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_ | 81 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_DISPLAY_H_ |
OLD | NEW |