Commit a14bfd83 authored by Jacob Dufault's avatar Jacob Dufault Committed by Commit Bot

cros: Simplify LoginScreenClient by removing a wrapper.

Bug: 784495
Change-Id: I73564231df70b8bce3899d9695d834bde2346b73
Reviewed-on: https://chromium-review.googlesource.com/961602
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544170}
parent a27374cc
......@@ -72,11 +72,10 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
const std::string& default_locale,
bool show_advanced_view) override;
// Wrappers around the mojom::LoginScreenClient interface. Hash the password
// and send AuthenticateUser request to LoginScreenClient.
// LoginScreenClient(chrome) will do the authentication and request to show
// error messages in the screen if auth fails, or request to clear errors if
// auth succeeds.
// Hash the password and send AuthenticateUser request to LoginScreenClient.
// LoginScreenClient (in the chrome process) will do the authentication and
// request to show error messages in the screen if auth fails, or request to
// clear errors if auth succeeds.
void AuthenticateUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin,
......
......@@ -221,7 +221,7 @@ void ScreenLocker::Init() {
delegate_ = views_screen_locker_.get();
// Create and display lock screen.
LoginScreenClient::Get()->ShowLockScreen(base::BindOnce(
LoginScreenClient::Get()->login_screen()->ShowLockScreen(base::BindOnce(
[](ViewsScreenLocker* screen_locker, bool did_show) {
CHECK(did_show);
screen_locker->OnLockScreenReady();
......
......@@ -67,7 +67,7 @@ ViewsScreenLocker::~ViewsScreenLocker() {
void ViewsScreenLocker::Init() {
lock_time_ = base::TimeTicks::Now();
user_selection_screen_->Init(screen_locker_->users());
LoginScreenClient::Get()->LoadUsers(
LoginScreenClient::Get()->login_screen()->LoadUsers(
user_selection_screen_->UpdateAndReturnUserListForMojo(),
false /* show_guests */);
if (!ime_state_.get())
......@@ -118,13 +118,13 @@ void ViewsScreenLocker::ShowErrorMessage(
int error_msg_id,
HelpAppLauncher::HelpTopic help_topic_id) {
// TODO(xiaoyinh): Complete the implementation here.
LoginScreenClient::Get()->ShowErrorMessage(0 /* login_attempts */,
std::string(), std::string(),
LoginScreenClient::Get()->login_screen()->ShowErrorMessage(
0 /* login_attempts */, std::string(), std::string(),
static_cast<int>(help_topic_id));
}
void ViewsScreenLocker::ClearErrors() {
LoginScreenClient::Get()->ClearErrors();
LoginScreenClient::Get()->login_screen()->ClearErrors();
}
void ViewsScreenLocker::AnimateAuthenticationSuccess() {
......@@ -262,7 +262,8 @@ void ViewsScreenLocker::UnregisterLockScreenAppFocusHandler() {
}
void ViewsScreenLocker::HandleLockScreenAppFocusOut(bool reverse) {
LoginScreenClient::Get()->HandleFocusLeavingLockScreenApps(reverse);
LoginScreenClient::Get()->login_screen()->HandleFocusLeavingLockScreenApps(
reverse);
}
void ViewsScreenLocker::OnOSVersionLabelTextUpdated(
......@@ -292,7 +293,8 @@ void ViewsScreenLocker::UpdatePinKeyboardState(const AccountId& account_id) {
return;
bool is_enabled = quick_unlock_storage->IsPinAuthenticationAvailable();
LoginScreenClient::Get()->SetPinEnabledForUser(account_id, is_enabled);
LoginScreenClient::Get()->login_screen()->SetPinEnabledForUser(account_id,
is_enabled);
}
void ViewsScreenLocker::OnAllowedInputMethodsChanged() {
......@@ -309,7 +311,7 @@ void ViewsScreenLocker::OnAllowedInputMethodsChanged() {
}
void ViewsScreenLocker::OnDevChannelInfoUpdated() {
LoginScreenClient::Get()->SetDevChannelInfo(
LoginScreenClient::Get()->login_screen()->SetDevChannelInfo(
os_version_label_text_, enterprise_info_text_, bluetooth_name_);
}
......
......@@ -42,12 +42,12 @@ void LoginDisplayViews::Init(const user_manager::UserList& filtered_users,
// Load the login screen.
auto* client = LoginScreenClient::Get();
client->SetDelegate(host_);
client->ShowLoginScreen(
client->login_screen()->ShowLoginScreen(
base::BindOnce([](bool did_show) { CHECK(did_show); }));
user_selection_screen_->Init(filtered_users);
client->LoadUsers(user_selection_screen_->UpdateAndReturnUserListForMojo(),
show_guest);
client->login_screen()->LoadUsers(
user_selection_screen_->UpdateAndReturnUserListForMojo(), show_guest);
user_selection_screen_->SetUsersLoaded(true /*loaded*/);
}
......
......@@ -70,8 +70,8 @@ UserSelectionScreenProxy::~UserSelectionScreenProxy() = default;
void UserSelectionScreenProxy::SetPublicSessionDisplayName(
const AccountId& account_id,
const std::string& display_name) {
LoginScreenClient::Get()->SetPublicSessionDisplayName(account_id,
display_name);
LoginScreenClient::Get()->login_screen()->SetPublicSessionDisplayName(
account_id, display_name);
}
void UserSelectionScreenProxy::SetPublicSessionLocales(
......@@ -79,7 +79,7 @@ void UserSelectionScreenProxy::SetPublicSessionLocales(
std::unique_ptr<base::ListValue> locales,
const std::string& default_locale,
bool multiple_recommended_locales) {
LoginScreenClient::Get()->SetPublicSessionLocales(
LoginScreenClient::Get()->login_screen()->SetPublicSessionLocales(
account_id, std::move(locales), default_locale,
multiple_recommended_locales);
}
......@@ -92,19 +92,21 @@ void UserSelectionScreenProxy::ShowUserPodCustomIcon(
ToEasyUnlockIconOptionsPtr(icon_options);
if (!icon)
return;
LoginScreenClient::Get()->ShowUserPodCustomIcon(account_id, std::move(icon));
LoginScreenClient::Get()->login_screen()->ShowUserPodCustomIcon(
account_id, std::move(icon));
}
void UserSelectionScreenProxy::HideUserPodCustomIcon(
const AccountId& account_id) {
LoginScreenClient::Get()->HideUserPodCustomIcon(account_id);
LoginScreenClient::Get()->login_screen()->HideUserPodCustomIcon(account_id);
}
void UserSelectionScreenProxy::SetAuthType(
const AccountId& account_id,
proximity_auth::mojom::AuthType auth_type,
const base::string16& initial_value) {
LoginScreenClient::Get()->SetAuthType(account_id, auth_type, initial_value);
LoginScreenClient::Get()->login_screen()->SetAuthType(account_id, auth_type,
initial_value);
}
base::WeakPtr<chromeos::UserBoardView> UserSelectionScreenProxy::GetWeakPtr() {
......
......@@ -107,7 +107,7 @@ ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() {
DVLOG(1) << "AutotestPrivateLoginStatusFunction";
#if defined(OS_CHROMEOS)
LoginScreenClient::Get()->IsReadyForPassword(base::BindOnce(
LoginScreenClient::Get()->login_screen()->IsReadyForPassword(base::BindOnce(
&AutotestPrivateLoginStatusFunction::OnIsReadyForPassword, this));
return RespondLater();
#else
......
......@@ -53,6 +53,14 @@ LoginScreenClient* LoginScreenClient::Get() {
return g_login_screen_client_instance;
}
void LoginScreenClient::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
ash::mojom::LoginScreenPtr& LoginScreenClient::login_screen() {
return login_screen_;
}
void LoginScreenClient::AuthenticateUser(
const AccountId& account_id,
const std::string& hashed_password,
......@@ -69,16 +77,6 @@ void LoginScreenClient::AuthenticateUser(
}
}
void LoginScreenClient::ShowLockScreen(
ash::mojom::LoginScreen::ShowLockScreenCallback on_shown) {
login_screen_->ShowLockScreen(std::move(on_shown));
}
void LoginScreenClient::ShowLoginScreen(
ash::mojom::LoginScreen::ShowLoginScreenCallback on_shown) {
login_screen_->ShowLoginScreen(std::move(on_shown));
}
void LoginScreenClient::AttemptUnlock(const AccountId& account_id) {
if (delegate_)
delegate_->HandleAttemptUnlock(account_id);
......@@ -109,7 +107,7 @@ void LoginScreenClient::FocusLockScreenApps(bool reverse) {
// |HandleFocusLeavingLockScreenApps| so the lock screen mojo service can
// give focus to the next window in the tab order.
if (!delegate_ || !delegate_->HandleFocusLockScreenApps(reverse))
HandleFocusLeavingLockScreenApps(reverse);
login_screen_->HandleFocusLeavingLockScreenApps(reverse);
}
void LoginScreenClient::ShowGaiaSignin() {
......@@ -153,78 +151,3 @@ void LoginScreenClient::OnMaxIncorrectPasswordAttempted(
RecordReauthReason(account_id,
chromeos::ReauthReason::INCORRECT_PASSWORD_ENTERED);
}
void LoginScreenClient::ShowErrorMessage(int32_t login_attempts,
const std::string& error_text,
const std::string& help_link_text,
int32_t help_topic_id) {
login_screen_->ShowErrorMessage(login_attempts, error_text, help_link_text,
help_topic_id);
}
void LoginScreenClient::ClearErrors() {
login_screen_->ClearErrors();
}
void LoginScreenClient::ShowUserPodCustomIcon(
const AccountId& account_id,
ash::mojom::EasyUnlockIconOptionsPtr icon) {
login_screen_->ShowUserPodCustomIcon(account_id, std::move(icon));
}
void LoginScreenClient::HideUserPodCustomIcon(const AccountId& account_id) {
login_screen_->HideUserPodCustomIcon(account_id);
}
void LoginScreenClient::SetAuthType(const AccountId& account_id,
proximity_auth::mojom::AuthType auth_type,
const base::string16& initial_value) {
login_screen_->SetAuthType(account_id, auth_type, initial_value);
}
void LoginScreenClient::LoadUsers(
std::vector<ash::mojom::LoginUserInfoPtr> users_list,
bool show_guest) {
login_screen_->LoadUsers(std::move(users_list), show_guest);
}
void LoginScreenClient::SetPinEnabledForUser(const AccountId& account_id,
bool is_enabled) {
login_screen_->SetPinEnabledForUser(account_id, is_enabled);
}
void LoginScreenClient::HandleFocusLeavingLockScreenApps(bool reverse) {
login_screen_->HandleFocusLeavingLockScreenApps(reverse);
}
void LoginScreenClient::SetDevChannelInfo(
const std::string& os_version_label_text,
const std::string& enterprise_info_text,
const std::string& bluetooth_name) {
login_screen_->SetDevChannelInfo(os_version_label_text, enterprise_info_text,
bluetooth_name);
}
void LoginScreenClient::IsReadyForPassword(
ash::mojom::LoginScreen::IsReadyForPasswordCallback callback) {
login_screen_->IsReadyForPassword(std::move(callback));
}
void LoginScreenClient::SetPublicSessionDisplayName(
const AccountId& account_id,
const std::string& display_name) {
login_screen_->SetPublicSessionDisplayName(account_id, display_name);
}
void LoginScreenClient::SetPublicSessionLocales(
const AccountId& account_id,
std::unique_ptr<base::ListValue> locales,
const std::string& default_locale,
bool show_advanced_view) {
login_screen_->SetPublicSessionLocales(account_id, std::move(locales),
default_locale, show_advanced_view);
}
void LoginScreenClient::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
......@@ -18,9 +18,6 @@ using AuthenticateUserCallback =
// to ash.
class LoginScreenClient : public ash::mojom::LoginScreenClient {
public:
LoginScreenClient();
~LoginScreenClient() override;
// Handles method calls coming from ash into chrome.
class Delegate {
public:
......@@ -47,9 +44,17 @@ class LoginScreenClient : public ash::mojom::LoginScreenClient {
DISALLOW_COPY_AND_ASSIGN(Delegate);
};
LoginScreenClient();
~LoginScreenClient() override;
static bool HasInstance();
static LoginScreenClient* Get();
// Set the object which will handle calls coming from ash.
void SetDelegate(Delegate* delegate);
// Returns an object which can be used to make calls to ash.
ash::mojom::LoginScreenPtr& login_screen();
// ash::mojom::LoginScreenClient:
void AuthenticateUser(
const AccountId& account_id,
......@@ -72,39 +77,6 @@ class LoginScreenClient : public ash::mojom::LoginScreenClient {
void OnRemoveUserWarningShown() override;
void RemoveUser(const AccountId& account_id) override;
// Wrappers around the mojom::LockScreen interface.
void ShowLockScreen(ash::mojom::LoginScreen::ShowLockScreenCallback on_shown);
void ShowLoginScreen(
ash::mojom::LoginScreen::ShowLoginScreenCallback on_shown);
void ShowErrorMessage(int32_t login_attempts,
const std::string& error_text,
const std::string& help_link_text,
int32_t help_topic_id);
void ClearErrors();
void ShowUserPodCustomIcon(const AccountId& account_id,
ash::mojom::EasyUnlockIconOptionsPtr icon);
void HideUserPodCustomIcon(const AccountId& account_id);
void SetAuthType(const AccountId& account_id,
proximity_auth::mojom::AuthType auth_type,
const base::string16& initial_value);
void LoadUsers(std::vector<ash::mojom::LoginUserInfoPtr> users_list,
bool show_guest);
void SetPinEnabledForUser(const AccountId& account_id, bool is_enabled);
void HandleFocusLeavingLockScreenApps(bool reverse);
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 SetPublicSessionDisplayName(const AccountId& account_id,
const std::string& display_name);
void SetPublicSessionLocales(const AccountId& account_id,
std::unique_ptr<base::ListValue> locales,
const std::string& default_locale,
bool show_advanced_view);
void SetDelegate(Delegate* delegate);
private:
// Lock screen mojo service in ash.
ash::mojom::LoginScreenPtr login_screen_;
......
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