Mash cleanup: remove LoginScreenController::Observer
The two remaining methods are moved to LoginScreenModel::Observer. The
associated methods on mojom::LoginScreen are moved to LoginScreenModel.
Ownership of LoginDataDispatcher is moved to LoginScreenController
because the methods must be callable regardless of the presence of
LockScreen.
Bug: 958206
Change-Id: I0128e8c2bed5ad1f2569318933520e9c89d8b7c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626535
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663249}
diff --git a/ash/login/login_screen_controller.cc b/ash/login/login_screen_controller.cc
index 169b9c4..a1c241c 100644
--- a/ash/login/login_screen_controller.cc
+++ b/ash/login/login_screen_controller.cc
@@ -292,22 +292,12 @@
login_screen_client_->ShowFeedback();
}
-void LoginScreenController::AddObserver(
- LoginScreenControllerObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void LoginScreenController::RemoveObserver(
- LoginScreenControllerObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
void LoginScreenController::FlushForTesting() {
login_screen_client_.FlushForTesting();
}
LoginScreenModel* LoginScreenController::GetModel() {
- return DataDispatcher();
+ return &login_data_dispatcher_;
}
void LoginScreenController::SetClient(mojom::LoginScreenClientPtr client) {
@@ -345,13 +335,11 @@
}
void LoginScreenController::ShowWarningBanner(const base::string16& message) {
- if (DataDispatcher())
- DataDispatcher()->ShowWarningBanner(message);
+ login_data_dispatcher_.ShowWarningBanner(message);
}
void LoginScreenController::HideWarningBanner() {
- if (DataDispatcher())
- DataDispatcher()->HideWarningBanner();
+ login_data_dispatcher_.HideWarningBanner();
}
void LoginScreenController::ClearErrors() {
@@ -363,10 +351,10 @@
proximity_auth::mojom::AuthType auth_type,
const base::string16& initial_value) {
if (auth_type == proximity_auth::mojom::AuthType::USER_CLICK) {
- DataDispatcher()->SetTapToUnlockEnabledForUser(account_id,
- true /*enabled*/);
+ login_data_dispatcher_.SetTapToUnlockEnabledForUser(account_id,
+ true /*enabled*/);
} else if (auth_type == proximity_auth::mojom::AuthType::ONLINE_SIGN_IN) {
- DataDispatcher()->SetForceOnlineSignInForUser(account_id);
+ login_data_dispatcher_.SetForceOnlineSignInForUser(account_id);
} else {
NOTIMPLEMENTED();
}
@@ -376,34 +364,24 @@
bool is_enabled) {
// Chrome will update pin pod state every time user tries to authenticate.
// LockScreen is destroyed in the case of authentication success.
- if (DataDispatcher())
- DataDispatcher()->SetPinEnabledForUser(account_id, is_enabled);
+ login_data_dispatcher_.SetPinEnabledForUser(account_id, is_enabled);
}
void LoginScreenController::NotifyFingerprintAuthResult(
const AccountId& account_id,
bool successful) {
- if (DataDispatcher())
- DataDispatcher()->NotifyFingerprintAuthResult(account_id, successful);
+ login_data_dispatcher_.NotifyFingerprintAuthResult(account_id, successful);
}
void LoginScreenController::EnableAuthForUser(const AccountId& account_id) {
- if (DataDispatcher())
- DataDispatcher()->EnableAuthForUser(account_id);
+ login_data_dispatcher_.EnableAuthForUser(account_id);
}
void LoginScreenController::DisableAuthForUser(
const AccountId& account_id,
ash::mojom::AuthDisabledDataPtr auth_disabled_data) {
- if (DataDispatcher()) {
- DataDispatcher()->DisableAuthForUser(account_id,
- std::move(auth_disabled_data));
- }
-}
-
-void LoginScreenController::HandleFocusLeavingLockScreenApps(bool reverse) {
- for (auto& observer : observers_)
- observer.OnFocusLeavingLockScreenApps(reverse);
+ login_data_dispatcher_.DisableAuthForUser(account_id,
+ std::move(auth_disabled_data));
}
void LoginScreenController::SetSystemInfo(
@@ -411,10 +389,8 @@
const std::string& os_version_label_text,
const std::string& enterprise_info_text,
const std::string& bluetooth_name) {
- if (DataDispatcher()) {
- DataDispatcher()->SetSystemInfo(show_if_hidden, os_version_label_text,
- enterprise_info_text, bluetooth_name);
- }
+ login_data_dispatcher_.SetSystemInfo(show_if_hidden, os_version_label_text,
+ enterprise_info_text, bluetooth_name);
}
void LoginScreenController::IsReadyForPassword(
@@ -425,16 +401,13 @@
void LoginScreenController::SetPublicSessionDisplayName(
const AccountId& account_id,
const std::string& display_name) {
- if (DataDispatcher())
- DataDispatcher()->SetPublicSessionDisplayName(account_id, display_name);
+ login_data_dispatcher_.SetPublicSessionDisplayName(account_id, display_name);
}
void LoginScreenController::SetPublicSessionShowFullManagementDisclosure(
bool is_full_management_disclosure_needed) {
- if (DataDispatcher()) {
- DataDispatcher()->SetPublicSessionShowFullManagementDisclosure(
- is_full_management_disclosure_needed);
- }
+ login_data_dispatcher_.SetPublicSessionShowFullManagementDisclosure(
+ is_full_management_disclosure_needed);
}
void LoginScreenController::ShowKioskAppError(const std::string& message) {
@@ -445,12 +418,6 @@
Shell::Get()->toast_manager()->Show(toast_data);
}
-void LoginScreenController::NotifyOobeDialogState(
- mojom::OobeDialogState state) {
- for (auto& observer : observers_)
- observer.OnOobeDialogStateChanged(state);
-}
-
void LoginScreenController::SetAllowLoginAsGuest(bool allow_guest) {
Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
->shelf_widget()
@@ -473,8 +440,7 @@
}
void LoginScreenController::SetShowParentAccessDialog(bool show) {
- if (DataDispatcher())
- DataDispatcher()->SetShowParentAccessDialog(show);
+ login_data_dispatcher_.SetShowParentAccessDialog(show);
}
void LoginScreenController::FocusLoginShelf(bool reverse) {
@@ -551,12 +517,6 @@
std::move(callback).Run(base::make_optional<bool>(success));
}
-LoginDataDispatcher* LoginScreenController::DataDispatcher() const {
- if (!ash::LockScreen::HasInstance())
- return nullptr;
- return ash::LockScreen::Get()->data_dispatcher();
-}
-
void LoginScreenController::OnShow() {
SetSystemTrayVisibility(SystemTrayVisibility::kPrimary);
if (authentication_stage_ != AuthenticationStage::kIdle) {