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