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( ...@@ -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, void LoginScreenController::AuthenticateUser(const AccountId& account_id,
const std::string& password, const std::string& password,
bool authenticated_by_pin, bool authenticated_by_pin,
......
...@@ -64,6 +64,7 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen { ...@@ -64,6 +64,7 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
void SetDevChannelInfo(const std::string& os_version_label_text, void SetDevChannelInfo(const std::string& os_version_label_text,
const std::string& enterprise_info_text, const std::string& enterprise_info_text,
const std::string& bluetooth_name) override; const std::string& bluetooth_name) override;
void IsReadyForPassword(IsReadyForPasswordCallback callback) override;
// Wrappers around the mojom::LoginScreenClient interface. Hash the password // Wrappers around the mojom::LoginScreenClient interface. Hash the password
// and send AuthenticateUser request to LoginScreenClient. // and send AuthenticateUser request to LoginScreenClient.
......
...@@ -78,6 +78,9 @@ interface LoginScreen { ...@@ -78,6 +78,9 @@ interface LoginScreen {
SetDevChannelInfo(string os_version_label_text, SetDevChannelInfo(string os_version_label_text,
string enterprise_info_text, string enterprise_info_text,
string bluetooth_name); 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 // Allows ash lock screen to control a client (e.g. Chrome browser). Requests
......
...@@ -109,6 +109,7 @@ class ScreenLocker : public AuthStatusConsumer, ...@@ -109,6 +109,7 @@ class ScreenLocker : public AuthStatusConsumer,
// Returns the default instance if it has been created. // Returns the default instance if it has been created.
static ScreenLocker* default_screen_locker() { return screen_locker_; } static ScreenLocker* default_screen_locker() { return screen_locker_; }
// Returns true if the lock UI has been confirmed as displayed.
bool locked() const { return locked_; } bool locked() const { return locked_; }
// Initialize and show the screen locker. // Initialize and show the screen locker.
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "chrome/browser/chromeos/login/lock/screen_locker.h" #include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/system/input_device_settings.h" #include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/profiles/profile_manager.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/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h" #include "chromeos/dbus/session_manager_client.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
...@@ -105,17 +106,32 @@ ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() { ...@@ -105,17 +106,32 @@ ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() {
ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() {
DVLOG(1) << "AutotestPrivateLoginStatusFunction"; DVLOG(1) << "AutotestPrivateLoginStatusFunction";
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
#if defined(OS_CHROMEOS) #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 = const user_manager::UserManager* user_manager =
user_manager::UserManager::Get(); 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 = const bool is_screen_locked =
!!chromeos::ScreenLocker::default_screen_locker(); !!chromeos::ScreenLocker::default_screen_locker() &&
chromeos::ScreenLocker::default_screen_locker()->locked();
if (user_manager) { if (user_manager) {
result->SetBoolean("isLoggedIn", user_manager->IsUserLoggedIn()); result->SetBoolean("isLoggedIn", user_manager->IsUserLoggedIn());
result->SetBoolean("isOwner", user_manager->IsCurrentUserOwner()); result->SetBoolean("isOwner", user_manager->IsCurrentUserOwner());
result->SetBoolean("isScreenLocked", is_screen_locked); result->SetBoolean("isScreenLocked", is_screen_locked);
result->SetBoolean("isReadyForPassword", is_ready);
if (user_manager->IsUserLoggedIn()) { if (user_manager->IsUserLoggedIn()) {
result->SetBoolean("isRegularUser", result->SetBoolean("isRegularUser",
user_manager->IsLoggedInAsUserWithGaiaAccount()); user_manager->IsLoggedInAsUserWithGaiaAccount());
...@@ -143,10 +159,9 @@ ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() { ...@@ -143,10 +159,9 @@ ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() {
result->SetString("userImage", user_image); result->SetString("userImage", user_image);
} }
} }
#endif Respond(OneArgument(std::move(result)));
return RespondNow(OneArgument(std::move(result)));
} }
#endif
ExtensionFunction::ResponseAction AutotestPrivateLockScreenFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateLockScreenFunction::Run() {
DVLOG(1) << "AutotestPrivateLockScreenFunction"; DVLOG(1) << "AutotestPrivateLockScreenFunction";
......
...@@ -50,6 +50,10 @@ class AutotestPrivateLoginStatusFunction : public UIThreadExtensionFunction { ...@@ -50,6 +50,10 @@ class AutotestPrivateLoginStatusFunction : public UIThreadExtensionFunction {
private: private:
~AutotestPrivateLoginStatusFunction() override {} ~AutotestPrivateLoginStatusFunction() override {}
ResponseAction Run() override; ResponseAction Run() override;
#if defined(OS_CHROMEOS)
void OnIsReadyForPassword(bool is_ready);
#endif
}; };
class AutotestPrivateLockScreenFunction : public UIThreadExtensionFunction { class AutotestPrivateLockScreenFunction : public UIThreadExtensionFunction {
......
...@@ -171,6 +171,11 @@ void LoginScreenClient::SetDevChannelInfo( ...@@ -171,6 +171,11 @@ void LoginScreenClient::SetDevChannelInfo(
bluetooth_name); bluetooth_name);
} }
void LoginScreenClient::IsReadyForPassword(
ash::mojom::LoginScreen::IsReadyForPasswordCallback callback) {
login_screen_->IsReadyForPassword(std::move(callback));
}
void LoginScreenClient::SetDelegate(Delegate* delegate) { void LoginScreenClient::SetDelegate(Delegate* delegate) {
delegate_ = delegate; delegate_ = delegate;
} }
...@@ -84,6 +84,8 @@ class LoginScreenClient : public ash::mojom::LoginScreenClient { ...@@ -84,6 +84,8 @@ class LoginScreenClient : public ash::mojom::LoginScreenClient {
void SetDevChannelInfo(const std::string& os_version_label_text, void SetDevChannelInfo(const std::string& os_version_label_text,
const std::string& enterprise_info_text, const std::string& enterprise_info_text,
const std::string& bluetooth_name); const std::string& bluetooth_name);
void IsReadyForPassword(
ash::mojom::LoginScreen::IsReadyForPasswordCallback callback);
void SetDelegate(Delegate* delegate); void SetDelegate(Delegate* delegate);
......
...@@ -13,6 +13,8 @@ namespace autotestPrivate { ...@@ -13,6 +13,8 @@ namespace autotestPrivate {
boolean isOwner; boolean isOwner;
// Is the screen locked? // Is the screen locked?
boolean isScreenLocked; boolean isScreenLocked;
// Is the screen ready for password?
boolean isReadyForPassword;
// Is the logged-in user a regular user? // Is the logged-in user a regular user?
boolean isRegularUser; 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