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/BUILD.gn b/ash/BUILD.gn
index 01361a8..70b198f 100644
--- a/ash/BUILD.gn
+++ b/ash/BUILD.gn
@@ -372,8 +372,6 @@
"lock_screen_action/lock_screen_note_launcher.h",
"login/login_screen_controller.cc",
"login/login_screen_controller.h",
- "login/login_screen_controller_observer.cc",
- "login/login_screen_controller_observer.h",
"login/ui/animated_rounded_image_view.cc",
"login/ui/animated_rounded_image_view.h",
"login/ui/animation_frame.h",
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) {
diff --git a/ash/login/login_screen_controller.h b/ash/login/login_screen_controller.h
index 53468c7da..4e5059077 100644
--- a/ash/login/login_screen_controller.h
+++ b/ash/login/login_screen_controller.h
@@ -8,13 +8,12 @@
#include <vector>
#include "ash/ash_export.h"
-#include "ash/login/login_screen_controller_observer.h"
+#include "ash/login/ui/login_data_dispatcher.h"
#include "ash/public/cpp/kiosk_app_menu.h"
#include "ash/public/cpp/login_screen.h"
#include "ash/public/cpp/system_tray_focus_observer.h"
#include "ash/public/interfaces/login_screen.mojom.h"
#include "base/macros.h"
-#include "base/observer_list.h"
#include "base/optional.h"
#include "mojo/public/cpp/bindings/binding_set.h"
@@ -22,7 +21,6 @@
namespace ash {
-class LoginDataDispatcher;
class SystemTrayNotifier;
// LoginScreenController implements mojom::LoginScreen and wraps the
@@ -103,10 +101,6 @@
void FocusOobeDialog();
void NotifyUserActivity();
- // Add or remove an observer.
- void AddObserver(LoginScreenControllerObserver* observer);
- void RemoveObserver(LoginScreenControllerObserver* observer);
-
// Enable or disable authentication for the debug overlay.
enum class ForceFailAuth { kOff, kImmediate, kDelayed };
void set_force_fail_auth_for_debug_overlay(ForceFailAuth force_fail) {
@@ -138,7 +132,6 @@
void DisableAuthForUser(
const AccountId& account_id,
ash::mojom::AuthDisabledDataPtr auth_disabled_data) override;
- void HandleFocusLeavingLockScreenApps(bool reverse) override;
void SetSystemInfo(bool show_if_hidden,
const std::string& os_version_label_text,
const std::string& enterprise_info_text,
@@ -149,7 +142,6 @@
void SetPublicSessionShowFullManagementDisclosure(
bool is_full_management_disclosure_needed) override;
void ShowKioskAppError(const std::string& message) override;
- void NotifyOobeDialogState(mojom::OobeDialogState state) override;
void SetAddUserButtonEnabled(bool enable) override;
void SetShutdownButtonEnabled(bool enable) override;
void SetAllowLoginAsGuest(bool allow_guest) override;
@@ -171,20 +163,21 @@
return authentication_stage_;
}
+ LoginDataDispatcher* data_dispatcher() { return &login_data_dispatcher_; }
+
private:
void OnAuthenticateComplete(OnAuthenticateCallback callback, bool success);
void OnParentAccessValidationComplete(OnParentAccessValidation callback,
bool success);
- // Returns the active data dispatcher or nullptr if there is no lock screen.
- LoginDataDispatcher* DataDispatcher() const;
-
// Common code that is called when the login/lock screen is shown.
void OnShow();
// SystemTrayFocusObserver:
void OnFocusLeavingSystemTray(bool reverse) override;
+ LoginDataDispatcher login_data_dispatcher_;
+
// Client interface in chrome browser. May be null in tests.
mojom::LoginScreenClientPtr login_screen_client_;
@@ -195,8 +188,6 @@
SystemTrayNotifier* system_tray_notifier_;
- base::ObserverList<LoginScreenControllerObserver>::Unchecked observers_;
-
// If set to false, all auth requests will forcibly fail.
ForceFailAuth force_fail_auth_for_debug_overlay_ = ForceFailAuth::kOff;
diff --git a/ash/login/login_screen_controller_observer.cc b/ash/login/login_screen_controller_observer.cc
deleted file mode 100644
index 3826f07..0000000
--- a/ash/login/login_screen_controller_observer.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/login/login_screen_controller_observer.h"
-
-namespace ash {
-
-LoginScreenControllerObserver::~LoginScreenControllerObserver() = default;
-
-void LoginScreenControllerObserver::OnFocusLeavingLockScreenApps(bool reverse) {
-}
-
-void LoginScreenControllerObserver::OnOobeDialogStateChanged(
- mojom::OobeDialogState state) {}
-
-} // namespace ash
diff --git a/ash/login/login_screen_controller_observer.h b/ash/login/login_screen_controller_observer.h
deleted file mode 100644
index 92c09a9b6..0000000
--- a/ash/login/login_screen_controller_observer.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_LOGIN_LOGIN_SCREEN_CONTROLLER_OBSERVER_H_
-#define ASH_LOGIN_LOGIN_SCREEN_CONTROLLER_OBSERVER_H_
-
-#include "ash/ash_export.h"
-#include "ash/public/interfaces/login_screen.mojom.h"
-
-namespace ash {
-
-// Interface used by LoginScreenController when some events have been received
-// from another process, ie, chrome.
-class ASH_EXPORT LoginScreenControllerObserver {
- public:
- virtual ~LoginScreenControllerObserver();
-
- // Called when focus is leaving a lock screen app window due to tabbing.
- // |reverse| - whether the tab order is reversed.
- virtual void OnFocusLeavingLockScreenApps(bool reverse);
-
- // Called when the state of the OOBE dialog is changed.
- virtual void OnOobeDialogStateChanged(mojom::OobeDialogState state);
-};
-
-} // namespace ash
-
-#endif // ASH_LOGIN_LOGIN_SCREEN_CONTROLLER_OBSERVER_H_
diff --git a/ash/login/ui/lock_contents_view.cc b/ash/login/ui/lock_contents_view.cc
index 9d52fab..75e8c83 100644
--- a/ash/login/ui/lock_contents_view.cc
+++ b/ash/login/ui/lock_contents_view.cc
@@ -386,7 +386,6 @@
data_dispatcher_->AddObserver(this);
display_observer_.Add(display::Screen::GetScreen());
- Shell::Get()->login_screen_controller()->AddObserver(this);
Shell::Get()->system_tray_notifier()->AddSystemTrayFocusObserver(this);
keyboard::KeyboardController::Get()->AddObserver(this);
@@ -455,7 +454,6 @@
LockContentsView::~LockContentsView() {
Shell::Get()->accelerator_controller()->UnregisterAll(this);
data_dispatcher_->RemoveObserver(this);
- Shell::Get()->login_screen_controller()->RemoveObserver(this);
keyboard::KeyboardController::Get()->RemoveObserver(this);
Shell::Get()->system_tray_notifier()->RemoveSystemTrayFocusObserver(this);
@@ -1095,8 +1093,8 @@
FocusFirstOrLastFocusableChild(this, reverse);
}
-void LockContentsView::OnOobeDialogStateChanged(mojom::OobeDialogState state) {
- oobe_dialog_visible_ = state != mojom::OobeDialogState::HIDDEN;
+void LockContentsView::OnOobeDialogStateChanged(OobeDialogState state) {
+ oobe_dialog_visible_ = state != OobeDialogState::HIDDEN;
// Deactivate the lock screen widget while the dialog is visible to
// prevent lock screen from grabbing focus and hiding the OOBE dialog.
@@ -1107,7 +1105,7 @@
// effect.
set_can_process_events_within_subtree(!oobe_dialog_visible_);
- if (state == mojom::OobeDialogState::HIDDEN && primary_big_view_)
+ if (state == OobeDialogState::HIDDEN && primary_big_view_)
primary_big_view_->RequestFocus();
}
diff --git a/ash/login/ui/lock_contents_view.h b/ash/login/ui/lock_contents_view.h
index 157d4ad..d0a0d01 100644
--- a/ash/login/ui/lock_contents_view.h
+++ b/ash/login/ui/lock_contents_view.h
@@ -13,8 +13,6 @@
#include "ash/ash_export.h"
#include "ash/keyboard/ui/keyboard_controller.h"
#include "ash/keyboard/ui/keyboard_controller_observer.h"
-#include "ash/login/login_screen_controller.h"
-#include "ash/login/login_screen_controller_observer.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/login_data_dispatcher.h"
#include "ash/login/ui/login_display_style.h"
@@ -64,7 +62,6 @@
// at a time.
class ASH_EXPORT LockContentsView
: public NonAccessibleView,
- public LoginScreenControllerObserver,
public LoginDataDispatcher::Observer,
public SystemTrayFocusObserver,
public display::DisplayObserver,
@@ -136,10 +133,6 @@
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
- // LoginScreenController::Observer:
- void OnFocusLeavingLockScreenApps(bool reverse) override;
- void OnOobeDialogStateChanged(mojom::OobeDialogState state) override;
-
// LoginDataDispatcher::Observer:
void OnUsersChanged(const std::vector<LoginUserInfo>& users) override;
void OnUserAvatarChanged(const AccountId& account_id,
@@ -181,6 +174,8 @@
void OnDetachableBasePairingStatusChanged(
DetachableBasePairingStatus pairing_status) override;
void OnSetShowParentAccessDialog(bool show) override;
+ void OnFocusLeavingLockScreenApps(bool reverse) override;
+ void OnOobeDialogStateChanged(OobeDialogState state) override;
// SystemTrayFocusObserver:
void OnFocusLeavingSystemTray(bool reverse) override;
diff --git a/ash/login/ui/lock_contents_view_unittest.cc b/ash/login/ui/lock_contents_view_unittest.cc
index d418441..0c0b2c4f 100644
--- a/ash/login/ui/lock_contents_view_unittest.cc
+++ b/ash/login/ui/lock_contents_view_unittest.cc
@@ -2,16 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ash/login/ui/lock_contents_view.h"
+
#include <memory>
#include <string>
#include <unordered_set>
#include <utility>
#include "ash/detachable_base/detachable_base_pairing_status.h"
+#include "ash/login/login_screen_controller.h"
#include "ash/login/mock_login_screen_client.h"
#include "ash/login/ui/arrow_button_view.h"
#include "ash/login/ui/fake_login_detachable_base_model.h"
-#include "ash/login/ui/lock_contents_view.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/login_auth_user_view.h"
#include "ash/login/ui/login_big_user_view.h"
@@ -2332,8 +2334,7 @@
std::unique_ptr<MockLoginScreenClient> client = BindMockLoginScreenClient();
EXPECT_CALL(*client, FocusOobeDialog()).Times(1);
- Shell::Get()->login_screen_controller()->NotifyOobeDialogState(
- mojom::OobeDialogState::GAIA_SIGNIN);
+ DataDispatcher()->NotifyOobeDialogState(OobeDialogState::GAIA_SIGNIN);
lock->OnFocusLeavingSystemTray(false /* reverse */);
Shell::Get()->login_screen_controller()->FlushForTesting();
}
@@ -2349,8 +2350,7 @@
std::unique_ptr<MockLoginScreenClient> client = BindMockLoginScreenClient();
EXPECT_CALL(*client, FocusOobeDialog()).Times(0);
- Shell::Get()->login_screen_controller()->NotifyOobeDialogState(
- mojom::OobeDialogState::HIDDEN);
+ DataDispatcher()->NotifyOobeDialogState(OobeDialogState::HIDDEN);
lock->OnFocusLeavingSystemTray(false /* reverse */);
Shell::Get()->login_screen_controller()->FlushForTesting();
}
@@ -2373,8 +2373,7 @@
AccountId list_user =
list_user_view->current_user().basic_user_info.account_id;
- Shell::Get()->login_screen_controller()->NotifyOobeDialogState(
- mojom::OobeDialogState::GAIA_SIGNIN);
+ DataDispatcher()->NotifyOobeDialogState(OobeDialogState::GAIA_SIGNIN);
// Send event to swap users.
ui::test::EventGenerator* generator = GetEventGenerator();
@@ -2388,8 +2387,7 @@
list_user_view->current_user().basic_user_info.account_id);
// Hide OOBE dialog.
- Shell::Get()->login_screen_controller()->NotifyOobeDialogState(
- mojom::OobeDialogState::HIDDEN);
+ DataDispatcher()->NotifyOobeDialogState(OobeDialogState::HIDDEN);
// Attempt swap again.
generator->MoveMouseTo(list_user_view->GetBoundsInScreen().CenterPoint());
diff --git a/ash/login/ui/lock_debug_view.cc b/ash/login/ui/lock_debug_view.cc
index 74f901b4..80392727 100644
--- a/ash/login/ui/lock_debug_view.cc
+++ b/ash/login/ui/lock_debug_view.cc
@@ -541,8 +541,7 @@
public:
static constexpr int kNullBaseId = -1;
- explicit DebugLoginDetachableBaseModel(LoginDataDispatcher* data_dispatcher)
- : data_dispatcher_(data_dispatcher) {}
+ DebugLoginDetachableBaseModel() = default;
~DebugLoginDetachableBaseModel() override = default;
bool debugging_pairing_state() const { return pairing_status_.has_value(); }
@@ -595,7 +594,10 @@
base_id_ = kNullBaseId;
}
- data_dispatcher_->SetDetachableBasePairingStatus(pairing_status);
+ Shell::Get()
+ ->login_screen_controller()
+ ->data_dispatcher()
+ ->SetDetachableBasePairingStatus(pairing_status);
}
// Marks the paired base (as seen by the model) as the user's last used base.
@@ -606,7 +608,10 @@
DCHECK_GE(base_id_, 0);
last_used_bases_[account_id] = base_id_;
- data_dispatcher_->SetDetachableBasePairingStatus(*pairing_status_);
+ Shell::Get()
+ ->login_screen_controller()
+ ->data_dispatcher()
+ ->SetDetachableBasePairingStatus(*pairing_status_);
}
// Clears all in-memory pairing state.
@@ -615,8 +620,10 @@
base_id_ = kNullBaseId;
last_used_bases_.clear();
- data_dispatcher_->SetDetachableBasePairingStatus(
- DetachableBasePairingStatus::kNone);
+ Shell::Get()
+ ->login_screen_controller()
+ ->data_dispatcher()
+ ->SetDetachableBasePairingStatus(DetachableBasePairingStatus::kNone);
}
// LoginDetachableBaseModel:
@@ -642,8 +649,6 @@
}
private:
- LoginDataDispatcher* data_dispatcher_;
-
// In-memory detachable base pairing state.
base::Optional<DetachableBasePairingStatus> pairing_status_;
int base_id_ = kNullBaseId;
@@ -655,11 +660,10 @@
};
LockDebugView::LockDebugView(mojom::TrayActionState initial_note_action_state,
- LockScreen::ScreenType screen_type,
- LoginDataDispatcher* data_dispatcher)
+ LockScreen::ScreenType screen_type)
: debug_data_dispatcher_(std::make_unique<DebugDataDispatcherTransformer>(
initial_note_action_state,
- data_dispatcher,
+ Shell::Get()->login_screen_controller()->data_dispatcher(),
base::BindRepeating(
&LockDebugView::UpdatePerUserActionContainerAndLayout,
base::Unretained(this)))),
@@ -668,7 +672,7 @@
std::make_unique<views::BoxLayout>(views::BoxLayout::kHorizontal));
auto debug_detachable_base_model =
- std::make_unique<DebugLoginDetachableBaseModel>(data_dispatcher);
+ std::make_unique<DebugLoginDetachableBaseModel>();
debug_detachable_base_model_ = debug_detachable_base_model.get();
lock_ = new LockContentsView(initial_note_action_state, screen_type,
diff --git a/ash/login/ui/lock_debug_view.h b/ash/login/ui/lock_debug_view.h
index cac00eb..63fa82c 100644
--- a/ash/login/ui/lock_debug_view.h
+++ b/ash/login/ui/lock_debug_view.h
@@ -21,7 +21,6 @@
namespace ash {
-class LoginDataDispatcher;
class LockContentsView;
namespace mojom {
@@ -32,8 +31,7 @@
class LockDebugView : public views::View, public views::ButtonListener {
public:
LockDebugView(mojom::TrayActionState initial_note_action_state,
- LockScreen::ScreenType screen_type,
- LoginDataDispatcher* data_dispatcher);
+ LockScreen::ScreenType screen_type);
~LockDebugView() override;
// views::View:
diff --git a/ash/login/ui/lock_screen.cc b/ash/login/ui/lock_screen.cc
index 1b11dde..4bf83d4 100644
--- a/ash/login/ui/lock_screen.cc
+++ b/ash/login/ui/lock_screen.cc
@@ -51,9 +51,7 @@
}
LockScreen::~LockScreen() {
- // Must happen before data_dispatcher_.reset().
widget_.reset();
- data_dispatcher_.reset();
ui::Clipboard::DestroyClipboardForCurrentThread();
if (saved_clipboard_)
@@ -83,30 +81,23 @@
instance_->widget_->SetBounds(
display::Screen::GetScreen()->GetPrimaryDisplay().bounds());
- auto data_dispatcher = std::make_unique<LoginDataDispatcher>();
auto initial_note_action_state =
Shell::Get()->tray_action()->GetLockScreenNoteState();
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kShowLoginDevOverlay)) {
- auto* debug_view = new LockDebugView(initial_note_action_state, type,
- data_dispatcher.get());
+ auto* debug_view = new LockDebugView(initial_note_action_state, type);
instance_->contents_view_ = debug_view->lock();
instance_->widget_->SetContentsView(debug_view);
} else {
auto detachable_base_model = LoginDetachableBaseModel::Create(
- Shell::Get()->detachable_base_handler(), data_dispatcher.get());
+ Shell::Get()->detachable_base_handler());
instance_->contents_view_ = new LockContentsView(
- initial_note_action_state, type, data_dispatcher.get(),
+ initial_note_action_state, type,
+ Shell::Get()->login_screen_controller()->data_dispatcher(),
std::move(detachable_base_model));
instance_->widget_->SetContentsView(instance_->contents_view_);
}
- data_dispatcher->AddObserver(Shelf::ForWindow(Shell::GetPrimaryRootWindow())
- ->shelf_widget()
- ->login_shelf_view());
-
- instance_->data_dispatcher_ = std::move(data_dispatcher);
-
// Postpone showing the screen after the animation of the first wallpaper
// completes, to make the transition smooth. The callback will be dispatched
// immediately if the animation is already complete (e.g. kLock).
@@ -137,7 +128,7 @@
}
CHECK_EQ(instance_, this);
- data_dispatcher_->RemoveObserver(
+ Shell::Get()->login_screen_controller()->data_dispatcher()->RemoveObserver(
Shelf::ForWindow(Shell::GetPrimaryRootWindow())
->shelf_widget()
->login_shelf_view());
@@ -155,8 +146,10 @@
}
void LockScreen::OnLockScreenNoteStateChanged(mojom::TrayActionState state) {
- if (data_dispatcher())
- data_dispatcher()->SetLockScreenNoteState(state);
+ Shell::Get()
+ ->login_screen_controller()
+ ->data_dispatcher()
+ ->SetLockScreenNoteState(state);
}
void LockScreen::OnSessionStateChanged(session_manager::SessionState state) {
diff --git a/ash/login/ui/lock_screen.h b/ash/login/ui/lock_screen.h
index 54936d1c5..89df403 100644
--- a/ash/login/ui/lock_screen.h
+++ b/ash/login/ui/lock_screen.h
@@ -19,7 +19,6 @@
namespace ash {
class LockContentsView;
-class LoginDataDispatcher;
class TrayAction;
class ASH_EXPORT LockScreen : public TrayActionObserver,
@@ -58,9 +57,6 @@
ScreenType screen_type() const { return type_; }
- // Returns the active data dispatcher.
- LoginDataDispatcher* data_dispatcher() { return data_dispatcher_.get(); }
-
// Returns if the screen has been shown (i.e. |LockWindow::Show| was called).
bool is_shown() const { return is_shown_; }
@@ -84,8 +80,6 @@
// The lock screen widget.
std::unique_ptr<views::Widget> widget_;
- std::unique_ptr<LoginDataDispatcher> data_dispatcher_;
-
// Unowned pointer to the LockContentsView hosted in lock window.
LockContentsView* contents_view_ = nullptr;
diff --git a/ash/login/ui/lock_screen_sanity_unittest.cc b/ash/login/ui/lock_screen_sanity_unittest.cc
index b42b5ef..7756cf6 100644
--- a/ash/login/ui/lock_screen_sanity_unittest.cc
+++ b/ash/login/ui/lock_screen_sanity_unittest.cc
@@ -281,7 +281,7 @@
// Initially, focus should be with the lock screen app - when the app loses
// focus (notified via mojo interface), shelf should get the focus next.
EXPECT_TRUE(VerifyFocused(lock_screen_app));
- controller->HandleFocusLeavingLockScreenApps(false /*reverse*/);
+ DataDispatcher()->HandleFocusLeavingLockScreenApps(false /*reverse*/);
EXPECT_TRUE(VerifyFocused(shelf));
// Reversing focus should bring focus back to the lock screen app.
@@ -293,7 +293,7 @@
// Have the app tab out in reverse tab order - in this case, the status area
// should get the focus.
- controller->HandleFocusLeavingLockScreenApps(true /*reverse*/);
+ DataDispatcher()->HandleFocusLeavingLockScreenApps(true /*reverse*/);
EXPECT_TRUE(VerifyFocused(status_area));
// Tabbing out of the status area (in default order) should focus the lock
@@ -306,7 +306,7 @@
// Tab out of the lock screen app once more - the shelf should get the focus
// again.
- controller->HandleFocusLeavingLockScreenApps(false /*reverse*/);
+ DataDispatcher()->HandleFocusLeavingLockScreenApps(false /*reverse*/);
EXPECT_TRUE(VerifyFocused(shelf));
}
@@ -335,8 +335,7 @@
EXPECT_TRUE(VerifyFocused(lock_screen_app));
// Tab out of the lock screen app - shelf should get the focus.
- Shell::Get()->login_screen_controller()->HandleFocusLeavingLockScreenApps(
- false /*reverse*/);
+ DataDispatcher()->HandleFocusLeavingLockScreenApps(false /*reverse*/);
EXPECT_TRUE(VerifyFocused(shelf));
// Move the lock screen note taking to available state (which happens when the
diff --git a/ash/login/ui/login_data_dispatcher.cc b/ash/login/ui/login_data_dispatcher.cc
index 63e5a35..b5070c0e 100644
--- a/ash/login/ui/login_data_dispatcher.cc
+++ b/ash/login/ui/login_data_dispatcher.cc
@@ -83,6 +83,12 @@
void LoginDataDispatcher::Observer::OnSetShowParentAccessDialog(bool show) {}
+void LoginDataDispatcher::Observer::OnFocusLeavingLockScreenApps(bool reverse) {
+}
+
+void LoginDataDispatcher::Observer::OnOobeDialogStateChanged(
+ OobeDialogState state) {}
+
LoginDataDispatcher::LoginDataDispatcher() = default;
LoginDataDispatcher::~LoginDataDispatcher() = default;
@@ -229,4 +235,14 @@
observer.OnSetShowParentAccessDialog(show);
}
+void LoginDataDispatcher::HandleFocusLeavingLockScreenApps(bool reverse) {
+ for (auto& observer : observers_)
+ observer.OnFocusLeavingLockScreenApps(reverse);
+}
+
+void LoginDataDispatcher::NotifyOobeDialogState(OobeDialogState state) {
+ for (auto& observer : observers_)
+ observer.OnOobeDialogStateChanged(state);
+}
+
} // namespace ash
diff --git a/ash/login/ui/login_data_dispatcher.h b/ash/login/ui/login_data_dispatcher.h
index f10fec01..c943ced 100644
--- a/ash/login/ui/login_data_dispatcher.h
+++ b/ash/login/ui/login_data_dispatcher.h
@@ -131,6 +131,13 @@
// Called when parent access code input dialog visibility should change.
virtual void OnSetShowParentAccessDialog(bool show);
+
+ // Called when focus is leaving a lock screen app window due to tabbing.
+ // |reverse| - whether the tab order is reversed.
+ virtual void OnFocusLeavingLockScreenApps(bool reverse);
+
+ // Called when the state of the OOBE dialog is changed.
+ virtual void OnOobeDialogStateChanged(OobeDialogState state);
};
LoginDataDispatcher();
@@ -182,6 +189,8 @@
void SetDetachableBasePairingStatus(
DetachableBasePairingStatus pairing_status);
void SetShowParentAccessDialog(bool show);
+ void HandleFocusLeavingLockScreenApps(bool reverse) override;
+ void NotifyOobeDialogState(OobeDialogState state) override;
private:
base::ObserverList<Observer>::Unchecked observers_;
diff --git a/ash/login/ui/login_detachable_base_model.cc b/ash/login/ui/login_detachable_base_model.cc
index 95bd89b..7fdf0a8 100644
--- a/ash/login/ui/login_detachable_base_model.cc
+++ b/ash/login/ui/login_detachable_base_model.cc
@@ -7,8 +7,10 @@
#include "ash/detachable_base/detachable_base_handler.h"
#include "ash/detachable_base/detachable_base_observer.h"
#include "ash/detachable_base/detachable_base_pairing_status.h"
+#include "ash/login/login_screen_controller.h"
#include "ash/login/ui/login_data_dispatcher.h"
#include "ash/public/cpp/session/user_info.h"
+#include "ash/shell.h"
#include "base/macros.h"
#include "base/scoped_observer.h"
@@ -19,10 +21,9 @@
class LoginDetachableBaseModelImpl : public LoginDetachableBaseModel,
public DetachableBaseObserver {
public:
- LoginDetachableBaseModelImpl(DetachableBaseHandler* detachable_base_handler,
- LoginDataDispatcher* login_data_dispatcher)
- : detachable_base_handler_(detachable_base_handler),
- login_data_dispatcher_(login_data_dispatcher) {
+ explicit LoginDetachableBaseModelImpl(
+ DetachableBaseHandler* detachable_base_handler)
+ : detachable_base_handler_(detachable_base_handler) {
detachable_base_observer_.Add(detachable_base_handler);
}
@@ -42,7 +43,10 @@
// DetachableBaseObserver:
void OnDetachableBasePairingStatusChanged(
DetachableBasePairingStatus pairing_status) override {
- login_data_dispatcher_->SetDetachableBasePairingStatus(pairing_status);
+ Shell::Get()
+ ->login_screen_controller()
+ ->data_dispatcher()
+ ->SetDetachableBasePairingStatus(pairing_status);
}
void OnDetachableBaseRequiresUpdateChanged(bool requires_update) override {}
@@ -50,7 +54,6 @@
DetachableBaseHandler* detachable_base_handler_;
ScopedObserver<DetachableBaseHandler, DetachableBaseObserver>
detachable_base_observer_{this};
- LoginDataDispatcher* login_data_dispatcher_;
DISALLOW_COPY_AND_ASSIGN(LoginDetachableBaseModelImpl);
};
@@ -59,10 +62,9 @@
// static
std::unique_ptr<LoginDetachableBaseModel> LoginDetachableBaseModel::Create(
- DetachableBaseHandler* detachable_base_handler,
- LoginDataDispatcher* login_data_dispatcher) {
- return std::make_unique<LoginDetachableBaseModelImpl>(detachable_base_handler,
- login_data_dispatcher);
+ DetachableBaseHandler* detachable_base_handler) {
+ return std::make_unique<LoginDetachableBaseModelImpl>(
+ detachable_base_handler);
}
} // namespace ash
diff --git a/ash/login/ui/login_detachable_base_model.h b/ash/login/ui/login_detachable_base_model.h
index fcfbac6a..67614670 100644
--- a/ash/login/ui/login_detachable_base_model.h
+++ b/ash/login/ui/login_detachable_base_model.h
@@ -13,7 +13,6 @@
class DetachableBaseHandler;
enum class DetachableBasePairingStatus;
-class LoginDataDispatcher;
struct UserInfo;
// Wrapper around ash::DetachableBaseHandler used by login UI. Exposed as an
@@ -29,8 +28,7 @@
virtual ~LoginDetachableBaseModel() = default;
static std::unique_ptr<LoginDetachableBaseModel> Create(
- DetachableBaseHandler* detachable_base_handler,
- LoginDataDispatcher* login_data_dispatcher);
+ DetachableBaseHandler* detachable_base_handler);
// Returns the current detachable base pairing status.
virtual DetachableBasePairingStatus GetPairingStatus() = 0;
diff --git a/ash/login/ui/login_test_base.cc b/ash/login/ui/login_test_base.cc
index 9db6a2d..ab14fc2 100644
--- a/ash/login/ui/login_test_base.cc
+++ b/ash/login/ui/login_test_base.cc
@@ -151,8 +151,9 @@
}
LoginDataDispatcher* LoginTestBase::DataDispatcher() {
- return LockScreen::HasInstance() ? LockScreen::Get()->data_dispatcher()
- : &data_dispatcher_;
+ return LockScreen::HasInstance()
+ ? Shell::Get()->login_screen_controller()->data_dispatcher()
+ : &data_dispatcher_;
}
void LoginTestBase::TearDown() {
diff --git a/ash/public/cpp/login_screen_model.h b/ash/public/cpp/login_screen_model.h
index 441c490..4d44f088 100644
--- a/ash/public/cpp/login_screen_model.h
+++ b/ash/public/cpp/login_screen_model.h
@@ -14,6 +14,7 @@
namespace ash {
enum class FingerprintState;
+enum class OobeDialogState;
struct EasyUnlockIconOptions;
struct InputMethodItem;
struct LocaleItem;
@@ -59,6 +60,16 @@
const std::string& locale,
const std::vector<InputMethodItem>& keyboard_layouts) = 0;
+ // Called when focus is reported to be leaving a lock screen app window.
+ // Requests focus to be handed off to the next suitable widget.
+ // |reverse|: Whether the tab order is reversed.
+ virtual void HandleFocusLeavingLockScreenApps(bool reverse) = 0;
+
+ // Called when the dialog hosting oobe has changed state. The oobe dialog
+ // provides support for any part of login that is implemented in JS/HTML, such
+ // as add user or powerwash.
+ virtual void NotifyOobeDialogState(OobeDialogState state) = 0;
+
protected:
virtual ~LoginScreenModel();
};
diff --git a/ash/public/cpp/login_types.h b/ash/public/cpp/login_types.h
index ee2e5ee..be8fec24 100644
--- a/ash/public/cpp/login_types.h
+++ b/ash/public/cpp/login_types.h
@@ -12,6 +12,45 @@
namespace ash {
+// State of the Oobe UI dialog, which is used to update the visibility of login
+// shelf buttons.
+// This comes from SIGNIN_UI_STATE defined in display_manager.js, with an
+// additional value HIDDEN to indicate the visibility of the oobe ui dialog.
+enum class OobeDialogState {
+ // Showing other screen, which does not impact the visibility of login shelf
+ // buttons.
+ NONE = 0,
+
+ // Showing gaia signin screen.
+ GAIA_SIGNIN = 1,
+
+ // 2 is unused to keep in sync with display_manager.js
+
+ // Showing wrong hardware identification screen.
+ WRONG_HWID_WARNING = 3,
+
+ // Showing supervised user creation screen.
+ SUPERVISED_USER_CREATION_FLOW = 4,
+
+ // Showing SAML password confirmation screen.
+ SAML_PASSWORD_CONFIRM = 5,
+
+ // Showing password changed screen.
+ PASSWORD_CHANGED = 6,
+
+ // Showing device enrollment screen.
+ ENROLLMENT = 7,
+
+ // Showing error screen.
+ ERROR = 8,
+
+ // Showing sync consent screen.
+ SYNC_CONSENT = 9,
+
+ // Oobe UI dialog is currently hidden.
+ HIDDEN = 10,
+};
+
// Supported multi-profile user behavior values.
// Keep in sync with the enum in chromeos_user_pod_row.js and user_pod_row.js
// TODO(estade): change all the enums to use kCamelCase.
@@ -188,8 +227,8 @@
// True if this user is the device owner.
bool is_device_owner = false;
- // The initial fingerprint state. There are other mojom methods (ie,
- // login_screen.mojom::SetFingerprintState) which update the current state.
+ // The initial fingerprint state. There are other methods (ie,
+ // LoginScreenModel::SetFingerprintState) which update the current state.
FingerprintState fingerprint_state = FingerprintState::UNAVAILABLE;
// True if multi-profiles sign in is allowed for this user.
diff --git a/ash/public/interfaces/login_screen.mojom b/ash/public/interfaces/login_screen.mojom
index 7f942a2..80ac9302 100644
--- a/ash/public/interfaces/login_screen.mojom
+++ b/ash/public/interfaces/login_screen.mojom
@@ -9,45 +9,6 @@
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/time.mojom";
-// State of the Oobe UI dialog, which is used to update the visibility of login
-// shelf buttons.
-// This comes from SIGNIN_UI_STATE defined in display_manager.js, with an
-// additional value HIDDEN to indicate the visibility of the oobe ui dialog.
-enum OobeDialogState {
- // Showing other screen, which does not impact the visibility of login shelf
- // buttons.
- NONE = 0,
-
- // Showing gaia signin screen.
- GAIA_SIGNIN = 1,
-
- // 2 is unused to keep in sync with display_manager.js
-
- // Showing wrong hardware identification screen.
- WRONG_HWID_WARNING = 3,
-
- // Showing supervised user creation screen.
- SUPERVISED_USER_CREATION_FLOW = 4,
-
- // Showing SAML password confirmation screen.
- SAML_PASSWORD_CONFIRM = 5,
-
- // Showing password changed screen.
- PASSWORD_CHANGED = 6,
-
- // Showing device enrollment screen.
- ENROLLMENT = 7,
-
- // Showing error screen.
- ERROR = 8,
-
- // Showing sync consent screen.
- SYNC_CONSENT = 9,
-
- // Oobe UI dialog is currently hidden.
- HIDDEN = 10,
-};
-
// Reason why the auth is disabled. This is used to personalize the UI.
enum AuthDisabledReason {
// Auth is disabled because the device is locked by a time limit override.
@@ -149,11 +110,6 @@
DisableAuthForUser(signin.mojom.AccountId account_id,
AuthDisabledData auth_disabled_data);
- // Called when focus is reported to be leaving a lock screen app window.
- // Requests focus to be handed off to the next suitable widget.
- // |reverse|: Whether the tab order is reversed.
- HandleFocusLeavingLockScreenApps(bool reverse);
-
// Called when new system information is available.
// |show_if_hidden|: If true, the system information should be displayed to
// the user if it is currently hidden. If false, the system
@@ -182,11 +138,6 @@
// Display a toast describing the latest kiosk app launch error.
ShowKioskAppError(string message);
- // Called when the dialog hosting oobe has changed state. The oobe dialog
- // provides support for any part of login that is implemented in JS/HTML, such
- // as add user or powerwash.
- NotifyOobeDialogState(OobeDialogState state);
-
// Sets whether users can be added from the login screen.
SetAddUserButtonEnabled(bool enable);
diff --git a/ash/shelf/login_shelf_view.cc b/ash/shelf/login_shelf_view.cc
index 9239cf1..bc90117 100644
--- a/ash/shelf/login_shelf_view.cc
+++ b/ash/shelf/login_shelf_view.cc
@@ -380,11 +380,7 @@
LoginShelfView::LoginShelfView(
LockScreenActionBackgroundController* lock_screen_action_background)
- : lock_screen_action_background_(lock_screen_action_background),
- tray_action_observer_(this),
- lock_screen_action_background_observer_(this),
- shutdown_controller_observer_(this),
- login_screen_controller_observer_(this) {
+ : lock_screen_action_background_(lock_screen_action_background) {
// We reuse the focusable state on this view as a signal that focus should
// switch to the lock screen or status area. This view should otherwise not
// be focusable.
@@ -418,9 +414,9 @@
tray_action_observer_.Add(Shell::Get()->tray_action());
shutdown_controller_observer_.Add(Shell::Get()->shutdown_controller());
lock_screen_action_background_observer_.Add(lock_screen_action_background);
- login_screen_controller_observer_.Add(
- Shell::Get()->login_screen_controller());
locale_change_observer_.Add(Shell::Get()->locale_update_controller());
+ login_data_dispatcher_observer_.Add(
+ Shell::Get()->login_screen_controller()->data_dispatcher());
UpdateUi();
}
@@ -543,7 +539,7 @@
UpdateUi();
}
-void LoginShelfView::SetLoginDialogState(mojom::OobeDialogState state) {
+void LoginShelfView::SetLoginDialogState(OobeDialogState state) {
dialog_state_ = state;
UpdateUi();
}
@@ -585,15 +581,15 @@
UpdateUi();
}
-void LoginShelfView::OnOobeDialogStateChanged(mojom::OobeDialogState state) {
- SetLoginDialogState(state);
-}
-
void LoginShelfView::OnUsersChanged(const std::vector<LoginUserInfo>& users) {
login_screen_has_users_ = !users.empty();
UpdateUi();
}
+void LoginShelfView::OnOobeDialogStateChanged(OobeDialogState state) {
+ SetLoginDialogState(state);
+}
+
void LoginShelfView::OnLocaleChanged() {
for (views::View* child : children()) {
if (child->GetClassName() == kLoginShelfButtonClassName) {
@@ -653,7 +649,7 @@
GetViewByID(kParentAccess)->SetVisible(is_locked && show_parent_access_);
bool is_login_primary = (session_state == SessionState::LOGIN_PRIMARY);
- bool dialog_visible = dialog_state_ != mojom::OobeDialogState::HIDDEN;
+ bool dialog_visible = dialog_state_ != OobeDialogState::HIDDEN;
bool is_oobe = (session_state == SessionState::OOBE);
bool user_session_started =
@@ -671,14 +667,13 @@
// 5. No users sessions have started. Button is hidden from all post login
// screens like sync consent, etc.
GetViewByID(kBrowseAsGuest)
- ->SetVisible(
- (is_login_primary || (is_oobe && allow_guest_in_oobe_)) &&
- allow_guest_ &&
- dialog_state_ != mojom::OobeDialogState::WRONG_HWID_WARNING &&
- dialog_state_ != mojom::OobeDialogState::SAML_PASSWORD_CONFIRM &&
- (dialog_state_ != mojom::OobeDialogState::GAIA_SIGNIN ||
- !login_screen_has_users_) &&
- !user_session_started);
+ ->SetVisible((is_login_primary || (is_oobe && allow_guest_in_oobe_)) &&
+ allow_guest_ &&
+ dialog_state_ != OobeDialogState::WRONG_HWID_WARNING &&
+ dialog_state_ != OobeDialogState::SAML_PASSWORD_CONFIRM &&
+ (dialog_state_ != OobeDialogState::GAIA_SIGNIN ||
+ !login_screen_has_users_) &&
+ !user_session_started);
// Show add user button when it's in login screen and Oobe UI dialog is not
// visible. The button should not appear if the device is not connected to a
@@ -690,8 +685,7 @@
// 3. Oobe UI dialog is not visible or is currently showing gaia signin
// screen.
kiosk_apps_button_->SetVisible(
- (!dialog_visible ||
- dialog_state_ == mojom::OobeDialogState::GAIA_SIGNIN) &&
+ (!dialog_visible || dialog_state_ == OobeDialogState::GAIA_SIGNIN) &&
kiosk_apps_button_->HasApps() && (is_login_primary || is_oobe));
UpdateButtonColors(is_oobe);
diff --git a/ash/shelf/login_shelf_view.h b/ash/shelf/login_shelf_view.h
index bb992d5..56215e63 100644
--- a/ash/shelf/login_shelf_view.h
+++ b/ash/shelf/login_shelf_view.h
@@ -11,9 +11,9 @@
#include "ash/ash_export.h"
#include "ash/lock_screen_action/lock_screen_action_background_observer.h"
-#include "ash/login/login_screen_controller_observer.h"
#include "ash/login/ui/login_data_dispatcher.h"
#include "ash/public/cpp/kiosk_app_menu.h"
+#include "ash/public/cpp/login_types.h"
#include "ash/public/interfaces/login_screen.mojom.h"
#include "ash/shutdown_controller.h"
#include "ash/system/locale/locale_update_controller.h"
@@ -34,22 +34,17 @@
class LockScreenActionBackgroundController;
enum class LockScreenActionBackgroundState;
-class LoginScreenController;
class TrayAction;
class KioskAppsButton;
// LoginShelfView contains the shelf buttons visible outside of an active user
// session. ShelfView and LoginShelfView should never be shown together.
-// This view is attached as a LoginDataDispatcher::Observer when the
-// LockScreen is instantiated in kLogin mode. It cannot attach itself because it
-// does not know when the Login is instantiated.
class ASH_EXPORT LoginShelfView : public views::View,
public views::ButtonListener,
public TrayActionObserver,
public LockScreenActionBackgroundObserver,
public ShutdownController::Observer,
- public LoginScreenControllerObserver,
public LoginDataDispatcher::Observer,
public LocaleChangeObserver {
public:
@@ -88,7 +83,7 @@
launch_app);
// Sets the state of the login dialog.
- void SetLoginDialogState(mojom::OobeDialogState state);
+ void SetLoginDialogState(OobeDialogState state);
// Sets if the guest button on the login shelf can be shown. Even if set to
// true the button may still not be visible.
@@ -143,11 +138,9 @@
// ShutdownController::Observer:
void OnShutdownPolicyChanged(bool reboot_on_shutdown) override;
- // LoginScreenControllerObserver:
- void OnOobeDialogStateChanged(mojom::OobeDialogState state) override;
-
// LoginDataDispatcher::Observer:
void OnUsersChanged(const std::vector<LoginUserInfo>& users) override;
+ void OnOobeDialogStateChanged(OobeDialogState state) override;
// LocaleChangeObserver:
void OnLocaleChanged() override;
@@ -166,7 +159,7 @@
// Updates the total bounds of all buttons.
void UpdateButtonUnionBounds();
- mojom::OobeDialogState dialog_state_ = mojom::OobeDialogState::HIDDEN;
+ OobeDialogState dialog_state_ = OobeDialogState::HIDDEN;
bool allow_guest_ = true;
bool allow_guest_in_oobe_ = false;
bool show_parent_access_ = false;
@@ -176,21 +169,21 @@
LockScreenActionBackgroundController* lock_screen_action_background_;
- ScopedObserver<TrayAction, TrayActionObserver> tray_action_observer_;
+ ScopedObserver<TrayAction, TrayActionObserver> tray_action_observer_{this};
ScopedObserver<LockScreenActionBackgroundController,
LockScreenActionBackgroundObserver>
- lock_screen_action_background_observer_;
+ lock_screen_action_background_observer_{this};
ScopedObserver<ShutdownController, ShutdownController::Observer>
- shutdown_controller_observer_;
-
- ScopedObserver<LoginScreenController, LoginScreenControllerObserver>
- login_screen_controller_observer_;
+ shutdown_controller_observer_{this};
ScopedObserver<LocaleUpdateController, LocaleChangeObserver>
locale_change_observer_{this};
+ ScopedObserver<LoginDataDispatcher, LoginDataDispatcher::Observer>
+ login_data_dispatcher_observer_{this};
+
// The kiosk app button will only be created for the primary display's login
// shelf.
KioskAppsButton* kiosk_apps_button_ = nullptr;
diff --git a/ash/shelf/login_shelf_view_unittest.cc b/ash/shelf/login_shelf_view_unittest.cc
index 568af4c..404ad1c 100644
--- a/ash/shelf/login_shelf_view_unittest.cc
+++ b/ash/shelf/login_shelf_view_unittest.cc
@@ -297,7 +297,7 @@
// However, SetAllowLoginAsGuest(true) does not mean that the guest button is
// always visible.
login_shelf_view_->SetLoginDialogState(
- mojom::OobeDialogState::SAML_PASSWORD_CONFIRM);
+ OobeDialogState::SAML_PASSWORD_CONFIRM);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown}));
}
@@ -315,29 +315,28 @@
// Add user button is always hidden if dialog state !=
// OobeDialogState::HIDDEN.
- login_shelf_view_->SetLoginDialogState(mojom::OobeDialogState::GAIA_SIGNIN);
+ login_shelf_view_->SetLoginDialogState(OobeDialogState::GAIA_SIGNIN);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown}));
// Guest button is hidden if dialog state ==
// OobeDialogState::WRONG_HWID_WARNING or SAML_PASSWORD_CONFIRM.
- login_shelf_view_->SetLoginDialogState(mojom::OobeDialogState::HIDDEN);
+ login_shelf_view_->SetLoginDialogState(OobeDialogState::HIDDEN);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown,
LoginShelfView::kBrowseAsGuest,
LoginShelfView::kAddUser}));
- login_shelf_view_->SetLoginDialogState(
- mojom::OobeDialogState::WRONG_HWID_WARNING);
+ login_shelf_view_->SetLoginDialogState(OobeDialogState::WRONG_HWID_WARNING);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown}));
- login_shelf_view_->SetLoginDialogState(mojom::OobeDialogState::HIDDEN);
+ login_shelf_view_->SetLoginDialogState(OobeDialogState::HIDDEN);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown,
LoginShelfView::kBrowseAsGuest,
LoginShelfView::kAddUser}));
login_shelf_view_->SetLoginDialogState(
- mojom::OobeDialogState::SAML_PASSWORD_CONFIRM);
+ OobeDialogState::SAML_PASSWORD_CONFIRM);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown}));
// By default guest login during gaia is not allowed.
- login_shelf_view_->SetLoginDialogState(mojom::OobeDialogState::GAIA_SIGNIN);
+ login_shelf_view_->SetLoginDialogState(OobeDialogState::GAIA_SIGNIN);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown}));
// Guest button is hidden if SetAllowLoginAsGuest(false).
@@ -346,17 +345,17 @@
// Kiosk app button is visible when dialog state == OobeDialogState::HIDDEN
// or GAIA_SIGNIN.
- login_shelf_view_->SetLoginDialogState(mojom::OobeDialogState::GAIA_SIGNIN);
+ login_shelf_view_->SetLoginDialogState(OobeDialogState::GAIA_SIGNIN);
std::vector<KioskAppMenuEntry> kiosk_apps(1);
login_shelf_view_->SetKioskApps(kiosk_apps, {});
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kApps}));
login_shelf_view_->SetLoginDialogState(
- mojom::OobeDialogState::SAML_PASSWORD_CONFIRM);
+ OobeDialogState::SAML_PASSWORD_CONFIRM);
EXPECT_TRUE(ShowsShelfButtons({LoginShelfView::kShutdown}));
- login_shelf_view_->SetLoginDialogState(mojom::OobeDialogState::HIDDEN);
+ login_shelf_view_->SetLoginDialogState(OobeDialogState::HIDDEN);
EXPECT_TRUE(
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kAddUser,
LoginShelfView::kApps}));
@@ -375,7 +374,7 @@
NotifySessionStateChanged(SessionState::LOGIN_PRIMARY);
// When no user pods are visible, the Gaia dialog would normally pop up. We
// need to simulate that behavior in this test.
- login_shelf_view_->SetLoginDialogState(mojom::OobeDialogState::GAIA_SIGNIN);
+ login_shelf_view_->SetLoginDialogState(OobeDialogState::GAIA_SIGNIN);
EXPECT_TRUE(ShowsShelfButtons(
{LoginShelfView::kShutdown, LoginShelfView::kBrowseAsGuest}));
}
diff --git a/chrome/browser/chromeos/login/lock/views_screen_locker.cc b/chrome/browser/chromeos/login/lock/views_screen_locker.cc
index c5199b6..95bb14c 100644
--- a/chrome/browser/chromeos/login/lock/views_screen_locker.cc
+++ b/chrome/browser/chromeos/login/lock/views_screen_locker.cc
@@ -291,7 +291,7 @@
}
void ViewsScreenLocker::HandleLockScreenAppFocusOut(bool reverse) {
- LoginScreenClient::Get()->login_screen()->HandleFocusLeavingLockScreenApps(
+ ash::LoginScreen::Get()->GetModel()->HandleFocusLeavingLockScreenApps(
reverse);
}
diff --git a/chrome/browser/chromeos/login/ui/fake_login_display_host.cc b/chrome/browser/chromeos/login/ui/fake_login_display_host.cc
index be8e47a..813d625b 100644
--- a/chrome/browser/chromeos/login/ui/fake_login_display_host.cc
+++ b/chrome/browser/chromeos/login/ui/fake_login_display_host.cc
@@ -120,8 +120,7 @@
void FakeLoginDisplayHost::UpdateOobeDialogSize(int width, int height) {}
-void FakeLoginDisplayHost::UpdateOobeDialogState(
- ash::mojom::OobeDialogState state) {}
+void FakeLoginDisplayHost::UpdateOobeDialogState(ash::OobeDialogState state) {}
const user_manager::UserList FakeLoginDisplayHost::GetUsers() {
return user_manager::UserList();
diff --git a/chrome/browser/chromeos/login/ui/fake_login_display_host.h b/chrome/browser/chromeos/login/ui/fake_login_display_host.h
index 916d9a42..80fc4e1 100644
--- a/chrome/browser/chromeos/login/ui/fake_login_display_host.h
+++ b/chrome/browser/chromeos/login/ui/fake_login_display_host.h
@@ -58,7 +58,7 @@
const base::Optional<AccountId>& prefilled_account) override;
void HideOobeDialog() override;
void UpdateOobeDialogSize(int width, int height) override;
- void UpdateOobeDialogState(ash::mojom::OobeDialogState state) override;
+ void UpdateOobeDialogState(ash::OobeDialogState state) override;
const user_manager::UserList GetUsers() override;
void CancelPasswordChangedFlow() override;
void MigrateUserData(const std::string& old_password) override;
diff --git a/chrome/browser/chromeos/login/ui/login_display_host.h b/chrome/browser/chromeos/login/ui/login_display_host.h
index 4acb3660..03b7f6b 100644
--- a/chrome/browser/chromeos/login/ui/login_display_host.h
+++ b/chrome/browser/chromeos/login/ui/login_display_host.h
@@ -8,7 +8,6 @@
#include <memory>
#include <string>
-#include "ash/public/interfaces/login_screen.mojom.h"
#include "base/callback_forward.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
@@ -20,6 +19,10 @@
class AccountId;
+namespace ash {
+enum class OobeDialogState;
+}
+
namespace content {
class WebContents;
}
@@ -142,7 +145,7 @@
virtual void UpdateOobeDialogSize(int width, int height) = 0;
// Update the state of the oobe dialog.
- virtual void UpdateOobeDialogState(ash::mojom::OobeDialogState state) = 0;
+ virtual void UpdateOobeDialogState(ash::OobeDialogState state) = 0;
// Get users that are visible in the login screen UI.
// This is mainly used by views login screen. WebUI login screen will
diff --git a/chrome/browser/chromeos/login/ui/login_display_host_mojo.cc b/chrome/browser/chromeos/login/ui/login_display_host_mojo.cc
index 3757b98..b6582ac 100644
--- a/chrome/browser/chromeos/login/ui/login_display_host_mojo.cc
+++ b/chrome/browser/chromeos/login/ui/login_display_host_mojo.cc
@@ -268,8 +268,7 @@
dialog_->UpdateSizeAndPosition(width, height);
}
-void LoginDisplayHostMojo::UpdateOobeDialogState(
- ash::mojom::OobeDialogState state) {
+void LoginDisplayHostMojo::UpdateOobeDialogState(ash::OobeDialogState state) {
if (dialog_)
dialog_->SetState(state);
}
diff --git a/chrome/browser/chromeos/login/ui/login_display_host_mojo.h b/chrome/browser/chromeos/login/ui/login_display_host_mojo.h
index ed55109..899b3fc 100644
--- a/chrome/browser/chromeos/login/ui/login_display_host_mojo.h
+++ b/chrome/browser/chromeos/login/ui/login_display_host_mojo.h
@@ -83,7 +83,7 @@
const base::Optional<AccountId>& prefilled_account) override;
void HideOobeDialog() override;
void UpdateOobeDialogSize(int width, int height) override;
- void UpdateOobeDialogState(ash::mojom::OobeDialogState state) override;
+ void UpdateOobeDialogState(ash::OobeDialogState state) override;
const user_manager::UserList GetUsers() override;
void OnCancelPasswordChangedFlow() override;
void ShowFeedback() override;
diff --git a/chrome/browser/chromeos/login/ui/login_display_host_webui.cc b/chrome/browser/chromeos/login/ui/login_display_host_webui.cc
index dc531bb..d0a4313 100644
--- a/chrome/browser/chromeos/login/ui/login_display_host_webui.cc
+++ b/chrome/browser/chromeos/login/ui/login_display_host_webui.cc
@@ -1096,8 +1096,7 @@
NOTREACHED();
}
-void LoginDisplayHostWebUI::UpdateOobeDialogState(
- ash::mojom::OobeDialogState state) {
+void LoginDisplayHostWebUI::UpdateOobeDialogState(ash::OobeDialogState state) {
NOTREACHED();
}
diff --git a/chrome/browser/chromeos/login/ui/login_display_host_webui.h b/chrome/browser/chromeos/login/ui/login_display_host_webui.h
index 9af129f..55f8f55 100644
--- a/chrome/browser/chromeos/login/ui/login_display_host_webui.h
+++ b/chrome/browser/chromeos/login/ui/login_display_host_webui.h
@@ -81,7 +81,7 @@
const base::Optional<AccountId>& prefilled_account) override;
void HideOobeDialog() override;
void UpdateOobeDialogSize(int width, int height) override;
- void UpdateOobeDialogState(ash::mojom::OobeDialogState state) override;
+ void UpdateOobeDialogState(ash::OobeDialogState state) override;
const user_manager::UserList GetUsers() override;
void ShowFeedback() override;
void ShowResetScreen() override;
diff --git a/chrome/browser/chromeos/login/ui/mock_login_display_host.h b/chrome/browser/chromeos/login/ui/mock_login_display_host.h
index 67edff2..bf2c2cd 100644
--- a/chrome/browser/chromeos/login/ui/mock_login_display_host.h
+++ b/chrome/browser/chromeos/login/ui/mock_login_display_host.h
@@ -56,7 +56,7 @@
const base::Optional<AccountId>& prefilled_account));
MOCK_METHOD0(HideOobeDialog, void());
MOCK_METHOD2(UpdateOobeDialogSize, void(int width, int height));
- MOCK_METHOD1(UpdateOobeDialogState, void(ash::mojom::OobeDialogState state));
+ MOCK_METHOD1(UpdateOobeDialogState, void(ash::OobeDialogState state));
MOCK_METHOD0(GetUsers, const user_manager::UserList(void));
MOCK_METHOD1(CompleteLogin, void(const UserContext&));
diff --git a/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.cc b/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.cc
index 421708a..b9c61b26 100644
--- a/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.cc
+++ b/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.cc
@@ -8,6 +8,8 @@
#include <utility>
#include <vector>
+#include "ash/public/cpp/login_screen.h"
+#include "ash/public/cpp/login_screen_model.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_mojo.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
@@ -268,7 +270,7 @@
void OobeUIDialogDelegate::Show() {
dialog_widget_->Show();
- SetState(ash::mojom::OobeDialogState::GAIA_SIGNIN);
+ SetState(ash::OobeDialogState::GAIA_SIGNIN);
if (should_display_captive_portal_)
GetOobeUI()->GetErrorScreen()->FixCaptivePortal();
@@ -288,7 +290,7 @@
if (!dialog_widget_)
return;
dialog_widget_->Hide();
- SetState(ash::mojom::OobeDialogState::HIDDEN);
+ SetState(ash::OobeDialogState::HIDDEN);
}
void OobeUIDialogDelegate::Close() {
@@ -300,19 +302,17 @@
dialog_widget_->Close();
}
-void OobeUIDialogDelegate::SetState(ash::mojom::OobeDialogState state) {
+void OobeUIDialogDelegate::SetState(ash::OobeDialogState state) {
if (!dialog_widget_ || state_ == state)
return;
- // Gaia WebUI is preloaded, so it's possible that WebUI send certain state
+ // Gaia WebUI is preloaded, so it's possible for WebUI to send state updates
// while the widget is not visible. Defer the state update until Show().
- if (!dialog_widget_->IsVisible() &&
- state != ash::mojom::OobeDialogState::HIDDEN) {
+ if (!dialog_widget_->IsVisible() && state != ash::OobeDialogState::HIDDEN)
return;
- }
state_ = state;
- LoginScreenClient::Get()->login_screen()->NotifyOobeDialogState(state_);
+ ash::LoginScreen::Get()->GetModel()->NotifyOobeDialogState(state_);
}
void OobeUIDialogDelegate::UpdateSizeAndPosition(int width, int height) {
diff --git a/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.h b/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.h
index 50c1319..a529c82 100644
--- a/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.h
+++ b/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.h
@@ -7,6 +7,7 @@
#include <string>
+#include "ash/public/cpp/login_types.h"
#include "ash/public/interfaces/login_screen.mojom.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
@@ -78,7 +79,7 @@
bool IsVisible();
// Update the oobe state of the dialog.
- void SetState(ash::mojom::OobeDialogState state);
+ void SetState(ash::OobeDialogState state);
// Tell the dialog whether to call FixCaptivePortal next time it is shown.
void SetShouldDisplayCaptivePortal(bool should_display);
@@ -144,7 +145,7 @@
captive_portal_observer_{this};
std::map<ui::Accelerator, std::string> accel_map_;
- ash::mojom::OobeDialogState state_ = ash::mojom::OobeDialogState::HIDDEN;
+ ash::OobeDialogState state_ = ash::OobeDialogState::HIDDEN;
// Whether the captive portal screen should be shown the next time the Gaia
// dialog is opened.
diff --git a/chrome/browser/ui/ash/login_screen_client.cc b/chrome/browser/ui/ash/login_screen_client.cc
index 36b2572..a53d5d90 100644
--- a/chrome/browser/ui/ash/login_screen_client.cc
+++ b/chrome/browser/ui/ash/login_screen_client.cc
@@ -168,8 +168,10 @@
// If delegate is not set, or it fails to handle focus request, call
// |HandleFocusLeavingLockScreenApps| so the lock screen mojo service can
// give focus to the next window in the tab order.
- if (!delegate_ || !delegate_->HandleFocusLockScreenApps(reverse))
- login_screen_->HandleFocusLeavingLockScreenApps(reverse);
+ if (!delegate_ || !delegate_->HandleFocusLockScreenApps(reverse)) {
+ ash::LoginScreen::Get()->GetModel()->HandleFocusLeavingLockScreenApps(
+ reverse);
+ }
}
void LoginScreenClient::FocusOobeDialog() {
diff --git a/chrome/browser/ui/ash/test_login_screen.cc b/chrome/browser/ui/ash/test_login_screen.cc
index e5d2289..20d0d60 100644
--- a/chrome/browser/ui/ash/test_login_screen.cc
+++ b/chrome/browser/ui/ash/test_login_screen.cc
@@ -68,8 +68,6 @@
const AccountId& account_id,
ash::mojom::AuthDisabledDataPtr auth_disabled_data) {}
-void TestLoginScreen::HandleFocusLeavingLockScreenApps(bool reverse) {}
-
void TestLoginScreen::SetSystemInfo(bool show_if_hidden,
const std::string& os_version_label_text,
const std::string& enterprise_info_text,
@@ -88,9 +86,6 @@
void TestLoginScreen::ShowKioskAppError(const std::string& message) {}
-void TestLoginScreen::NotifyOobeDialogState(ash::mojom::OobeDialogState state) {
-}
-
void TestLoginScreen::SetAddUserButtonEnabled(bool enable) {}
void TestLoginScreen::SetShutdownButtonEnabled(bool enable) {}
diff --git a/chrome/browser/ui/ash/test_login_screen.h b/chrome/browser/ui/ash/test_login_screen.h
index 6eebba8..e9995927 100644
--- a/chrome/browser/ui/ash/test_login_screen.h
+++ b/chrome/browser/ui/ash/test_login_screen.h
@@ -50,7 +50,6 @@
void DisableAuthForUser(
const AccountId& account_id,
ash::mojom::AuthDisabledDataPtr auth_disabled_data) override;
- void HandleFocusLeavingLockScreenApps(bool reverse) override;
void SetSystemInfo(bool show_if_hidden,
const std::string& os_version_label_text,
const std::string& enterprise_info_text,
@@ -61,7 +60,6 @@
void SetPublicSessionShowFullManagementDisclosure(
bool show_full_management_disclosure) override;
void ShowKioskAppError(const std::string& message) override;
- void NotifyOobeDialogState(ash::mojom::OobeDialogState state) override;
void SetAddUserButtonEnabled(bool enable) override;
void SetShutdownButtonEnabled(bool enable) override;
void SetAllowLoginAsGuest(bool allow_guest) override;
diff --git a/chrome/browser/ui/ash/test_login_screen_model.cc b/chrome/browser/ui/ash/test_login_screen_model.cc
index 3a5f6e7..df6cf8a 100644
--- a/chrome/browser/ui/ash/test_login_screen_model.cc
+++ b/chrome/browser/ui/ash/test_login_screen_model.cc
@@ -25,3 +25,5 @@
const AccountId& account_id,
const std::string& locale,
const std::vector<ash::InputMethodItem>& keyboard_layouts) {}
+void TestLoginScreenModel::HandleFocusLeavingLockScreenApps(bool reverse) {}
+void TestLoginScreenModel::NotifyOobeDialogState(ash::OobeDialogState state) {}
diff --git a/chrome/browser/ui/ash/test_login_screen_model.h b/chrome/browser/ui/ash/test_login_screen_model.h
index 1a6a5d2..a3a4730 100644
--- a/chrome/browser/ui/ash/test_login_screen_model.h
+++ b/chrome/browser/ui/ash/test_login_screen_model.h
@@ -29,6 +29,8 @@
const AccountId& account_id,
const std::string& locale,
const std::vector<ash::InputMethodItem>& keyboard_layouts) override;
+ void HandleFocusLeavingLockScreenApps(bool reverse) override;
+ void NotifyOobeDialogState(ash::OobeDialogState state) override;
private:
DISALLOW_COPY_AND_ASSIGN(TestLoginScreenModel);
diff --git a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
index 1b6912ee..59a9d6f 100644
--- a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
@@ -929,8 +929,7 @@
void GaiaScreenHandler::HandleUpdateSigninUIState(int state) {
if (LoginDisplayHost::default_host()) {
- auto dialog_state = static_cast<ash::mojom::OobeDialogState>(state);
- DCHECK(ash::mojom::IsKnownEnumValue(dialog_state));
+ auto dialog_state = static_cast<ash::OobeDialogState>(state);
LoginDisplayHost::default_host()->UpdateOobeDialogState(dialog_state);
}
}