OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_LOCK_SCREEN_LOCKER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/sequenced_task_runner_helpers.h" | 15 #include "base/sequenced_task_runner_helpers.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "chrome/browser/chromeos/login/help_app_launcher.h" | 17 #include "chrome/browser/chromeos/login/help_app_launcher.h" |
18 #include "chrome/browser/chromeos/login/lock/screen_locker_delegate.h" | |
19 #include "chrome/browser/chromeos/login/ui/login_display.h" | 18 #include "chrome/browser/chromeos/login/ui/login_display.h" |
20 #include "chromeos/login/auth/auth_status_consumer.h" | 19 #include "chromeos/login/auth/auth_status_consumer.h" |
21 #include "chromeos/login/auth/user_context.h" | 20 #include "chromeos/login/auth/user_context.h" |
22 #include "components/user_manager/user.h" | 21 #include "components/user_manager/user.h" |
23 #include "ui/base/accelerators/accelerator.h" | 22 #include "ui/base/accelerators/accelerator.h" |
24 #include "ui/base/ime/chromeos/input_method_manager.h" | 23 #include "ui/base/ime/chromeos/input_method_manager.h" |
25 | 24 |
26 namespace content { | 25 namespace content { |
27 class WebUI; | 26 class WebUI; |
28 } | 27 } |
29 | 28 |
30 namespace gfx { | 29 namespace gfx { |
31 class Image; | 30 class Image; |
32 } | 31 } |
33 | 32 |
34 namespace chromeos { | 33 namespace chromeos { |
35 | 34 |
36 class Authenticator; | 35 class Authenticator; |
37 class ExtendedAuthenticator; | 36 class ExtendedAuthenticator; |
38 class AuthFailure; | 37 class AuthFailure; |
39 class ScreenlockIconProvider; | 38 class ScreenlockIconProvider; |
39 class WebUIScreenLocker; | |
40 | 40 |
41 namespace test { | 41 namespace test { |
42 class ScreenLockerTester; | 42 class ScreenLockerTester; |
43 class ScreenLockerViewsTester; | 43 class ScreenLockerViewsTester; |
44 class WebUIScreenLockerTester; | 44 class WebUIScreenLockerTester; |
45 } // namespace test | 45 } // namespace test |
46 | 46 |
47 // ScreenLocker creates a ScreenLockerDelegate which will display the lock UI. | 47 // ScreenLocker creates a WebUIScreenLocker which will display the lock UI. |
48 // As well, it takes care of authenticating the user and managing a global | 48 // As well, it takes care of authenticating the user and managing a global |
49 // instance of itself which will be deleted when the system is unlocked. | 49 // instance of itself which will be deleted when the system is unlocked. |
50 class ScreenLocker : public AuthStatusConsumer { | 50 class ScreenLocker : public AuthStatusConsumer { |
51 public: | 51 public: |
52 explicit ScreenLocker(const user_manager::UserList& users); | 52 explicit ScreenLocker(const user_manager::UserList& users); |
53 | 53 |
54 // Returns the default instance if it has been created. | 54 // Returns the default instance if it has been created. |
55 static ScreenLocker* default_screen_locker() { | 55 static ScreenLocker* default_screen_locker() { |
56 return screen_locker_; | 56 return screen_locker_; |
57 } | 57 } |
(...skipping 27 matching lines...) Expand all Loading... | |
85 // (Re)enable input field. | 85 // (Re)enable input field. |
86 void EnableInput(); | 86 void EnableInput(); |
87 | 87 |
88 // Disables all UI needed and shows error bubble with |message|. | 88 // Disables all UI needed and shows error bubble with |message|. |
89 // If |sign_out_only| is true then all other input except "Sign Out" | 89 // If |sign_out_only| is true then all other input except "Sign Out" |
90 // button is blocked. | 90 // button is blocked. |
91 void ShowErrorMessage(int error_msg_id, | 91 void ShowErrorMessage(int error_msg_id, |
92 HelpAppLauncher::HelpTopic help_topic_id, | 92 HelpAppLauncher::HelpTopic help_topic_id, |
93 bool sign_out_only); | 93 bool sign_out_only); |
94 | 94 |
95 // Returns the screen locker's delegate. | 95 // Returns the WebUIScreenLocker used to lock the screen. |
96 ScreenLockerDelegate* delegate() const { return delegate_.get(); } | 96 WebUIScreenLocker* web_ui() const { return web_ui_.get(); } |
achuithb
2016/10/20 17:38:33
Wonder if we should drop the const here since we e
jdufault
2016/10/20 19:35:19
I've dropped the const and made the preferred usag
| |
97 | 97 |
98 // Returns the users to authenticate. | 98 // Returns the users to authenticate. |
99 const user_manager::UserList& users() const { return users_; } | 99 const user_manager::UserList& users() const { return users_; } |
100 | 100 |
101 // Allow a AuthStatusConsumer to listen for | 101 // Allow a AuthStatusConsumer to listen for |
102 // the same login events that ScreenLocker does. | 102 // the same login events that ScreenLocker does. |
103 void SetLoginStatusConsumer(chromeos::AuthStatusConsumer* consumer); | 103 void SetLoginStatusConsumer(chromeos::AuthStatusConsumer* consumer); |
104 | 104 |
105 // Returns WebUI associated with screen locker implementation or NULL if | |
106 // there isn't one. | |
107 content::WebUI* GetAssociatedWebUI(); | |
108 | |
109 // Initialize or uninitialize the ScreenLocker class. It listens to | 105 // Initialize or uninitialize the ScreenLocker class. It listens to |
110 // NOTIFICATION_SESSION_STARTED so that the screen locker accepts lock | 106 // NOTIFICATION_SESSION_STARTED so that the screen locker accepts lock |
111 // requests only after a user has logged in. | 107 // requests only after a user has logged in. |
112 static void InitClass(); | 108 static void InitClass(); |
113 static void ShutDownClass(); | 109 static void ShutDownClass(); |
114 | 110 |
115 // Handles a request from the session manager to lock the screen. | 111 // Handles a request from the session manager to lock the screen. |
116 static void HandleLockScreenRequest(); | 112 static void HandleLockScreenRequest(); |
117 | 113 |
118 // Show the screen locker. | 114 // Show the screen locker. |
119 static void Show(); | 115 static void Show(); |
120 | 116 |
121 // Hide the screen locker. | 117 // Hide the screen locker. |
122 static void Hide(); | 118 static void Hide(); |
123 | 119 |
124 // Returns the tester | 120 // Returns the tester |
125 static test::ScreenLockerTester* GetTester(); | 121 static test::ScreenLockerTester* GetTester(); |
126 | 122 |
127 private: | 123 private: |
128 friend class base::DeleteHelper<ScreenLocker>; | 124 friend class base::DeleteHelper<ScreenLocker>; |
129 friend class test::ScreenLockerTester; | 125 friend class test::ScreenLockerTester; |
130 friend class test::ScreenLockerViewsTester; | 126 friend class test::ScreenLockerViewsTester; |
131 friend class test::WebUIScreenLockerTester; | 127 friend class test::WebUIScreenLockerTester; |
132 friend class ScreenLockerDelegate; | 128 friend class WebUIScreenLocker; |
133 | 129 |
134 // Track whether the user used pin or password to unlock the lock screen. | 130 // Track whether the user used pin or password to unlock the lock screen. |
135 // Values corrospond to UMA histograms, do not modify, or add or delete other | 131 // Values corrospond to UMA histograms, do not modify, or add or delete other |
136 // than directly before AUTH_COUNT. | 132 // than directly before AUTH_COUNT. |
137 enum UnlockType { AUTH_PASSWORD = 0, AUTH_PIN, AUTH_COUNT }; | 133 enum UnlockType { AUTH_PASSWORD = 0, AUTH_PIN, AUTH_COUNT }; |
138 | 134 |
139 struct AuthenticationParametersCapture { | 135 struct AuthenticationParametersCapture { |
140 UserContext user_context; | 136 UserContext user_context; |
141 }; | 137 }; |
142 | 138 |
143 ~ScreenLocker() override; | 139 ~ScreenLocker() override; |
144 | 140 |
145 // Sets the authenticator. | 141 // Sets the authenticator. |
146 void SetAuthenticator(Authenticator* authenticator); | 142 void SetAuthenticator(Authenticator* authenticator); |
147 | 143 |
148 // Called when the screen lock is ready. | 144 // Called when the screen lock is ready. |
149 void ScreenLockReady(); | 145 void ScreenLockReady(); |
150 | 146 |
151 // Called when screen locker is safe to delete. | 147 // Called when screen locker is safe to delete. |
152 static void ScheduleDeletion(); | 148 static void ScheduleDeletion(); |
153 | 149 |
154 // Returns true if |account_id| is found among logged in users. | 150 // Returns true if |account_id| is found among logged in users. |
155 bool IsUserLoggedIn(const AccountId& account_id) const; | 151 bool IsUserLoggedIn(const AccountId& account_id) const; |
156 | 152 |
157 // Looks up user in unlock user list. | 153 // Looks up user in unlock user list. |
158 const user_manager::User* FindUnlockUser(const AccountId& account_id); | 154 const user_manager::User* FindUnlockUser(const AccountId& account_id); |
159 | 155 |
160 // ScreenLockerDelegate instance in use. | 156 // WebUIScreenLocker instance in use. |
161 std::unique_ptr<ScreenLockerDelegate> delegate_; | 157 std::unique_ptr<WebUIScreenLocker> web_ui_; |
162 | 158 |
163 // Users that can unlock the device. | 159 // Users that can unlock the device. |
164 user_manager::UserList users_; | 160 user_manager::UserList users_; |
165 | 161 |
166 // Used to authenticate the user to unlock. | 162 // Used to authenticate the user to unlock. |
167 scoped_refptr<Authenticator> authenticator_; | 163 scoped_refptr<Authenticator> authenticator_; |
168 | 164 |
169 // Used to authenticate the user to unlock supervised users. | 165 // Used to authenticate the user to unlock supervised users. |
170 scoped_refptr<ExtendedAuthenticator> extended_authenticator_; | 166 scoped_refptr<ExtendedAuthenticator> extended_authenticator_; |
171 | 167 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 scoped_refptr<input_method::InputMethodManager::State> saved_ime_state_; | 199 scoped_refptr<input_method::InputMethodManager::State> saved_ime_state_; |
204 | 200 |
205 base::WeakPtrFactory<ScreenLocker> weak_factory_; | 201 base::WeakPtrFactory<ScreenLocker> weak_factory_; |
206 | 202 |
207 DISALLOW_COPY_AND_ASSIGN(ScreenLocker); | 203 DISALLOW_COPY_AND_ASSIGN(ScreenLocker); |
208 }; | 204 }; |
209 | 205 |
210 } // namespace chromeos | 206 } // namespace chromeos |
211 | 207 |
212 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_ | 208 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_ |
OLD | NEW |