Chromium Code Reviews| Index: chrome/browser/ui/ash/lock_screen_client_chromeos.cc |
| diff --git a/chrome/browser/ui/ash/lock_screen_client_chromeos.cc b/chrome/browser/ui/ash/lock_screen_client_chromeos.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8b64774c90b3822a46fed4f354f3bda957b595dc |
| --- /dev/null |
| +++ b/chrome/browser/ui/ash/lock_screen_client_chromeos.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/ash/lock_screen_client_chromeos.h" |
| + |
| +#include "ash/public/interfaces/constants.mojom.h" |
| +#include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| +#include "content/public/common/service_manager_connection.h" |
| +#include "services/service_manager/public/cpp/connector.h" |
| + |
| +namespace { |
| +LockScreenClientChromeOS* g_instance = nullptr; |
| +} // namespace |
| + |
| +LockScreenClientChromeOS::LockScreenClientChromeOS() : binding_(this) { |
| + content::ServiceManagerConnection::GetForProcess() |
| + ->GetConnector() |
| + ->BindInterface(ash::mojom::kServiceName, &lock_screen_); |
| + // Register this object as the client interface implementation. |
| + lock_screen_->SetClient(binding_.CreateInterfacePtrAndBind()); |
| + |
| + DCHECK(!g_instance); |
| + g_instance = this; |
| +} |
| + |
| +LockScreenClientChromeOS::~LockScreenClientChromeOS() { |
| + DCHECK_EQ(this, g_instance); |
| + g_instance = nullptr; |
| +} |
| + |
| +// static |
| +LockScreenClientChromeOS* LockScreenClientChromeOS::Get() { |
| + return g_instance; |
| +} |
| + |
| +void LockScreenClientChromeOS::AuthenticateUser( |
| + const AccountId& account_id, |
| + const std::string& hashed_password, |
| + bool authenticated_by_pin) { |
| + // TODO(xiaoyinh@): Complete the implementation below. |
|
James Cook
2017/05/15 21:15:01
super-nit: No "@" in todos. :-)
xiaoyinh(OOO Sep 11-29)
2017/05/16 17:32:50
Done.
|
| + // It should be similar as SigninScreenHandler::HandleAuthenticateUser. |
| + chromeos::UserContext user_context(account_id); |
| + chromeos::Key key(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, |
| + std::string(), hashed_password); |
| + user_context.SetKey(key); |
| + user_context.SetIsUsingPin(authenticated_by_pin); |
| + chromeos::ScreenLocker::default_screen_locker()->Authenticate(user_context); |
| +} |
| + |
| +void LockScreenClientChromeOS::ShowErrorMessage() { |
| + lock_screen_->ShowErrorMessage(); |
| +} |
| + |
| +void LockScreenClientChromeOS::ClearErrors() { |
| + lock_screen_->ClearErrors(); |
| +} |