Commit 0bfd187c authored by Sarah Hu's avatar Sarah Hu Committed by Commit Bot

Modify Autotest API to support views based lockscreen

1. re-landing the change of
https://chromium-review.googlesource.com/c/chromium/src/+/812264
2. Add a mojo call IsAuthenticating to check the authentication state
in ash lock screen.

Bug: 781998
Change-Id: I40a985cced8fe9cdaad404b068ffeacc669677a4
Reviewed-on: https://chromium-review.googlesource.com/816022
Commit-Queue: Xiaoyin Hu <xiaoyinh@chromium.org>
Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523474}
parent 24e730d2
......@@ -137,6 +137,11 @@ void LoginScreenController::SetDevChannelInfo(
}
}
void LoginScreenController::IsReadyForPassword(
IsReadyForPasswordCallback callback) {
std::move(callback).Run(LockScreen::IsShown() && !is_authenticating_);
}
void LoginScreenController::AuthenticateUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin,
......
......@@ -64,6 +64,7 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
void SetDevChannelInfo(const std::string& os_version_label_text,
const std::string& enterprise_info_text,
const std::string& bluetooth_name) override;
void IsReadyForPassword(IsReadyForPasswordCallback callback) override;
// Wrappers around the mojom::LoginScreenClient interface. Hash the password
// and send AuthenticateUser request to LoginScreenClient.
......
......@@ -78,6 +78,9 @@ interface LoginScreen {
SetDevChannelInfo(string os_version_label_text,
string enterprise_info_text,
string bluetooth_name);
// Check if the login/lock screen is ready for a password.
IsReadyForPassword() => (bool is_ready);
};
// Allows ash lock screen to control a client (e.g. Chrome browser). Requests
......
......@@ -109,6 +109,7 @@ class ScreenLocker : public AuthStatusConsumer,
// Returns the default instance if it has been created.
static ScreenLocker* default_screen_locker() { return screen_locker_; }
// Returns true if the lock UI has been confirmed as displayed.
bool locked() const { return locked_; }
// Initialize and show the screen locker.
......
......@@ -32,6 +32,7 @@
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/login_screen_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "components/user_manager/user_manager.h"
......@@ -105,17 +106,32 @@ ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() {
ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() {
DVLOG(1) << "AutotestPrivateLoginStatusFunction";
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
#if defined(OS_CHROMEOS)
LoginScreenClient::Get()->IsReadyForPassword(base::BindOnce(
&AutotestPrivateLoginStatusFunction::OnIsReadyForPassword, this));
return RespondLater();
#else
return RespondNow(OneArgument(std::make_unique<base::DictionaryValue>()));
#endif
}
#if defined(OS_CHROMEOS)
void AutotestPrivateLoginStatusFunction::OnIsReadyForPassword(bool is_ready) {
auto result = std::make_unique<base::DictionaryValue>();
const user_manager::UserManager* user_manager =
user_manager::UserManager::Get();
// default_screen_locker()->locked() is set when the UI is ready, so this
// tells us both views based lockscreen UI and screenlocker are ready.
const bool is_screen_locked =
!!chromeos::ScreenLocker::default_screen_locker();
!!chromeos::ScreenLocker::default_screen_locker() &&
chromeos::ScreenLocker::default_screen_locker()->locked();
if (user_manager) {
result->SetBoolean("isLoggedIn", user_manager->IsUserLoggedIn());
result->SetBoolean("isOwner", user_manager->IsCurrentUserOwner());
result->SetBoolean("isScreenLocked", is_screen_locked);
result->SetBoolean("isReadyForPassword", is_ready);
if (user_manager->IsUserLoggedIn()) {
result->SetBoolean("isRegularUser",
user_manager->IsLoggedInAsUserWithGaiaAccount());
......@@ -143,10 +159,9 @@ ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() {
result->SetString("userImage", user_image);
}
}
#endif
return RespondNow(OneArgument(std::move(result)));
Respond(OneArgument(std::move(result)));
}
#endif
ExtensionFunction::ResponseAction AutotestPrivateLockScreenFunction::Run() {
DVLOG(1) << "AutotestPrivateLockScreenFunction";
......
......@@ -50,6 +50,10 @@ class AutotestPrivateLoginStatusFunction : public UIThreadExtensionFunction {
private:
~AutotestPrivateLoginStatusFunction() override {}
ResponseAction Run() override;
#if defined(OS_CHROMEOS)
void OnIsReadyForPassword(bool is_ready);
#endif
};
class AutotestPrivateLockScreenFunction : public UIThreadExtensionFunction {
......
......@@ -171,6 +171,11 @@ void LoginScreenClient::SetDevChannelInfo(
bluetooth_name);
}
void LoginScreenClient::IsReadyForPassword(
ash::mojom::LoginScreen::IsReadyForPasswordCallback callback) {
login_screen_->IsReadyForPassword(std::move(callback));
}
void LoginScreenClient::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
......@@ -84,6 +84,8 @@ class LoginScreenClient : public ash::mojom::LoginScreenClient {
void SetDevChannelInfo(const std::string& os_version_label_text,
const std::string& enterprise_info_text,
const std::string& bluetooth_name);
void IsReadyForPassword(
ash::mojom::LoginScreen::IsReadyForPasswordCallback callback);
void SetDelegate(Delegate* delegate);
......
......@@ -13,6 +13,8 @@ namespace autotestPrivate {
boolean isOwner;
// Is the screen locked?
boolean isScreenLocked;
// Is the screen ready for password?
boolean isReadyForPassword;
// Is the logged-in user a regular user?
boolean isRegularUser;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment