Index: ash/login/lock_screen_controller.cc |
diff --git a/ash/login/lock_screen_controller.cc b/ash/login/lock_screen_controller.cc |
index 5ff835e034049bb50717f77809a1f13da4591d08..3c3c07e7713e8534ca8de398a12625b041ccea0c 100644 |
--- a/ash/login/lock_screen_controller.cc |
+++ b/ash/login/lock_screen_controller.cc |
@@ -4,6 +4,7 @@ |
#include "ash/login/lock_screen_controller.h" |
+#include "ash/login/ui/lock_screen.h" |
#include "chromeos/cryptohome/system_salt_getter.h" |
#include "chromeos/login/auth/user_context.h" |
@@ -17,15 +18,28 @@ void LockScreenController::BindRequest(mojom::LockScreenRequest request) { |
bindings_.AddBinding(this, std::move(request)); |
} |
-void LockScreenController::AuthenticateUser(const AccountId& account_id, |
- const std::string& password, |
- bool authenticated_by_pin) { |
+void LockScreenController::AuthenticateUser( |
+ const AccountId& account_id, |
+ const std::string& password, |
+ bool authenticated_by_pin, |
+ mojom::LockScreenClient::AuthenticateUserCallback callback) { |
if (!lock_screen_client_) |
return; |
- chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind( |
+ // We cannot execute auth requests directly via GetSystemSalt because it |
+ // expects a base::Callback instance, but |callback| is a base::OnceCallback. |
+ // Instead, we store |callback| on this object and invoke it locally once we |
+ // have the system salt. |
+ pending_user_auths_.emplace_back(base::BindOnce( |
&LockScreenController::DoAuthenticateUser, base::Unretained(this), |
- account_id, password, authenticated_by_pin)); |
+ account_id, password, authenticated_by_pin, std::move(callback))); |
xiyuan
2017/06/06 22:37:51
nit: DCHECK_EQ(1u, pending_user_auths_.size()), si
jdufault
2017/06/07 18:58:35
Removed support for >1 concurrent auth.
|
+ chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind( |
+ &LockScreenController::OnGetSystemSalt, base::Unretained(this))); |
+} |
+ |
+void LockScreenController::ShowLockScreen(ShowLockScreenCallback on_shown) { |
+ ::ash::ShowLockScreen(); |
+ std::move(on_shown).Run(true); |
} |
void LockScreenController::SetClient(mojom::LockScreenClientPtr client) { |
@@ -43,17 +57,26 @@ void LockScreenController::ClearErrors() { |
NOTIMPLEMENTED(); |
} |
-void LockScreenController::DoAuthenticateUser(const AccountId& account_id, |
- const std::string& password, |
- bool authenticated_by_pin, |
- const std::string& system_salt) { |
+void LockScreenController::DoAuthenticateUser( |
+ const AccountId& account_id, |
+ const std::string& password, |
+ bool authenticated_by_pin, |
+ mojom::LockScreenClient::AuthenticateUserCallback callback, |
+ const std::string& system_salt) { |
// Hash password before sending through mojo. |
// TODO(xiaoyinh): Pin is hashed differently by using a different salt and |
// a different hash algorithm. Update this part in PinStorage. |
chromeos::Key key(password); |
key.Transform(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
- lock_screen_client_->AuthenticateUser(account_id, key.GetSecret(), |
- authenticated_by_pin); |
+ lock_screen_client_->AuthenticateUser( |
+ account_id, key.GetSecret(), authenticated_by_pin, std::move(callback)); |
+} |
+ |
+void LockScreenController::OnGetSystemSalt(const std::string& system_salt) { |
+ std::vector<PendingAuthenticateUserCall> auths; |
+ std::swap(auths, pending_user_auths_); |
+ for (auto& auth_call : auths) |
+ std::move(auth_call).Run(system_salt); |
} |
} // namespace ash |