Commit 8db5d9a3 authored by Quan Nguyen's avatar Quan Nguyen Committed by Commit Bot

Enable powerwash shortcut in views-based login screen.

Bug: 837501
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ia55c5e302d70c1a65409fd7268ae135e0ee7c5ca
Reviewed-on: https://chromium-review.googlesource.com/1102904
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569043}
parent 38da049a
......@@ -193,6 +193,12 @@ void LoginScreenController::ShowGaiaSignin(
login_screen_client_->ShowGaiaSignin(can_close, prefilled_account);
}
void LoginScreenController::ShowResetScreen() {
if (!login_screen_client_)
return;
login_screen_client_->ShowResetScreen();
}
void LoginScreenController::OnRemoveUserWarningShown() {
if (!login_screen_client_)
return;
......
......@@ -71,6 +71,7 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
void FocusLockScreenApps(bool reverse);
void ShowGaiaSignin(bool can_close,
const base::Optional<AccountId>& prefilled_account);
void ShowResetScreen();
void OnRemoveUserWarningShown();
void RemoveUser(const AccountId& account_id);
void LaunchPublicSession(const AccountId& account_id,
......
......@@ -69,6 +69,7 @@ class MockLoginScreenClient : public mojom::LoginScreenClient {
void(const AccountId& account_id, const std::string& locale));
MOCK_METHOD0(ShowFeedback, void());
MOCK_METHOD1(LaunchKioskApp, void(const std::string& app_id));
MOCK_METHOD0(ShowResetScreen, void());
private:
bool authenticate_user_callback_result_ = true;
......
......@@ -38,10 +38,13 @@
#include "chromeos/dbus/dbus_thread_manager.h"
#include "components/user_manager/user_type.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/display/display.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/manager/managed_display_info.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
......@@ -1338,6 +1341,9 @@ void LockContentsView::RegisterAccelerators() {
// TODO: Add more accelerators that are applicable to login screen.
accel_map_[ui::Accelerator(ui::VKEY_I, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN)] =
AcceleratorAction::kShowFeedback;
accel_map_[ui::Accelerator(
ui::VKEY_R, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)] =
AcceleratorAction::kShowReset;
AcceleratorController* controller = Shell::Get()->accelerator_controller();
for (const auto& item : accel_map_)
......@@ -1349,6 +1355,9 @@ void LockContentsView::PerformAction(AcceleratorAction action) {
case AcceleratorAction::kShowFeedback:
Shell::Get()->login_screen_controller()->ShowFeedback();
return;
case AcceleratorAction::kShowReset:
Shell::Get()->login_screen_controller()->ShowResetScreen();
return;
default:
NOTREACHED();
}
......
......@@ -102,6 +102,7 @@ class ASH_EXPORT LockContentsView
enum class AcceleratorAction {
kShowFeedback,
kShowReset,
};
// Number of login attempts before a login dialog is shown. For example, if
......
......@@ -194,6 +194,9 @@ interface LoginScreenClient {
// sign-in dialog so the user does not need to type the account email.
ShowGaiaSignin(bool can_close, signin.mojom.AccountId? prefilled_account);
// Show the Reset (Powerwash) screen.
ShowResetScreen();
// Notification that the remove user warning was shown.
OnRemoveUserWarningShown();
......
......@@ -360,6 +360,10 @@ void UserSelectionScreen::InitEasyUnlock() {
proximity_auth::ScreenlockBridge::Get()->SetLockHandler(this);
}
bool UserSelectionScreen::HasAnyUsers() const {
return !users_.empty();
}
// static
void UserSelectionScreen::FillUserDictionary(
user_manager::User* user,
......
......@@ -65,11 +65,12 @@ class UserSelectionScreen
void AttemptEasyUnlock(const AccountId& account_id);
void RecordClickOnLockIcon(const AccountId& account_id);
void InitEasyUnlock();
bool HasAnyUsers() const;
// ui::UserActivityDetector implementation:
void OnUserActivity(const ui::Event* event) override;
void InitEasyUnlock();
// proximity_auth::ScreenlockBridge::LockHandler implementation:
void ShowBannerMessage(const base::string16& message,
bool is_warning) override;
......
......@@ -7,6 +7,7 @@
#include <string>
#include <utility>
#include "base/optional.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/mojo_version_info_dispatcher.h"
......@@ -137,13 +138,15 @@ void LoginDisplayHostMojo::StartWizard(OobeScreen first_screen) {
DCHECK(GetOobeUI());
// Dtor of the old WizardController should be called before ctor of the
// new one to ensure only one |ExistingUserController| instance at a time.
// new one to ensure only one |WizardController| instance at a time.
wizard_controller_.reset();
wizard_controller_.reset(new WizardController(this, GetOobeUI()));
wizard_controller_->Init(first_screen);
bool closable_by_esc = first_screen == OobeScreen::SCREEN_OOBE_RESET;
// Post login screens should not be closable by escape key.
dialog_->Show(false /*closable_by_esc*/);
dialog_->Show(closable_by_esc);
}
WizardController* LoginDisplayHostMojo::GetWizardController() {
......@@ -171,6 +174,20 @@ void LoginDisplayHostMojo::OnStartSignInScreen(
return;
}
// If signin_screen_started_, we already have an instance of LockScreen,
// so we can skip login screen initialization and just reset the dialog state.
if (signin_screen_started_) {
if (user_selection_screen_->HasAnyUsers()) {
dialog_->Hide();
} else {
GetOobeUI()->GetGaiaScreenView()->ShowGaiaAsync(base::nullopt);
dialog_->Show(false /*closable_by_esc*/);
}
return;
}
signin_screen_started_ = true;
// There can only be one |ExistingUserController| instance at a time.
existing_user_controller_.reset();
existing_user_controller_ = std::make_unique<ExistingUserController>(this);
......@@ -222,13 +239,11 @@ void LoginDisplayHostMojo::UpdateGaiaDialogVisibility(
DCHECK(dialog_);
if (visible) {
if (prefilled_account) {
// Make sure gaia displays |account| if requested.
GetOobeUI()->GetGaiaScreenView()->ShowGaiaAsync(prefilled_account);
GetOobeUI()->GetGaiaScreenView()->ShowGaiaAsync(prefilled_account);
if (prefilled_account)
LoginDisplayHost::default_host()->LoadWallpaper(*prefilled_account);
} else {
else
LoginDisplayHost::default_host()->LoadSigninWallpaper();
}
dialog_->Show(can_close /*closable_by_esc*/);
return;
......
......@@ -144,6 +144,8 @@ class LoginDisplayHostMojo : public LoginDisplayHostCommon,
// Updates UI when version info is changed.
std::unique_ptr<MojoVersionInfoDispatcher> version_info_updater_;
bool signin_screen_started_ = false;
base::WeakPtrFactory<LoginDisplayHostMojo> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(LoginDisplayHostMojo);
......
......@@ -68,9 +68,6 @@ cr.define('cr.ui.Oobe', function() {
login.TopHeaderBar.decorate($('top-header-bar'));
chrome.send('screenStateInitialize');
if (Oobe.getInstance().showingViewsLogin)
chrome.send('showAddUser');
},
// Dummy Oobe functions not present with stripped login UI.
......
......@@ -118,6 +118,13 @@ void LoginScreenClient::ShowGaiaSignin(
}
}
void LoginScreenClient::ShowResetScreen() {
if (chromeos::LoginDisplayHost::default_host()) {
chromeos::LoginDisplayHost::default_host()->StartWizard(
chromeos::OobeScreen::SCREEN_OOBE_RESET);
}
}
void LoginScreenClient::OnRemoveUserWarningShown() {
ProfileMetrics::LogProfileDeleteUser(
ProfileMetrics::DELETE_PROFILE_USER_MANAGER_SHOW_WARNING);
......
......@@ -75,6 +75,7 @@ class LoginScreenClient : public ash::mojom::LoginScreenClient {
void ShowGaiaSignin(
bool can_close,
const base::Optional<AccountId>& prefilled_account) override;
void ShowResetScreen() override;
void OnRemoveUserWarningShown() override;
void RemoveUser(const AccountId& account_id) override;
void LaunchPublicSession(const AccountId& account_id,
......
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