Commit f4cbba88 authored by Sarah Hu's avatar Sarah Hu Committed by Commit Bot

Add mojo api for public session information

Add the following mojo api for chrome to send public session information
to LockContentsView in ash.
1. SetPublicSessionDisplayName
2. SetPublicSessionLocales

These api will be used in a follow-up CL:
https://chromium-review.googlesource.com/c/chromium/src/+/940623

Bug: 809635
Change-Id: I7b83d7188155c4c8547e8fef91aa53121dc760b3
Reviewed-on: https://chromium-review.googlesource.com/941516Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Xiaoyin Hu <xiaoyinh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541269}
parent 30c384ab
...@@ -172,6 +172,24 @@ void LoginScreenController::IsReadyForPassword( ...@@ -172,6 +172,24 @@ void LoginScreenController::IsReadyForPassword(
std::move(callback).Run(LockScreen::IsShown() && !is_authenticating_); std::move(callback).Run(LockScreen::IsShown() && !is_authenticating_);
} }
void LoginScreenController::SetPublicSessionDisplayName(
const AccountId& account_id,
const std::string& display_name) {
if (DataDispatcher())
DataDispatcher()->SetPublicSessionDisplayName(account_id, display_name);
}
void LoginScreenController::SetPublicSessionLocales(
const AccountId& account_id,
std::unique_ptr<base::ListValue> locales,
const std::string& default_locale,
bool show_advanced_view) {
if (DataDispatcher()) {
DataDispatcher()->SetPublicSessionLocales(
account_id, std::move(locales), default_locale, show_advanced_view);
}
}
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,
......
...@@ -65,6 +65,12 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen { ...@@ -65,6 +65,12 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
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; void IsReadyForPassword(IsReadyForPasswordCallback callback) override;
void SetPublicSessionDisplayName(const AccountId& account_id,
const std::string& display_name) override;
void SetPublicSessionLocales(const AccountId& account_id,
std::unique_ptr<base::ListValue> locales,
const std::string& default_locale,
bool show_advanced_view) 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.
......
...@@ -481,6 +481,20 @@ void LockContentsView::OnDevChannelInfoChanged( ...@@ -481,6 +481,20 @@ void LockContentsView::OnDevChannelInfoChanged(
LayoutTopHeader(); LayoutTopHeader();
} }
void LockContentsView::OnPublicSessionDisplayNameChanged(
const AccountId& account_id,
const std::string& display_name) {
NOTIMPLEMENTED();
}
void LockContentsView::OnPublicSessionLocalesChanged(
const AccountId& account_id,
const base::ListValue& locales,
const std::string& default_locale,
bool show_advanced_view) {
NOTIMPLEMENTED();
}
void LockContentsView::OnFocusLeavingLockScreenApps(bool reverse) { void LockContentsView::OnFocusLeavingLockScreenApps(bool reverse) {
if (!reverse || lock_screen_apps_active_) if (!reverse || lock_screen_apps_active_)
FocusNextWidget(reverse); FocusNextWidget(reverse);
......
...@@ -104,6 +104,13 @@ class ASH_EXPORT LockContentsView : public NonAccessibleView, ...@@ -104,6 +104,13 @@ class ASH_EXPORT LockContentsView : public NonAccessibleView,
void OnDevChannelInfoChanged(const std::string& os_version_label_text, void OnDevChannelInfoChanged(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 OnPublicSessionDisplayNameChanged(
const AccountId& account_id,
const std::string& display_name) override;
void OnPublicSessionLocalesChanged(const AccountId& account_id,
const base::ListValue& locales,
const std::string& default_locale,
bool show_advanced_view) override;
// SystemTrayFocusObserver: // SystemTrayFocusObserver:
void OnFocusLeavingSystemTray(bool reverse) override; void OnFocusLeavingSystemTray(bool reverse) override;
......
...@@ -31,6 +31,16 @@ void LoginDataDispatcher::Observer::OnDevChannelInfoChanged( ...@@ -31,6 +31,16 @@ void LoginDataDispatcher::Observer::OnDevChannelInfoChanged(
const std::string& enterprise_info_text, const std::string& enterprise_info_text,
const std::string& bluetooth_name) {} const std::string& bluetooth_name) {}
void LoginDataDispatcher::Observer::OnPublicSessionDisplayNameChanged(
const AccountId& account_id,
const std::string& display_name) {}
void LoginDataDispatcher::Observer::OnPublicSessionLocalesChanged(
const AccountId& account_id,
const base::ListValue& locales,
const std::string& default_locale,
bool show_advanced_view) {}
LoginDataDispatcher::LoginDataDispatcher() = default; LoginDataDispatcher::LoginDataDispatcher() = default;
LoginDataDispatcher::~LoginDataDispatcher() = default; LoginDataDispatcher::~LoginDataDispatcher() = default;
...@@ -83,4 +93,22 @@ void LoginDataDispatcher::SetDevChannelInfo( ...@@ -83,4 +93,22 @@ void LoginDataDispatcher::SetDevChannelInfo(
} }
} }
void LoginDataDispatcher::SetPublicSessionDisplayName(
const AccountId& account_id,
const std::string& display_name) {
for (auto& observer : observers_)
observer.OnPublicSessionDisplayNameChanged(account_id, display_name);
}
void LoginDataDispatcher::SetPublicSessionLocales(
const AccountId& account_id,
std::unique_ptr<base::ListValue> locales,
const std::string& default_locale,
bool show_advanced_view) {
for (auto& observer : observers_) {
observer.OnPublicSessionLocalesChanged(account_id, *locales, default_locale,
show_advanced_view);
}
}
} // namespace ash } // namespace ash
...@@ -63,6 +63,20 @@ class ASH_EXPORT LoginDataDispatcher { ...@@ -63,6 +63,20 @@ class ASH_EXPORT LoginDataDispatcher {
const std::string& os_version_label_text, 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);
// Called when public session display name is changed for user with
// |account_id|.
virtual void OnPublicSessionDisplayNameChanged(
const AccountId& account_id,
const std::string& display_name);
// Called when public session locales are changed for user with
// |account_id|.
virtual void OnPublicSessionLocalesChanged(
const AccountId& account_id,
const base::ListValue& locales,
const std::string& default_locale,
bool show_advanced_view);
}; };
LoginDataDispatcher(); LoginDataDispatcher();
...@@ -80,6 +94,12 @@ class ASH_EXPORT LoginDataDispatcher { ...@@ -80,6 +94,12 @@ class ASH_EXPORT LoginDataDispatcher {
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 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);
private: private:
base::ObserverList<Observer> observers_; base::ObserverList<Observer> observers_;
......
...@@ -8,6 +8,7 @@ import "ash/public/interfaces/login_user_info.mojom"; ...@@ -8,6 +8,7 @@ import "ash/public/interfaces/login_user_info.mojom";
import "components/password_manager/public/interfaces/sync_password_data.mojom"; import "components/password_manager/public/interfaces/sync_password_data.mojom";
import "components/proximity_auth/public/interfaces/auth_type.mojom"; import "components/proximity_auth/public/interfaces/auth_type.mojom";
import "components/signin/public/interfaces/account_id.mojom"; import "components/signin/public/interfaces/account_id.mojom";
import "mojo/common/values.mojom";
import "mojo/public/mojom/base/string16.mojom"; import "mojo/public/mojom/base/string16.mojom";
// Allows clients (e.g. Chrome browser) to control the ash login/lock/user-add // Allows clients (e.g. Chrome browser) to control the ash login/lock/user-add
...@@ -82,6 +83,24 @@ interface LoginScreen { ...@@ -82,6 +83,24 @@ interface LoginScreen {
// Check if the login/lock screen is ready for a password. // Check if the login/lock screen is ready for a password.
IsReadyForPassword() => (bool is_ready); IsReadyForPassword() => (bool is_ready);
// Set the public session display name for user with |account_id|.
SetPublicSessionDisplayName(signin.mojom.AccountId account_id,
string display_name);
// Set the public session locales for user with |account_id|.
// TODO: Use array<LocaleStruct> for |locales| instead of
// mojo.common.mojom.ListValue.
// |locales|: Available locales for this user.
// Each entry is a base::DictionaryValue and it contains several
// keys like displayName, nativeDisplayName, optionGroupName etc.
// |default_locale|: Default locale for this user.
// |show_advanced_view|: True if we should show the advanced expanded user
// view for the public session.
SetPublicSessionLocales(signin.mojom.AccountId account_id,
mojo.common.mojom.ListValue locales,
string default_locale,
bool show_advanced_view);
}; };
// 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
......
...@@ -36,7 +36,6 @@ namespace chromeos { ...@@ -36,7 +36,6 @@ namespace chromeos {
ChromeUserSelectionScreen::ChromeUserSelectionScreen( ChromeUserSelectionScreen::ChromeUserSelectionScreen(
const std::string& display_type) const std::string& display_type)
: UserSelectionScreen(display_type), : UserSelectionScreen(display_type),
handler_initialized_(false),
weak_factory_(this) { weak_factory_(this) {
device_local_account_policy_service_ = device_local_account_policy_service_ =
g_browser_process->platform_part() g_browser_process->platform_part()
...@@ -66,7 +65,7 @@ void ChromeUserSelectionScreen::Init(const user_manager::UserList& users) { ...@@ -66,7 +65,7 @@ void ChromeUserSelectionScreen::Init(const user_manager::UserList& users) {
void ChromeUserSelectionScreen::SendUserList() { void ChromeUserSelectionScreen::SendUserList() {
UserSelectionScreen::SendUserList(); UserSelectionScreen::SendUserList();
handler_initialized_ = true; users_loaded_ = true;
} }
void ChromeUserSelectionScreen::OnPolicyUpdated(const std::string& user_id) { void ChromeUserSelectionScreen::OnPolicyUpdated(const std::string& user_id) {
...@@ -95,7 +94,7 @@ void ChromeUserSelectionScreen::CheckForPublicSessionDisplayNameChange( ...@@ -95,7 +94,7 @@ void ChromeUserSelectionScreen::CheckForPublicSessionDisplayNameChange(
public_session_display_names_[account_id] = display_name; public_session_display_names_[account_id] = display_name;
if (!handler_initialized_) if (!users_loaded_)
return; return;
if (!display_name.empty()) { if (!display_name.empty()) {
...@@ -166,7 +165,7 @@ void ChromeUserSelectionScreen::SetPublicSessionDisplayName( ...@@ -166,7 +165,7 @@ void ChromeUserSelectionScreen::SetPublicSessionDisplayName(
void ChromeUserSelectionScreen::SetPublicSessionLocales( void ChromeUserSelectionScreen::SetPublicSessionLocales(
const AccountId& account_id, const AccountId& account_id,
const std::vector<std::string>& recommended_locales) { const std::vector<std::string>& recommended_locales) {
if (!handler_initialized_) if (!users_loaded_)
return; return;
// Construct the list of available locales. This list consists of the // Construct the list of available locales. This list consists of the
......
...@@ -55,8 +55,6 @@ class ChromeUserSelectionScreen ...@@ -55,8 +55,6 @@ class ChromeUserSelectionScreen
const AccountId& account_id, const AccountId& account_id,
const std::vector<std::string>& recommended_locales); const std::vector<std::string>& recommended_locales);
bool handler_initialized_;
policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_;
// Map from public session account IDs to their display names set by policy. // Map from public session account IDs to their display names set by policy.
......
...@@ -862,6 +862,10 @@ UserSelectionScreen::UpdateAndReturnUserListForMojo() { ...@@ -862,6 +862,10 @@ UserSelectionScreen::UpdateAndReturnUserListForMojo() {
return user_info_list; return user_info_list;
} }
void UserSelectionScreen::SetUsersLoaded(bool loaded) {
users_loaded_ = loaded;
}
EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser(
const AccountId& account_id) const { const AccountId& account_id) const {
if (GetScreenType() == OTHER_SCREEN) if (GetScreenType() == OTHER_SCREEN)
......
...@@ -127,6 +127,7 @@ class UserSelectionScreen ...@@ -127,6 +127,7 @@ class UserSelectionScreen
std::unique_ptr<base::ListValue> UpdateAndReturnUserListForWebUI(); std::unique_ptr<base::ListValue> UpdateAndReturnUserListForWebUI();
std::vector<ash::mojom::LoginUserInfoPtr> UpdateAndReturnUserListForMojo(); std::vector<ash::mojom::LoginUserInfoPtr> UpdateAndReturnUserListForMojo();
void SetUsersLoaded(bool loaded);
protected: protected:
UserBoardView* view_ = nullptr; UserBoardView* view_ = nullptr;
...@@ -135,6 +136,9 @@ class UserSelectionScreen ...@@ -135,6 +136,9 @@ class UserSelectionScreen
std::map<AccountId, std::vector<std::string>> std::map<AccountId, std::vector<std::string>>
public_session_recommended_locales_; public_session_recommended_locales_;
// Whether users have been sent to the UI(WebUI or Views).
bool users_loaded_ = false;
private: private:
class DircryptoMigrationChecker; class DircryptoMigrationChecker;
......
...@@ -48,6 +48,7 @@ void LoginDisplayViews::Init(const user_manager::UserList& filtered_users, ...@@ -48,6 +48,7 @@ void LoginDisplayViews::Init(const user_manager::UserList& filtered_users,
user_selection_screen_->Init(filtered_users); user_selection_screen_->Init(filtered_users);
client->LoadUsers(user_selection_screen_->UpdateAndReturnUserListForMojo(), client->LoadUsers(user_selection_screen_->UpdateAndReturnUserListForMojo(),
show_guest); show_guest);
user_selection_screen_->SetUsersLoaded(true /*loaded*/);
} }
void LoginDisplayViews::OnPreferencesChanged() { void LoginDisplayViews::OnPreferencesChanged() {
......
...@@ -67,6 +67,23 @@ UserSelectionScreenProxy::UserSelectionScreenProxy() = default; ...@@ -67,6 +67,23 @@ UserSelectionScreenProxy::UserSelectionScreenProxy() = default;
UserSelectionScreenProxy::~UserSelectionScreenProxy() = default; UserSelectionScreenProxy::~UserSelectionScreenProxy() = default;
void UserSelectionScreenProxy::SetPublicSessionDisplayName(
const AccountId& account_id,
const std::string& display_name) {
LoginScreenClient::Get()->SetPublicSessionDisplayName(account_id,
display_name);
}
void UserSelectionScreenProxy::SetPublicSessionLocales(
const AccountId& account_id,
std::unique_ptr<base::ListValue> locales,
const std::string& default_locale,
bool multiple_recommended_locales) {
LoginScreenClient::Get()->SetPublicSessionLocales(
account_id, std::move(locales), default_locale,
multiple_recommended_locales);
}
void UserSelectionScreenProxy::ShowUserPodCustomIcon( void UserSelectionScreenProxy::ShowUserPodCustomIcon(
const AccountId& account_id, const AccountId& account_id,
const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
......
...@@ -20,11 +20,11 @@ class UserSelectionScreenProxy : public chromeos::UserBoardView { ...@@ -20,11 +20,11 @@ class UserSelectionScreenProxy : public chromeos::UserBoardView {
// UserBoardView: // UserBoardView:
void SetPublicSessionDisplayName(const AccountId& account_id, void SetPublicSessionDisplayName(const AccountId& account_id,
const std::string& display_name) override{}; const std::string& display_name) override;
void SetPublicSessionLocales(const AccountId& account_id, void SetPublicSessionLocales(const AccountId& account_id,
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) override{}; bool multiple_recommended_locales) override;
void ShowBannerMessage(const base::string16& message) override{}; void ShowBannerMessage(const base::string16& message) override{};
void ShowUserPodCustomIcon( void ShowUserPodCustomIcon(
const AccountId& account_id, const AccountId& account_id,
......
...@@ -196,6 +196,21 @@ void LoginScreenClient::IsReadyForPassword( ...@@ -196,6 +196,21 @@ void LoginScreenClient::IsReadyForPassword(
login_screen_->IsReadyForPassword(std::move(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) { void LoginScreenClient::SetDelegate(Delegate* delegate) {
delegate_ = delegate; delegate_ = delegate;
} }
...@@ -94,6 +94,12 @@ class LoginScreenClient : public ash::mojom::LoginScreenClient { ...@@ -94,6 +94,12 @@ class LoginScreenClient : public ash::mojom::LoginScreenClient {
const std::string& bluetooth_name); const std::string& bluetooth_name);
void IsReadyForPassword( void IsReadyForPassword(
ash::mojom::LoginScreen::IsReadyForPasswordCallback callback); 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); void SetDelegate(Delegate* delegate);
......
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