| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 ASH_LOGIN_LOCK_SCREEN_CONTROLLER_H_ | 5 #ifndef ASH_LOGIN_LOCK_SCREEN_CONTROLLER_H_ |
| 6 #define ASH_LOGIN_LOCK_SCREEN_CONTROLLER_H_ | 6 #define ASH_LOGIN_LOCK_SCREEN_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/public/interfaces/lock_screen.mojom.h" | 9 #include "ash/public/interfaces/lock_screen.mojom.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "mojo/public/cpp/bindings/binding_set.h" | 11 #include "mojo/public/cpp/bindings/binding_set.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 | 14 |
| 15 // LockScreenController implements mojom::LockScreen and wraps the | 15 // LockScreenController implements mojom::LockScreen and wraps the |
| 16 // mojom::LockScreenClient interface. This lets a consumer of ash provide a | 16 // mojom::LockScreenClient interface. This lets a consumer of ash provide a |
| 17 // LockScreenClient, which we will dispatch to if one has been provided to us. | 17 // LockScreenClient, which we will dispatch to if one has been provided to us. |
| 18 // This could send requests to LockScreenClient and also handle requests from | 18 // This could send requests to LockScreenClient and also handle requests from |
| 19 // LockScreenClient through mojo. | 19 // LockScreenClient through mojo. |
| 20 class ASH_EXPORT LockScreenController | 20 class ASH_EXPORT LockScreenController |
| 21 : NON_EXPORTED_BASE(public mojom::LockScreen) { | 21 : NON_EXPORTED_BASE(public mojom::LockScreen) { |
| 22 public: | 22 public: |
| 23 using OnShownCallback = base::OnceCallback<void(bool did_show)>; |
| 24 |
| 23 LockScreenController(); | 25 LockScreenController(); |
| 24 ~LockScreenController() override; | 26 ~LockScreenController() override; |
| 25 | 27 |
| 26 // Binds the mojom::LockScreen interface to this object. | 28 // Binds the mojom::LockScreen interface to this object. |
| 27 void BindRequest(mojom::LockScreenRequest request); | 29 void BindRequest(mojom::LockScreenRequest request); |
| 28 | 30 |
| 29 // mojom::LockScreen: | 31 // mojom::LockScreen: |
| 30 void SetClient(mojom::LockScreenClientPtr client) override; | 32 void SetClient(mojom::LockScreenClientPtr client) override; |
| 33 void ShowLockScreen(ShowLockScreenCallback callback) override; |
| 31 void ShowErrorMessage(int32_t login_attempts, | 34 void ShowErrorMessage(int32_t login_attempts, |
| 32 const std::string& error_text, | 35 const std::string& error_text, |
| 33 const std::string& help_link_text, | 36 const std::string& help_link_text, |
| 34 int32_t help_topic_id) override; | 37 int32_t help_topic_id) override; |
| 35 void ClearErrors() override; | 38 void ClearErrors() override; |
| 36 | 39 |
| 37 // Wrappers around the mojom::SystemTrayClient interface. | 40 // Wrappers around the mojom::SystemTrayClient interface. |
| 38 // Hash the password and send AuthenticateUser request to LockScreenClient. | 41 // Hash the password and send AuthenticateUser request to LockScreenClient. |
| 39 // LockScreenClient(chrome) will do the authentication and request to show | 42 // LockScreenClient(chrome) will do the authentication and request to show |
| 40 // error messages in the lock screen if auth fails, or request to clear | 43 // error messages in the lock screen if auth fails, or request to clear |
| 41 // errors if auth succeeds. | 44 // errors if auth succeeds. |
| 42 void AuthenticateUser(const AccountId& account_id, | 45 void AuthenticateUser( |
| 43 const std::string& password, | 46 const AccountId& account_id, |
| 44 bool authenticated_by_pin); | 47 const std::string& password, |
| 48 bool authenticated_by_pin, |
| 49 mojom::LockScreenClient::AuthenticateUserCallback callback); |
| 45 | 50 |
| 46 private: | 51 private: |
| 47 void DoAuthenticateUser(const AccountId& account_id, | 52 using PendingAuthenticateUserCall = |
| 48 const std::string& password, | 53 base::OnceCallback<void(const std::string& system_salt)>; |
| 49 bool authenticated_by_pin, | 54 |
| 50 const std::string& system_salt); | 55 void DoAuthenticateUser( |
| 56 const AccountId& account_id, |
| 57 const std::string& password, |
| 58 bool authenticated_by_pin, |
| 59 mojom::LockScreenClient::AuthenticateUserCallback callback, |
| 60 const std::string& system_salt); |
| 61 |
| 62 void OnGetSystemSalt(const std::string& system_salt); |
| 51 | 63 |
| 52 // Client interface in chrome browser. May be null in tests. | 64 // Client interface in chrome browser. May be null in tests. |
| 53 mojom::LockScreenClientPtr lock_screen_client_; | 65 mojom::LockScreenClientPtr lock_screen_client_; |
| 54 | 66 |
| 55 // Bindings for the LockScreen interface. | 67 // Bindings for the LockScreen interface. |
| 56 mojo::BindingSet<mojom::LockScreen> bindings_; | 68 mojo::BindingSet<mojom::LockScreen> bindings_; |
| 57 | 69 |
| 70 // User authentication calls that will run when we have system salt. |
| 71 std::vector<PendingAuthenticateUserCall> pending_user_auths_; |
| 72 |
| 58 DISALLOW_COPY_AND_ASSIGN(LockScreenController); | 73 DISALLOW_COPY_AND_ASSIGN(LockScreenController); |
| 59 }; | 74 }; |
| 60 | 75 |
| 61 } // namspace ash | 76 } // namespace ash |
| 62 | 77 |
| 63 #endif // ASH_LOGIN_LOCK_SCREEN_CONTROLLER_H_ | 78 #endif // ASH_LOGIN_LOCK_SCREEN_CONTROLLER_H_ |
| OLD | NEW |