Commit 589d9942 authored by Jacob Dufault's avatar Jacob Dufault Committed by Commit Bot

cros: Refactor login_screen_controller a bit.

- Reorder class members to follow styleguide
- Move LockScreenAppsFocusObserver to LoginScreenController::Observer

I am planning on adding more methods to the observer; instead of having a
separate observer for each method it seems cleaner to have one larger observer.

Bug: 784495
Change-Id: I7de65cbc4abae26b23a11344b0a065b73032e09d
Reviewed-on: https://chromium-review.googlesource.com/978833
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546235}
parent 9437a886
......@@ -269,9 +269,10 @@ component("ash") {
"lock_screen_action/lock_screen_note_display_state_handler.h",
"lock_screen_action/lock_screen_note_launcher.cc",
"lock_screen_action/lock_screen_note_launcher.h",
"login/lock_screen_apps_focus_observer.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",
......
This diff is collapsed.
......@@ -6,6 +6,7 @@
#define ASH_LOGIN_LOGIN_SCREEN_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/login/login_screen_controller_observer.h"
#include "ash/public/interfaces/login_screen.mojom.h"
#include "base/macros.h"
#include "base/observer_list.h"
......@@ -16,7 +17,6 @@ class PrefRegistrySimple;
namespace ash {
class LockScreenAppsFocusObserver;
class LoginDataDispatcher;
// LoginScreenController implements mojom::LoginScreen and wraps the
......@@ -41,6 +41,42 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
// Binds the mojom::LoginScreen interface to this object.
void BindRequest(mojom::LoginScreenRequest request);
// Hash the password and send AuthenticateUser request to LoginScreenClient.
// LoginScreenClient (in the chrome process) will do the authentication and
// request to show error messages in the screen if auth fails, or request to
// clear errors if auth succeeds.
void AuthenticateUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin,
OnAuthenticateCallback callback);
void AttemptUnlock(const AccountId& account_id);
void HardlockPod(const AccountId& account_id);
void RecordClickOnLockIcon(const AccountId& account_id);
void OnFocusPod(const AccountId& account_id);
void OnNoPodFocused();
void LoadWallpaper(const AccountId& account_id);
void SignOutUser();
void CancelAddUser();
void LoginAsGuest();
void OnMaxIncorrectPasswordAttempted(const AccountId& account_id);
void FocusLockScreenApps(bool reverse);
void ShowGaiaSignin();
void OnRemoveUserWarningShown();
void RemoveUser(const AccountId& account_id);
void LaunchPublicSession(const AccountId& account_id,
const std::string& locale,
const std::string& input_method);
// 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) {
force_fail_auth_for_debug_overlay_ = force_fail;
}
// mojom::LoginScreen:
void SetClient(mojom::LoginScreenClientPtr client) override;
void ShowLockScreen(ShowLockScreenCallback on_shown) override;
......@@ -72,47 +108,9 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
const std::string& default_locale,
bool show_advanced_view) override;
// Hash the password and send AuthenticateUser request to LoginScreenClient.
// LoginScreenClient (in the chrome process) will do the authentication and
// request to show error messages in the screen if auth fails, or request to
// clear errors if auth succeeds.
void AuthenticateUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin,
OnAuthenticateCallback callback);
void AttemptUnlock(const AccountId& account_id);
void HardlockPod(const AccountId& account_id);
void RecordClickOnLockIcon(const AccountId& account_id);
void OnFocusPod(const AccountId& account_id);
void OnNoPodFocused();
void LoadWallpaper(const AccountId& account_id);
void SignOutUser();
void CancelAddUser();
void LoginAsGuest();
void OnMaxIncorrectPasswordAttempted(const AccountId& account_id);
void FocusLockScreenApps(bool reverse);
void ShowGaiaSignin();
void OnRemoveUserWarningShown();
void RemoveUser(const AccountId& account_id);
void LaunchPublicSession(const AccountId& account_id,
const std::string& locale,
const std::string& input_method);
// Methods to manage lock screen apps focus observers.
// The observers will be notified when lock screen apps focus changes are
// reported via lock screen mojo interface.
void AddLockScreenAppsFocusObserver(LockScreenAppsFocusObserver* observer);
void RemoveLockScreenAppsFocusObserver(LockScreenAppsFocusObserver* observer);
// Flushes the mojo pipes - to be used in tests.
void FlushForTesting();
// 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) {
force_fail_auth_for_debug_overlay_ = force_fail;
}
private:
using PendingDoAuthenticateUser =
base::OnceCallback<void(const std::string& system_salt)>;
......@@ -142,8 +140,7 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
// True iff we are currently authentication.
bool is_authenticating_ = false;
base::ObserverList<LockScreenAppsFocusObserver>
lock_screen_apps_focus_observers_;
base::ObserverList<LoginScreenControllerObserver> observers_;
// If set to false, all auth requests will forcibly fail.
ForceFailAuth force_fail_auth_for_debug_overlay_ = ForceFailAuth::kOff;
......
// 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.h"
namespace ash {
LoginScreenControllerObserver::~LoginScreenControllerObserver() = default;
} // namespace ash
// Copyright 2017 The Chromium Authors. All rights reserved.
// 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_LOCK_SCREEN_APPS_FOCUS_OBSERVER_H_
#define ASH_LOGIN_LOCK_SCREEN_APPS_FOCUS_OBSERVER_H_
#ifndef ASH_LOGIN_LOGIN_SCREEN_CONTROLLER_OBSERVER_H_
#define ASH_LOGIN_LOGIN_SCREEN_CONTROLLER_OBSERVER_H_
#include "ash/ash_export.h"
namespace ash {
// An interface used to observe lock screen apps focus related events, as
// reported through lock screen mojo interface.
class ASH_EXPORT LockScreenAppsFocusObserver {
// Interface used by LoginScreenController when some events have been received
// from another process, ie, chrome.
class ASH_EXPORT LoginScreenControllerObserver {
public:
virtual ~LockScreenAppsFocusObserver() {}
virtual ~LoginScreenControllerObserver();
// Called when focus is leaving a lock screen app window due to tabbing.
// |reverse| - whether the tab order is reversed.
......@@ -22,4 +22,4 @@ class ASH_EXPORT LockScreenAppsFocusObserver {
} // namespace ash
#endif // ASH_LOGIN_LOCK_SCREEN_APPS_FOCUS_OBSERVER_H_
#endif // ASH_LOGIN_LOGIN_SCREEN_CONTROLLER_OBSERVER_H_
......@@ -239,7 +239,7 @@ LockContentsView::LockContentsView(
keyboard_observer_(this) {
data_dispatcher_->AddObserver(this);
display_observer_.Add(display::Screen::GetScreen());
Shell::Get()->login_screen_controller()->AddLockScreenAppsFocusObserver(this);
Shell::Get()->login_screen_controller()->AddObserver(this);
Shell::Get()->system_tray_notifier()->AddSystemTrayFocusObserver(this);
auth_error_bubble_ = std::make_unique<LoginBubble>();
detachable_base_error_bubble_ = std::make_unique<LoginBubble>();
......@@ -282,8 +282,7 @@ LockContentsView::LockContentsView(
LockContentsView::~LockContentsView() {
data_dispatcher_->RemoveObserver(this);
Shell::Get()->login_screen_controller()->RemoveLockScreenAppsFocusObserver(
this);
Shell::Get()->login_screen_controller()->RemoveObserver(this);
Shell::Get()->system_tray_notifier()->RemoveSystemTrayFocusObserver(this);
if (unlock_attempt_ > 0) {
......
......@@ -10,7 +10,8 @@
#include <vector>
#include "ash/ash_export.h"
#include "ash/login/lock_screen_apps_focus_observer.h"
#include "ash/login/login_screen_controller.h"
#include "ash/login/login_screen_controller_observer.h"
#include "ash/login/ui/login_data_dispatcher.h"
#include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/non_accessible_view.h"
......@@ -55,7 +56,7 @@ enum class TrayActionState;
// but it is always shown on the primary display. There is only one instance
// at a time.
class ASH_EXPORT LockContentsView : public NonAccessibleView,
public LockScreenAppsFocusObserver,
public LoginScreenControllerObserver,
public LoginDataDispatcher::Observer,
public SystemTrayFocusObserver,
public display::DisplayObserver,
......@@ -96,7 +97,7 @@ class ASH_EXPORT LockContentsView : public NonAccessibleView,
void AboutToRequestFocusFromTabTraversal(bool reverse) override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// LockScreenAppsFocusObserver:
// LoginScreenController::Observer:
void OnFocusLeavingLockScreenApps(bool reverse) override;
// LoginDataDispatcher::Observer:
......
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