[OOBE Cleanup] Eliminate LD::Delegate::ResetAutoLoginTimer
ResetAutoLoginTimer was called on the user activity. This CL just moves the user activity observation directly to the ExistingUserController BUG=b:275061367 Change-Id: I60de81e5f817d3a2580de52f2498661fe48b475d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4370681 Reviewed-by: Renato Silva <rrsilva@google.com> Commit-Queue: Roman Sorokin <rsorokin@google.com> Reviewed-by: Danila Kuzmin <dkuzmin@google.com> Cr-Commit-Position: refs/heads/main@{#1122283}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
859d5f51fb
commit
869030e014
ash
chrome/browser
@@ -480,13 +480,6 @@ void LoginScreenController::FocusOobeDialog() {
|
|||||||
client_->FocusOobeDialog();
|
client_->FocusOobeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginScreenController::NotifyUserActivity() {
|
|
||||||
if (!client_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
client_->OnUserActivity();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoginScreenController::OnAuthenticateComplete(
|
void LoginScreenController::OnAuthenticateComplete(
|
||||||
OnAuthenticateCallback callback,
|
OnAuthenticateCallback callback,
|
||||||
bool success) {
|
bool success) {
|
||||||
|
@@ -100,7 +100,6 @@ class ASH_EXPORT LoginScreenController : public LoginScreen,
|
|||||||
void ShowParentAccessHelpApp();
|
void ShowParentAccessHelpApp();
|
||||||
void ShowLockScreenNotificationSettings();
|
void ShowLockScreenNotificationSettings();
|
||||||
void FocusOobeDialog();
|
void FocusOobeDialog();
|
||||||
void NotifyUserActivity();
|
|
||||||
|
|
||||||
// Enable or disable authentication for the debug overlay.
|
// Enable or disable authentication for the debug overlay.
|
||||||
enum class ForceFailAuth { kOff, kImmediate, kDelayed };
|
enum class ForceFailAuth { kOff, kImmediate, kDelayed };
|
||||||
|
@@ -113,7 +113,6 @@ class MockLoginScreenClient : public LoginScreenClient {
|
|||||||
MOCK_METHOD(void, ShowLockScreenNotificationSettings, (), (override));
|
MOCK_METHOD(void, ShowLockScreenNotificationSettings, (), (override));
|
||||||
MOCK_METHOD(void, FocusOobeDialog, (), (override));
|
MOCK_METHOD(void, FocusOobeDialog, (), (override));
|
||||||
MOCK_METHOD(void, OnFocusLeavingSystemTray, (bool reverse), (override));
|
MOCK_METHOD(void, OnFocusLeavingSystemTray, (bool reverse), (override));
|
||||||
MOCK_METHOD(void, OnUserActivity, (), (override));
|
|
||||||
MOCK_METHOD(void, OnLoginScreenShown, (), (override));
|
MOCK_METHOD(void, OnLoginScreenShown, (), (override));
|
||||||
MOCK_METHOD(void, OnSystemTrayBubbleShown, (), (override));
|
MOCK_METHOD(void, OnSystemTrayBubbleShown, (), (override));
|
||||||
MOCK_METHOD(views::Widget*, GetLoginWindowWidget, (), (override));
|
MOCK_METHOD(views::Widget*, GetLoginWindowWidget, (), (override));
|
||||||
|
@@ -304,30 +304,6 @@ class UserAddingScreenIndicator : public views::View {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class LockContentsView::AutoLoginUserActivityHandler
|
|
||||||
: public ui::UserActivityObserver {
|
|
||||||
public:
|
|
||||||
AutoLoginUserActivityHandler() {
|
|
||||||
observation_.Observe(ui::UserActivityDetector::Get());
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoLoginUserActivityHandler(const AutoLoginUserActivityHandler&) = delete;
|
|
||||||
AutoLoginUserActivityHandler& operator=(const AutoLoginUserActivityHandler&) =
|
|
||||||
delete;
|
|
||||||
|
|
||||||
~AutoLoginUserActivityHandler() override = default;
|
|
||||||
|
|
||||||
void OnUserActivity(const ui::Event* event) override {
|
|
||||||
if (Shell::Get()->login_screen_controller()) {
|
|
||||||
Shell::Get()->login_screen_controller()->NotifyUserActivity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
base::ScopedObservation<ui::UserActivityDetector, ui::UserActivityObserver>
|
|
||||||
observation_{this};
|
|
||||||
};
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
const int LockContentsView::kLoginAttemptsBeforeGaiaDialog = 4;
|
const int LockContentsView::kLoginAttemptsBeforeGaiaDialog = 4;
|
||||||
|
|
||||||
@@ -340,11 +316,6 @@ LockContentsView::LockContentsView(
|
|||||||
screen_type_(screen_type),
|
screen_type_(screen_type),
|
||||||
data_dispatcher_(data_dispatcher),
|
data_dispatcher_(data_dispatcher),
|
||||||
detachable_base_model_(std::move(detachable_base_model)) {
|
detachable_base_model_(std::move(detachable_base_model)) {
|
||||||
if (screen_type == LockScreen::ScreenType::kLogin) {
|
|
||||||
auto_login_user_activity_handler_ =
|
|
||||||
std::make_unique<AutoLoginUserActivityHandler>();
|
|
||||||
}
|
|
||||||
|
|
||||||
data_dispatcher_->AddObserver(this);
|
data_dispatcher_->AddObserver(this);
|
||||||
Shell::Get()->system_tray_notifier()->AddSystemTrayObserver(this);
|
Shell::Get()->system_tray_notifier()->AddSystemTrayObserver(this);
|
||||||
keyboard::KeyboardUIController::Get()->AddObserver(this);
|
keyboard::KeyboardUIController::Get()->AddObserver(this);
|
||||||
|
@@ -236,8 +236,6 @@ class ASH_EXPORT LockContentsView
|
|||||||
bool AreMediaControlsEnabled() const;
|
bool AreMediaControlsEnabled() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class AutoLoginUserActivityHandler;
|
|
||||||
|
|
||||||
using DisplayLayoutAction = base::RepeatingCallback<void(bool landscape)>;
|
using DisplayLayoutAction = base::RepeatingCallback<void(bool landscape)>;
|
||||||
|
|
||||||
// Focus the next/previous widget.
|
// Focus the next/previous widget.
|
||||||
@@ -536,11 +534,6 @@ class ASH_EXPORT LockContentsView
|
|||||||
// Accelerators handled by login screen.
|
// Accelerators handled by login screen.
|
||||||
std::map<ui::Accelerator, LoginAcceleratorAction> accel_map_;
|
std::map<ui::Accelerator, LoginAcceleratorAction> accel_map_;
|
||||||
|
|
||||||
// Notifies Chrome when user activity is detected on the login screen so that
|
|
||||||
// the auto-login timer can be reset.
|
|
||||||
std::unique_ptr<AutoLoginUserActivityHandler>
|
|
||||||
auto_login_user_activity_handler_;
|
|
||||||
|
|
||||||
BottomIndicatorState bottom_status_indicator_state_ =
|
BottomIndicatorState bottom_status_indicator_state_ =
|
||||||
BottomIndicatorState::kNone;
|
BottomIndicatorState::kNone;
|
||||||
|
|
||||||
|
@@ -162,9 +162,6 @@ class ASH_PUBLIC_EXPORT LoginScreenClient {
|
|||||||
// Called when the lock screen is shown.
|
// Called when the lock screen is shown.
|
||||||
virtual void OnLoginScreenShown() = 0;
|
virtual void OnLoginScreenShown() = 0;
|
||||||
|
|
||||||
// Used by Ash to signal that user activity occurred on the login screen.
|
|
||||||
virtual void OnUserActivity() = 0;
|
|
||||||
|
|
||||||
// Get login screen widget. Currently used to set proper accessibility
|
// Get login screen widget. Currently used to set proper accessibility
|
||||||
// navigation.
|
// navigation.
|
||||||
virtual views::Widget* GetLoginWindowWidget() = 0;
|
virtual views::Widget* GetLoginWindowWidget() = 0;
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include "ash/public/cpp/login_screen.h"
|
#include "ash/public/cpp/login_screen.h"
|
||||||
#include "ash/public/cpp/notification_utils.h"
|
#include "ash/public/cpp/notification_utils.h"
|
||||||
#include "base/barrier_closure.h"
|
#include "base/barrier_closure.h"
|
||||||
|
#include "base/check_is_test.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/functional/bind.h"
|
#include "base/functional/bind.h"
|
||||||
@@ -127,6 +128,8 @@
|
|||||||
#include "services/network/public/mojom/network_context.mojom.h"
|
#include "services/network/public/mojom/network_context.mojom.h"
|
||||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
#include "ui/base/user_activity/user_activity_detector.h"
|
||||||
|
#include "ui/base/user_activity/user_activity_observer.h"
|
||||||
#include "ui/message_center/public/cpp/notification.h"
|
#include "ui/message_center/public/cpp/notification.h"
|
||||||
#include "ui/message_center/public/cpp/notification_delegate.h"
|
#include "ui/message_center/public/cpp/notification_delegate.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
@@ -383,6 +386,12 @@ ExistingUserController::ExistingUserController()
|
|||||||
base::Unretained(this)));
|
base::Unretained(this)));
|
||||||
|
|
||||||
observed_user_manager_.Observe(user_manager::UserManager::Get());
|
observed_user_manager_.Observe(user_manager::UserManager::Get());
|
||||||
|
|
||||||
|
if (ui::UserActivityDetector::Get()) {
|
||||||
|
ui::UserActivityDetector::Get()->AddObserver(this);
|
||||||
|
} else {
|
||||||
|
CHECK_IS_TEST();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExistingUserController::Init(const user_manager::UserList& users) {
|
void ExistingUserController::Init(const user_manager::UserList& users) {
|
||||||
@@ -495,7 +504,12 @@ void ExistingUserController::Observe(
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ExistingUserController, private:
|
// ExistingUserController, private:
|
||||||
|
|
||||||
ExistingUserController::~ExistingUserController() = default;
|
ExistingUserController::~ExistingUserController() {
|
||||||
|
ui::UserActivityDetector* activity_detector = ui::UserActivityDetector::Get();
|
||||||
|
if (activity_detector) {
|
||||||
|
activity_detector->RemoveObserver(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ExistingUserController, LoginDisplay::Delegate implementation:
|
// ExistingUserController, LoginDisplay::Delegate implementation:
|
||||||
@@ -1352,7 +1366,7 @@ void ExistingUserController::ConfigureAutoLogin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExistingUserController::ResetAutoLoginTimer() {
|
void ExistingUserController::OnUserActivity(const ui::Event* event) {
|
||||||
// Only restart the auto-login timer if it's already running.
|
// Only restart the auto-login timer if it's already running.
|
||||||
if (auto_login_timer_ && auto_login_timer_->IsRunning()) {
|
if (auto_login_timer_ && auto_login_timer_->IsRunning()) {
|
||||||
StopAutoLoginTimer();
|
StopAutoLoginTimer();
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "content/public/browser/notification_registrar.h"
|
#include "content/public/browser/notification_registrar.h"
|
||||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||||
#include "third_party/cros_system_api/dbus/cryptohome/dbus-constants.h"
|
#include "third_party/cros_system_api/dbus/cryptohome/dbus-constants.h"
|
||||||
|
#include "ui/base/user_activity/user_activity_observer.h"
|
||||||
#include "url/gurl.h"
|
#include "url/gurl.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
@@ -58,7 +59,8 @@ class ExistingUserController : public LoginDisplay::Delegate,
|
|||||||
public content::NotificationObserver,
|
public content::NotificationObserver,
|
||||||
public LoginPerformer::Delegate,
|
public LoginPerformer::Delegate,
|
||||||
public UserSessionManagerDelegate,
|
public UserSessionManagerDelegate,
|
||||||
public user_manager::UserManager::Observer {
|
public user_manager::UserManager::Observer,
|
||||||
|
public ui::UserActivityObserver {
|
||||||
public:
|
public:
|
||||||
// Returns the current existing user controller fetched from the current
|
// Returns the current existing user controller fetched from the current
|
||||||
// LoginDisplayHost instance.
|
// LoginDisplayHost instance.
|
||||||
@@ -99,7 +101,9 @@ class ExistingUserController : public LoginDisplay::Delegate,
|
|||||||
void Login(const UserContext& user_context,
|
void Login(const UserContext& user_context,
|
||||||
const SigninSpecifics& specifics) override;
|
const SigninSpecifics& specifics) override;
|
||||||
void OnStartKioskEnableScreen() override;
|
void OnStartKioskEnableScreen() override;
|
||||||
void ResetAutoLoginTimer() override;
|
|
||||||
|
// ui::UserActivityObserver:
|
||||||
|
void OnUserActivity(const ui::Event* event) override;
|
||||||
|
|
||||||
void CompleteLogin(const UserContext& user_context);
|
void CompleteLogin(const UserContext& user_context);
|
||||||
void OnGaiaScreenReady();
|
void OnGaiaScreenReady();
|
||||||
|
@@ -202,7 +202,7 @@ TEST_F(ExistingUserControllerAutoLoginTest, ResetAutoLoginTimer) {
|
|||||||
EXPECT_FALSE(auto_login_timer());
|
EXPECT_FALSE(auto_login_timer());
|
||||||
|
|
||||||
// When the timer isn't running, nothing should happen.
|
// When the timer isn't running, nothing should happen.
|
||||||
existing_user_controller()->ResetAutoLoginTimer();
|
existing_user_controller()->OnUserActivity(/*event=*/nullptr);
|
||||||
EXPECT_FALSE(auto_login_timer());
|
EXPECT_FALSE(auto_login_timer());
|
||||||
|
|
||||||
// Start the timer.
|
// Start the timer.
|
||||||
@@ -216,7 +216,7 @@ TEST_F(ExistingUserControllerAutoLoginTest, ResetAutoLoginTimer) {
|
|||||||
// User activity should restart the timer, so check to see that the
|
// User activity should restart the timer, so check to see that the
|
||||||
// timer delay was modified.
|
// timer delay was modified.
|
||||||
set_auto_login_delay(kAutoLoginDelay1);
|
set_auto_login_delay(kAutoLoginDelay1);
|
||||||
existing_user_controller()->ResetAutoLoginTimer();
|
existing_user_controller()->OnUserActivity(/*event=*/nullptr);
|
||||||
ASSERT_TRUE(auto_login_timer());
|
ASSERT_TRUE(auto_login_timer());
|
||||||
EXPECT_TRUE(auto_login_timer()->IsRunning());
|
EXPECT_TRUE(auto_login_timer()->IsRunning());
|
||||||
EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(),
|
EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(),
|
||||||
|
@@ -26,9 +26,6 @@ class LoginDisplay {
|
|||||||
// Called when the user requests kiosk enable screen.
|
// Called when the user requests kiosk enable screen.
|
||||||
virtual void OnStartKioskEnableScreen() = 0;
|
virtual void OnStartKioskEnableScreen() = 0;
|
||||||
|
|
||||||
// Restarts the auto-login timer if it is running.
|
|
||||||
virtual void ResetAutoLoginTimer() = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~Delegate();
|
virtual ~Delegate();
|
||||||
};
|
};
|
||||||
|
@@ -12,28 +12,14 @@ namespace ash {
|
|||||||
|
|
||||||
// LoginDisplayWebUI, public: --------------------------------------------------
|
// LoginDisplayWebUI, public: --------------------------------------------------
|
||||||
|
|
||||||
LoginDisplayWebUI::~LoginDisplayWebUI() {
|
LoginDisplayWebUI::~LoginDisplayWebUI() = default;
|
||||||
ui::UserActivityDetector* activity_detector = ui::UserActivityDetector::Get();
|
|
||||||
if (activity_detector && activity_detector->HasObserver(this))
|
|
||||||
activity_detector->RemoveObserver(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoginDisplay implementation: ------------------------------------------------
|
// LoginDisplay implementation: ------------------------------------------------
|
||||||
|
|
||||||
LoginDisplayWebUI::LoginDisplayWebUI() = default;
|
LoginDisplayWebUI::LoginDisplayWebUI() = default;
|
||||||
|
|
||||||
void LoginDisplayWebUI::Init(const user_manager::UserList& users,
|
void LoginDisplayWebUI::Init(const user_manager::UserList& users,
|
||||||
bool show_guest) {
|
bool show_guest) {}
|
||||||
ui::UserActivityDetector* activity_detector = ui::UserActivityDetector::Get();
|
|
||||||
if (activity_detector && !activity_detector->HasObserver(this))
|
|
||||||
activity_detector->AddObserver(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- Common methods
|
|
||||||
|
|
||||||
// ---- Gaia screen methods
|
|
||||||
|
|
||||||
// ---- Not yet classified methods
|
|
||||||
|
|
||||||
void LoginDisplayWebUI::SetUIEnabled(bool is_enabled) {
|
void LoginDisplayWebUI::SetUIEnabled(bool is_enabled) {
|
||||||
LoginDisplayHost* host = LoginDisplayHost::default_host();
|
LoginDisplayHost* host = LoginDisplayHost::default_host();
|
||||||
@@ -41,9 +27,4 @@ void LoginDisplayWebUI::SetUIEnabled(bool is_enabled) {
|
|||||||
host->GetWebUILoginView()->SetUIEnabled(is_enabled);
|
host->GetWebUILoginView()->SetUIEnabled(is_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginDisplayWebUI::OnUserActivity(const ui::Event* event) {
|
|
||||||
if (delegate_)
|
|
||||||
delegate_->ResetAutoLoginTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ash
|
} // namespace ash
|
||||||
|
@@ -7,12 +7,11 @@
|
|||||||
|
|
||||||
#include "chrome/browser/ash/login/ui/login_display.h"
|
#include "chrome/browser/ash/login/ui/login_display.h"
|
||||||
#include "components/user_manager/user.h"
|
#include "components/user_manager/user.h"
|
||||||
#include "ui/base/user_activity/user_activity_observer.h"
|
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
|
|
||||||
// WebUI-based login UI implementation.
|
// WebUI-based login UI implementation.
|
||||||
class LoginDisplayWebUI : public LoginDisplay, public ui::UserActivityObserver {
|
class LoginDisplayWebUI : public LoginDisplay {
|
||||||
public:
|
public:
|
||||||
LoginDisplayWebUI();
|
LoginDisplayWebUI();
|
||||||
|
|
||||||
@@ -24,9 +23,6 @@ class LoginDisplayWebUI : public LoginDisplay, public ui::UserActivityObserver {
|
|||||||
// LoginDisplay implementation:
|
// LoginDisplay implementation:
|
||||||
void Init(const user_manager::UserList& users, bool show_guest) override;
|
void Init(const user_manager::UserList& users, bool show_guest) override;
|
||||||
void SetUIEnabled(bool is_enabled) override;
|
void SetUIEnabled(bool is_enabled) override;
|
||||||
|
|
||||||
// ui::UserActivityDetector implementation:
|
|
||||||
void OnUserActivity(const ui::Event* event) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ash
|
} // namespace ash
|
||||||
|
@@ -375,14 +375,6 @@ void LoginScreenClientImpl::SetPublicSessionKeyboardLayout(
|
|||||||
account_id, locale, result);
|
account_id, locale, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginScreenClientImpl::OnUserActivity() {
|
|
||||||
if (ash::LoginDisplayHost::default_host()) {
|
|
||||||
ash::LoginDisplayHost::default_host()
|
|
||||||
->GetExistingUserController()
|
|
||||||
->ResetAutoLoginTimer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
views::Widget* LoginScreenClientImpl::GetLoginWindowWidget() {
|
views::Widget* LoginScreenClientImpl::GetLoginWindowWidget() {
|
||||||
if (ash::LoginDisplayHost::default_host()) {
|
if (ash::LoginDisplayHost::default_host()) {
|
||||||
return ash::LoginDisplayHost::default_host()->GetLoginWindowWidget();
|
return ash::LoginDisplayHost::default_host()->GetLoginWindowWidget();
|
||||||
|
@@ -128,7 +128,6 @@ class LoginScreenClientImpl : public ash::LoginScreenClient {
|
|||||||
void OnFocusLeavingSystemTray(bool reverse) override;
|
void OnFocusLeavingSystemTray(bool reverse) override;
|
||||||
void OnSystemTrayBubbleShown() override;
|
void OnSystemTrayBubbleShown() override;
|
||||||
void OnLoginScreenShown() override;
|
void OnLoginScreenShown() override;
|
||||||
void OnUserActivity() override;
|
|
||||||
views::Widget* GetLoginWindowWidget() override;
|
views::Widget* GetLoginWindowWidget() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user