Commit 242ff31d authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Mash cleanup: move LoginScreen::ShowWarningBanner to LoginScreenModel

ShowWarningBanner() and HideWarningBanner() are combined into
UpdateWarningMessage().

TBR=tsepez@chromium.org

Bug: 958206
Change-Id: I1569d2cec960357c5e6151bdfc32800be495c268
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1629428
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663978}
parent 336752cc
......@@ -334,14 +334,6 @@ void LoginScreenController::ShowErrorMessage(int32_t login_attempts,
NOTIMPLEMENTED();
}
void LoginScreenController::ShowWarningBanner(const base::string16& message) {
login_data_dispatcher_.ShowWarningBanner(message);
}
void LoginScreenController::HideWarningBanner() {
login_data_dispatcher_.HideWarningBanner();
}
void LoginScreenController::ClearErrors() {
NOTIMPLEMENTED();
}
......
......@@ -118,8 +118,6 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen,
const std::string& error_text,
const std::string& help_link_text,
int32_t help_topic_id) override;
void ShowWarningBanner(const base::string16& message) override;
void HideWarningBanner() override;
void ClearErrors() override;
void SetAuthType(const AccountId& account_id,
proximity_auth::mojom::AuthType auth_type,
......
......@@ -874,13 +874,19 @@ void LockContentsView::OnShowEasyUnlockIcon(const AccountId& user,
}
}
void LockContentsView::OnShowWarningBanner(const base::string16& message) {
DCHECK(!message.empty());
void LockContentsView::OnWarningMessageUpdated(const base::string16& message) {
if (message.empty()) {
if (warning_banner_bubble_->GetVisible())
warning_banner_bubble_->Hide();
return;
}
if (!CurrentBigUserView() || !CurrentBigUserView()->auth_user()) {
LOG(ERROR) << "Unable to find the current active big user to show a "
"warning banner.";
return;
}
if (warning_banner_bubble_->GetVisible())
warning_banner_bubble_->Hide();
// Shows warning banner as a persistent error bubble.
......@@ -898,11 +904,6 @@ void LockContentsView::OnShowWarningBanner(const base::string16& message) {
warning_banner_bubble_->Show();
}
void LockContentsView::OnHideWarningBanner() {
if (warning_banner_bubble_->GetVisible())
warning_banner_bubble_->Hide();
}
void LockContentsView::OnLockScreenNoteStateChanged(
mojom::TrayActionState state) {
if (disable_lock_screen_note_)
......
......@@ -152,8 +152,7 @@ class ASH_EXPORT LockContentsView
void OnForceOnlineSignInForUser(const AccountId& user) override;
void OnShowEasyUnlockIcon(const AccountId& user,
const EasyUnlockIconOptions& icon) override;
void OnShowWarningBanner(const base::string16& message) override;
void OnHideWarningBanner() override;
void OnWarningMessageUpdated(const base::string16& message) override;
void OnSystemInfoChanged(bool show,
const std::string& os_version_label_text,
const std::string& enterprise_info_text,
......
......@@ -2167,15 +2167,15 @@ TEST_F(LockContentsViewUnitTest, ShowHideWarningBannerBubble) {
EXPECT_FALSE(test_api.warning_banner_bubble()->GetVisible());
// Verifies that a warning banner is shown by giving a non-empty message.
DataDispatcher()->ShowWarningBanner(base::ASCIIToUTF16("foo"));
DataDispatcher()->UpdateWarningMessage(base::ASCIIToUTF16("foo"));
EXPECT_TRUE(test_api.warning_banner_bubble()->GetVisible());
// Verifies that a warning banner is hidden by HideWarningBanner().
DataDispatcher()->HideWarningBanner();
DataDispatcher()->UpdateWarningMessage({});
EXPECT_FALSE(test_api.warning_banner_bubble()->GetVisible());
// Shows a warning banner again.
DataDispatcher()->ShowWarningBanner(base::ASCIIToUTF16("foo"));
DataDispatcher()->UpdateWarningMessage(base::ASCIIToUTF16("foo"));
EXPECT_TRUE(test_api.warning_banner_bubble()->GetVisible());
// Attempt and fail user auth - an auth error is expected to be shown.
......
......@@ -436,12 +436,10 @@ class LockDebugView::DebugDataDispatcherTransformer
enterprise_info, bluetooth_name);
}
void ShowWarningBanner(const base::string16& message) {
debug_dispatcher_.ShowWarningBanner(message);
void UpdateWarningMessage(const base::string16& message) {
debug_dispatcher_.UpdateWarningMessage(message);
}
void HideWarningBanner() { debug_dispatcher_.HideWarningBanner(); }
// LoginDataDispatcher::Observer:
void OnUsersChanged(const std::vector<LoginUserInfo>& users) override {
// Update root_users_ to new source data.
......@@ -975,9 +973,9 @@ void LockDebugView::ButtonPressed(views::Button* sender,
// Show or hide warning banner.
if (sender->GetID() == ButtonId::kGlobalToggleWarningBanner) {
if (is_warning_banner_shown_) {
debug_data_dispatcher_->HideWarningBanner();
debug_data_dispatcher_->UpdateWarningMessage({});
} else {
debug_data_dispatcher_->ShowWarningBanner(base::ASCIIToUTF16(
debug_data_dispatcher_->UpdateWarningMessage(base::ASCIIToUTF16(
"A critical update is ready to install. Sign in to get started."));
}
is_warning_banner_shown_ = !is_warning_banner_shown_;
......
......@@ -48,11 +48,9 @@ void LoginDataDispatcher::Observer::OnShowEasyUnlockIcon(
const AccountId& user,
const EasyUnlockIconOptions& icon) {}
void LoginDataDispatcher::Observer::OnShowWarningBanner(
void LoginDataDispatcher::Observer::OnWarningMessageUpdated(
const base::string16& message) {}
void LoginDataDispatcher::Observer::OnHideWarningBanner() {}
void LoginDataDispatcher::Observer::OnSystemInfoChanged(
bool show,
const std::string& os_version_label_text,
......@@ -167,14 +165,9 @@ void LoginDataDispatcher::ShowEasyUnlockIcon(
observer.OnShowEasyUnlockIcon(user, icon);
}
void LoginDataDispatcher::ShowWarningBanner(const base::string16& message) {
for (auto& observer : observers_)
observer.OnShowWarningBanner(message);
}
void LoginDataDispatcher::HideWarningBanner() {
void LoginDataDispatcher::UpdateWarningMessage(const base::string16& message) {
for (auto& observer : observers_)
observer.OnHideWarningBanner();
observer.OnWarningMessageUpdated(message);
}
void LoginDataDispatcher::SetSystemInfo(
......
......@@ -86,11 +86,9 @@ class ASH_EXPORT LoginDataDispatcher : public LoginScreenModel {
virtual void OnShowEasyUnlockIcon(const AccountId& user,
const EasyUnlockIconOptions& icon);
// Called when a warning banner message should be displayed.
virtual void OnShowWarningBanner(const base::string16& message);
// Called when a warning banner message should be hidden.
virtual void OnHideWarningBanner();
// Called when a warning message should be displayed, or hidden if |message|
// is empty.
virtual void OnWarningMessageUpdated(const base::string16& message);
// Called when the system info has changed.
virtual void OnSystemInfoChanged(bool show,
......@@ -168,8 +166,7 @@ class ASH_EXPORT LoginDataDispatcher : public LoginScreenModel {
void SetLockScreenNoteState(mojom::TrayActionState state);
void ShowEasyUnlockIcon(const AccountId& user,
const EasyUnlockIconOptions& icon) override;
void ShowWarningBanner(const base::string16& message);
void HideWarningBanner();
void UpdateWarningMessage(const base::string16& message) override;
void SetSystemInfo(bool show_if_hidden,
const std::string& os_version_label_text,
const std::string& enterprise_info_text,
......
......@@ -8,6 +8,7 @@
#include <string>
#include "ash/public/cpp/ash_public_export.h"
#include "base/strings/string16.h"
class AccountId;
......@@ -31,6 +32,12 @@ class ASH_PUBLIC_EXPORT LoginScreenModel {
virtual void ShowEasyUnlockIcon(const AccountId& account_id,
const EasyUnlockIconOptions& icon) = 0;
// Shows a warning banner message on the login screen. A warning banner is
// used to notify users of important messages before they log in to their
// session. (e.g. Tell the user that an update of the user data will start
// on login.) If |message| is empty, the banner will be hidden.
virtual void UpdateWarningMessage(const base::string16& message) = 0;
// Set the users who are displayed on the login UI. |users| is filtered
// and does not correspond to every user on the device.
virtual void SetUserList(const std::vector<LoginUserInfo>& users) = 0;
......
......@@ -63,18 +63,6 @@ interface LoginScreen {
string help_link_text,
int32 help_topic_id);
// Shows a warning banner message on the login screen. A warning banner is
// used to notify users of important messages before they log in to their
// session. (e.g. Tell the user that an update of the user data will start
// on login)
// |message|: The message to show.
ShowWarningBanner(mojo_base.mojom.String16 message);
// Hide a warning banner if it is displayed.
// TODO(fukino): Ideally chrome-side should not have this level of UI
// control. Make the API simpler and let ash determine the UI behavior.
HideWarningBanner();
// Requests to close any displayed error messages in ash lock screen.
ClearErrors();
......
......@@ -104,11 +104,7 @@ void UserBoardViewMojo::ShowBannerMessage(const base::string16& message,
// warning banner message.
// TODO(fukino): Remove ShowWarningMessage and related implementation along
// with the migration screen once the transition to ext4 is compilete.
if (!message.empty()) {
LoginScreenClient::Get()->login_screen()->ShowWarningBanner(message);
} else {
LoginScreenClient::Get()->login_screen()->HideWarningBanner();
}
ash::LoginScreen::Get()->GetModel()->UpdateWarningMessage(message);
}
void UserBoardViewMojo::ShowUserPodCustomIcon(
......
......@@ -46,10 +46,6 @@ void TestLoginScreen::ShowErrorMessage(int32_t login_attempts,
const std::string& help_link_text,
int32_t help_topic_id) {}
void TestLoginScreen::ShowWarningBanner(const base::string16& message) {}
void TestLoginScreen::HideWarningBanner() {}
void TestLoginScreen::ClearErrors() {}
void TestLoginScreen::SetAuthType(const AccountId& account_id,
......
......@@ -35,8 +35,6 @@ class TestLoginScreen : public ash::mojom::LoginScreen,
const std::string& error_text,
const std::string& help_link_text,
int32_t help_topic_id) override;
void ShowWarningBanner(const base::string16& message) override;
void HideWarningBanner() override;
void ClearErrors() override;
void SetAuthType(const AccountId& account_id,
::proximity_auth::mojom::AuthType auth_type,
......
......@@ -14,6 +14,8 @@ void TestLoginScreenModel::SetAvatarForUser(const AccountId& account_id,
void TestLoginScreenModel::ShowEasyUnlockIcon(
const AccountId& account_id,
const ash::EasyUnlockIconOptions& icon) {}
void TestLoginScreenModel::UpdateWarningMessage(const base::string16& message) {
}
void TestLoginScreenModel::SetFingerprintState(const AccountId& account_id,
ash::FingerprintState state) {}
void TestLoginScreenModel::SetPublicSessionLocales(
......
......@@ -21,6 +21,7 @@ class TestLoginScreenModel : public ash::LoginScreenModel {
ash::FingerprintState state) override;
void ShowEasyUnlockIcon(const AccountId& user,
const ash::EasyUnlockIconOptions& icon) override;
void UpdateWarningMessage(const base::string16& message) override;
void SetPublicSessionLocales(const AccountId& account_id,
const std::vector<ash::LocaleItem>& locales,
const std::string& default_locale,
......
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