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 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 FingerprintState state) = 0; | 94 FingerprintState state) = 0; |
95 | 95 |
96 // Returns the web contents used to back the lock screen. | 96 // Returns the web contents used to back the lock screen. |
97 // TODO(jdufault): Remove this function when we remove WebUIScreenLocker. | 97 // TODO(jdufault): Remove this function when we remove WebUIScreenLocker. |
98 virtual content::WebContents* GetWebContents() = 0; | 98 virtual content::WebContents* GetWebContents() = 0; |
99 | 99 |
100 private: | 100 private: |
101 DISALLOW_COPY_AND_ASSIGN(Delegate); | 101 DISALLOW_COPY_AND_ASSIGN(Delegate); |
102 }; | 102 }; |
103 | 103 |
| 104 using AuthenticateCallback = base::OnceCallback<void(bool auth_success)>; |
| 105 |
104 explicit ScreenLocker(const user_manager::UserList& users); | 106 explicit ScreenLocker(const user_manager::UserList& users); |
105 | 107 |
106 // Returns the default instance if it has been created. | 108 // Returns the default instance if it has been created. |
107 static ScreenLocker* default_screen_locker() { | 109 static ScreenLocker* default_screen_locker() { |
108 return screen_locker_; | 110 return screen_locker_; |
109 } | 111 } |
110 | 112 |
111 bool locked() const { return locked_; } | 113 bool locked() const { return locked_; } |
112 | 114 |
113 // Initialize and show the screen locker. | 115 // Initialize and show the screen locker. |
114 void Init(); | 116 void Init(); |
115 | 117 |
116 // AuthStatusConsumer: | 118 // AuthStatusConsumer: |
117 void OnAuthFailure(const chromeos::AuthFailure& error) override; | 119 void OnAuthFailure(const chromeos::AuthFailure& error) override; |
118 void OnAuthSuccess(const UserContext& user_context) override; | 120 void OnAuthSuccess(const UserContext& user_context) override; |
119 | 121 |
120 // Called when an account password (not PIN/quick unlock) has been used to | 122 // Called when an account password (not PIN/quick unlock) has been used to |
121 // unlock the device. | 123 // unlock the device. |
122 void OnPasswordAuthSuccess(const UserContext& user_context); | 124 void OnPasswordAuthSuccess(const UserContext& user_context); |
123 | 125 |
124 // Does actual unlocking once authentication is successful and all blocking | 126 // Does actual unlocking once authentication is successful and all blocking |
125 // animations are done. | 127 // animations are done. |
126 void UnlockOnLoginSuccess(); | 128 void UnlockOnLoginSuccess(); |
127 | 129 |
128 // Authenticates the user with given |user_context|. | 130 // Authenticates the user with given |user_context|. |
129 void Authenticate(const UserContext& user_context); | 131 void Authenticate(const UserContext& user_context, |
| 132 AuthenticateCallback callback); |
130 | 133 |
131 // Close message bubble to clear error messages. | 134 // Close message bubble to clear error messages. |
132 void ClearErrors(); | 135 void ClearErrors(); |
133 | 136 |
134 // Exit the chrome, which will sign out the current session. | 137 // Exit the chrome, which will sign out the current session. |
135 void Signout(); | 138 void Signout(); |
136 | 139 |
137 // (Re)enable input field. | 140 // (Re)enable input field. |
138 void EnableInput(); | 141 void EnableInput(); |
139 | 142 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // Delegate to forward all login status events to. | 264 // Delegate to forward all login status events to. |
262 // Tests can use this to receive login status events. | 265 // Tests can use this to receive login status events. |
263 AuthStatusConsumer* auth_status_consumer_ = nullptr; | 266 AuthStatusConsumer* auth_status_consumer_ = nullptr; |
264 | 267 |
265 // Number of bad login attempts in a row. | 268 // Number of bad login attempts in a row. |
266 int incorrect_passwords_count_ = 0; | 269 int incorrect_passwords_count_ = 0; |
267 | 270 |
268 // Type of the last unlock attempt. | 271 // Type of the last unlock attempt. |
269 UnlockType unlock_attempt_type_ = AUTH_PASSWORD; | 272 UnlockType unlock_attempt_type_ = AUTH_PASSWORD; |
270 | 273 |
| 274 // Callback to run, if any, when authentication is done. |
| 275 AuthenticateCallback on_auth_complete_; |
| 276 |
271 // Copy of parameters passed to last call of OnLoginSuccess for usage in | 277 // Copy of parameters passed to last call of OnLoginSuccess for usage in |
272 // UnlockOnLoginSuccess(). | 278 // UnlockOnLoginSuccess(). |
273 std::unique_ptr<AuthenticationParametersCapture> authentication_capture_; | 279 std::unique_ptr<AuthenticationParametersCapture> authentication_capture_; |
274 | 280 |
275 // Provider for button icon set by the screenlockPrivate API. | 281 // Provider for button icon set by the screenlockPrivate API. |
276 std::unique_ptr<ScreenlockIconProvider> screenlock_icon_provider_; | 282 std::unique_ptr<ScreenlockIconProvider> screenlock_icon_provider_; |
277 | 283 |
278 scoped_refptr<input_method::InputMethodManager::State> saved_ime_state_; | 284 scoped_refptr<input_method::InputMethodManager::State> saved_ime_state_; |
279 | 285 |
280 device::mojom::FingerprintPtr fp_service_; | 286 device::mojom::FingerprintPtr fp_service_; |
281 mojo::Binding<device::mojom::FingerprintObserver> binding_; | 287 mojo::Binding<device::mojom::FingerprintObserver> binding_; |
282 | 288 |
283 base::WeakPtrFactory<ScreenLocker> weak_factory_; | 289 base::WeakPtrFactory<ScreenLocker> weak_factory_; |
284 | 290 |
285 DISALLOW_COPY_AND_ASSIGN(ScreenLocker); | 291 DISALLOW_COPY_AND_ASSIGN(ScreenLocker); |
286 }; | 292 }; |
287 | 293 |
288 } // namespace chromeos | 294 } // namespace chromeos |
289 | 295 |
290 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_ | 296 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_ |
OLD | NEW |