Commit c6ff3153 authored by Quan Nguyen's avatar Quan Nguyen Committed by Commit Bot

cros: Focus the primary password field when OOBE dialog goes away.

As part of this CL, a method has been added to LoginScreenControllerObserver to be notified when the OOBE dialog visibility changes.

Bug: 871186
Change-Id: I7b8d9fb7de99c16df6166c43f2eb55f56b93736e
Reviewed-on: https://chromium-review.googlesource.com/1164248Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarXiaoyin Hu <xiaoyinh@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581318}
parent e462ebf8
......@@ -415,10 +415,8 @@ void LoginScreenController::SetKioskApps(
}
void LoginScreenController::NotifyOobeDialogVisibility(bool visible) {
Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
->shelf_widget()
->login_shelf_view()
->SetLoginDialogVisible(visible);
for (auto& observer : observers_)
observer.OnOobeDialogVisibilityChanged(visible);
}
void LoginScreenController::SetAddUserButtonEnabled(bool enable) {
......
......@@ -2,10 +2,22 @@
// 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"
#include "ash/login/login_screen_controller.h"
namespace ash {
LoginScreenControllerObserver::~LoginScreenControllerObserver() = default;
void LoginScreenControllerObserver::SetAvatarForUser(
const AccountId& account_id,
const mojom::UserAvatarPtr& avatar) {}
void LoginScreenControllerObserver::OnFocusLeavingLockScreenApps(bool reverse) {
}
void LoginScreenControllerObserver::OnOobeDialogVisibilityChanged(
bool visible) {}
} // namespace ash
......@@ -20,11 +20,14 @@ class ASH_EXPORT LoginScreenControllerObserver {
// Called when |avatar| for |account_id| has changed.
virtual void SetAvatarForUser(const AccountId& account_id,
const mojom::UserAvatarPtr& avatar) = 0;
const mojom::UserAvatarPtr& avatar);
// 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) = 0;
virtual void OnFocusLeavingLockScreenApps(bool reverse);
// Called when the visibility state of the OOBE dialog is changed.
virtual void OnOobeDialogVisibilityChanged(bool visible);
};
} // namespace ash
......
......@@ -886,6 +886,11 @@ void LockContentsView::OnFocusLeavingLockScreenApps(bool reverse) {
FindFirstOrLastFocusableChild(this, reverse)->RequestFocus();
}
void LockContentsView::OnOobeDialogVisibilityChanged(bool visible) {
if (!visible && primary_big_view_)
primary_big_view_->RequestFocus();
}
void LockContentsView::OnFocusLeavingSystemTray(bool reverse) {
// This function is called when the system tray is losing focus. We want to
// focus the first or last child in this view, or a lock screen app window if
......
......@@ -135,6 +135,7 @@ class ASH_EXPORT LockContentsView
void SetAvatarForUser(const AccountId& account_id,
const mojom::UserAvatarPtr& avatar) override;
void OnFocusLeavingLockScreenApps(bool reverse) override;
void OnOobeDialogVisibilityChanged(bool visible) override;
// LoginDataDispatcher::Observer:
void OnUsersChanged(
......
......@@ -274,7 +274,8 @@ LoginShelfView::LoginShelfView(
: lock_screen_action_background_(lock_screen_action_background),
tray_action_observer_(this),
lock_screen_action_background_observer_(this),
shutdown_controller_observer_(this) {
shutdown_controller_observer_(this),
login_screen_controller_observer_(this) {
// 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.
......@@ -309,6 +310,8 @@ LoginShelfView::LoginShelfView(
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());
UpdateUi();
}
......@@ -433,6 +436,10 @@ void LoginShelfView::OnShutdownPolicyChanged(bool reboot_on_shutdown) {
UpdateUi();
}
void LoginShelfView::OnOobeDialogVisibilityChanged(bool visible) {
SetLoginDialogVisible(visible);
}
bool LoginShelfView::LockScreenActionBackgroundAnimating() const {
return lock_screen_action_background_->state() ==
LockScreenActionBackgroundState::kShowing ||
......
......@@ -9,6 +9,7 @@
#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/public/interfaces/kiosk_app_info.mojom.h"
#include "ash/shutdown_controller.h"
#include "ash/tray_action/tray_action_observer.h"
......@@ -29,6 +30,7 @@ namespace ash {
class LockScreenActionBackgroundController;
enum class LockScreenActionBackgroundState;
class TrayAction;
class LoginScreenController;
class KioskAppsButton;
......@@ -38,7 +40,8 @@ class ASH_EXPORT LoginShelfView : public views::View,
public views::ButtonListener,
public TrayActionObserver,
public LockScreenActionBackgroundObserver,
public ShutdownController::Observer {
public ShutdownController::Observer,
public LoginScreenControllerObserver {
public:
enum ButtonId {
kShutdown = 1, // Shut down the device.
......@@ -93,6 +96,9 @@ class ASH_EXPORT LoginShelfView : public views::View,
// ShutdownController::Observer:
void OnShutdownPolicyChanged(bool reboot_on_shutdown) override;
// LoginScreenControllerObserver:
void OnOobeDialogVisibilityChanged(bool visible) override;
private:
bool LockScreenActionBackgroundAnimating() const;
......@@ -114,6 +120,9 @@ class ASH_EXPORT LoginShelfView : public views::View,
ScopedObserver<ShutdownController, ShutdownController::Observer>
shutdown_controller_observer_;
ScopedObserver<LoginScreenController, LoginScreenControllerObserver>
login_screen_controller_observer_;
KioskAppsButton* kiosk_apps_button_ = nullptr; // Owned by view hierarchy
DISALLOW_COPY_AND_ASSIGN(LoginShelfView);
......
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