Commit 016ff4b3 authored by Quan Nguyen's avatar Quan Nguyen Committed by Commit Bot

Reland "Enable powerwash shortcut in views-based login screen."

This reverts commit 14fd238a.
Removes the chrome.send('showAddUser') in md_login.js to avoid a race
between the powerwash dialog and the Gaia signin screen.

Bug: 837501
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I7ab656ebe522cbd164073b73b3dd927cca7b1f13
Reviewed-on: https://chromium-review.googlesource.com/1129384
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576306}
parent eb5b84e3
......@@ -237,6 +237,12 @@ void LoginScreenController::ShowFeedback() {
login_screen_client_->ShowFeedback();
}
void LoginScreenController::ShowResetScreen() {
if (!login_screen_client_)
return;
login_screen_client_->ShowResetScreen();
}
void LoginScreenController::AddObserver(
LoginScreenControllerObserver* observer) {
observers_.AddObserver(observer);
......
......@@ -82,6 +82,7 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
void RequestPublicSessionKeyboardLayouts(const AccountId& account_id,
const std::string& locale);
void ShowFeedback();
void ShowResetScreen();
void LaunchKioskApp(const std::string& app_id);
void LaunchArcKioskApp(const AccountId& account_id);
......
......@@ -68,6 +68,7 @@ class MockLoginScreenClient : public mojom::LoginScreenClient {
MOCK_METHOD2(RequestPublicSessionKeyboardLayouts,
void(const AccountId& account_id, const std::string& locale));
MOCK_METHOD0(ShowFeedback, void());
MOCK_METHOD0(ShowResetScreen, void());
MOCK_METHOD1(LaunchKioskApp, void(const std::string& app_id));
MOCK_METHOD1(LaunchArcKioskApp, void(const AccountId& account_id));
......
......@@ -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"
......@@ -1443,6 +1446,9 @@ void LockContentsView::RegisterAccelerators() {
AcceleratorAction::kFocusNextUser;
accel_map_[ui::Accelerator(ui::VKEY_LEFT, 0)] =
AcceleratorAction::kFocusPreviousUser;
accel_map_[ui::Accelerator(
ui::VKEY_R, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN)] =
AcceleratorAction::kShowResetScreen;
AcceleratorController* controller = Shell::Get()->accelerator_controller();
for (const auto& item : accel_map_)
......@@ -1460,6 +1466,9 @@ void LockContentsView::PerformAction(AcceleratorAction action) {
case AcceleratorAction::kFocusPreviousUser:
FocusPreviousUser();
return;
case AcceleratorAction::kShowResetScreen:
Shell::Get()->login_screen_controller()->ShowResetScreen();
return;
default:
NOTREACHED();
}
......
......@@ -104,6 +104,7 @@ class ASH_EXPORT LockContentsView
kShowFeedback,
kFocusNextUser,
kFocusPreviousUser,
kShowResetScreen,
};
// Number of login attempts before a login dialog is shown. For example, if
......
......@@ -35,6 +35,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/test/display_manager_test_api.h"
#include "ui/events/event_constants.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/controls/textfield/textfield.h"
......@@ -1722,4 +1723,15 @@ TEST_F(LockContentsViewKeyboardUnitTest, UserSwapFocusesBigView) {
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
}
TEST_F(LockContentsViewKeyboardUnitTest, PowerwashShortcutShowsResetScreen) {
ASSERT_NO_FATAL_FAILURE(ShowLoginScreen());
std::unique_ptr<MockLoginScreenClient> client = BindMockLoginScreenClient();
EXPECT_CALL(*client, ShowResetScreen()).Times(1);
ui::test::EventGenerator* generator = GetEventGenerator();
generator->PressKey(
ui::VKEY_R, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN);
base::RunLoop().RunUntilIdle();
}
} // namespace ash
......@@ -226,6 +226,9 @@ interface LoginScreenClient {
// Request to show a feedback report dialog in chrome.
ShowFeedback();
// Show the reset (powerwash) screen.
ShowResetScreen();
// Launch the specific kiosk app.
LaunchKioskApp(string app_id);
......
......@@ -43,6 +43,10 @@ class GaiaView {
const std::string& password,
const std::string& services) = 0;
// Cancels the request to show the sign-in screen while the asynchronous
// clean-up process that precedes the screen being shown is in progress.
virtual void CancelShowGaiaAsync() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(GaiaView);
};
......
......@@ -162,8 +162,10 @@ void LoginDisplayHostMojo::StartWizard(OobeScreen first_screen) {
wizard_controller_ = std::make_unique<WizardController>();
wizard_controller_->Init(first_screen);
// Post login screens should not be closable by escape key.
dialog_->Show(false /*closable_by_esc*/);
// Post login screens (aside from powerwash) should not be closable by escape
// key.
bool closable_by_esc = first_screen == OobeScreen::SCREEN_OOBE_RESET;
dialog_->Show(closable_by_esc);
}
WizardController* LoginDisplayHostMojo::GetWizardController() {
......@@ -191,6 +193,14 @@ void LoginDisplayHostMojo::OnStartSignInScreen(
return;
}
if (signin_screen_started_) {
dialog_->Hide();
GetOobeUI()->GetGaiaScreenView()->ShowGaiaAsync(base::nullopt);
return;
}
signin_screen_started_ = true;
existing_user_controller_ = std::make_unique<ExistingUserController>();
login_display_->set_delegate(existing_user_controller_.get());
......@@ -250,6 +260,11 @@ void LoginDisplayHostMojo::ShowGaiaDialog(
GetOobeUI()->GetGaiaScreenView()->ShowGaiaAsync(prefilled_account);
LoadWallpaper(*prefilled_account);
} else {
// Restore the gaia screen if the OOBE dialog is currently occupied by a
// wizard.
if (GetOobeUI()->current_screen() != OobeScreen::SCREEN_GAIA_SIGNIN)
GetOobeUI()->GetGaiaScreenView()->ShowGaiaAsync(base::nullopt);
LoadSigninWallpaper();
}
......
......@@ -155,6 +155,11 @@ class LoginDisplayHostMojo : public LoginDisplayHostCommon,
// Updates UI when version info is changed.
std::unique_ptr<MojoVersionInfoDispatcher> version_info_updater_;
// Set to true on the first call to OnStartSignInScreen. Never reset to false.
// This is used to avoid doing redundant work (e.g. LockScreen::Show()) if the
// login screen is already showing and OnStartSignInScreen is called again.
bool signin_screen_started_ = false;
base::WeakPtrFactory<LoginDisplayHostMojo> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(LoginDisplayHostMojo);
......
......@@ -69,9 +69,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.
......
......@@ -9,11 +9,13 @@
#include "ash/public/interfaces/constants.mojom.h"
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/login/reauth_stats.h"
#include "chrome/browser/chromeos/login/screens/gaia_view.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "components/user_manager/remove_user_delegate.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h"
......@@ -151,6 +153,19 @@ void LoginScreenClient::ShowFeedback() {
chromeos::LoginDisplayHost::default_host()->ShowFeedback();
}
void LoginScreenClient::ShowResetScreen() {
if (chromeos::LoginDisplayHost::default_host()->GetOobeUI()) {
// If gaia init is in progress, cancel it so the screen doesn't race with
// the reset wizard.
chromeos::LoginDisplayHost::default_host()
->GetOobeUI()
->GetGaiaScreenView()
->CancelShowGaiaAsync();
chromeos::LoginDisplayHost::default_host()->StartWizard(
chromeos::OobeScreen::SCREEN_OOBE_RESET);
}
}
void LoginScreenClient::LaunchKioskApp(const std::string& app_id) {
chromeos::LoginDisplayHost::default_host()->StartAppLaunch(app_id, false,
false);
......
......@@ -83,6 +83,7 @@ class LoginScreenClient : public ash::mojom::LoginScreenClient {
void RequestPublicSessionKeyboardLayouts(const AccountId& account_id,
const std::string& locale) override;
void ShowFeedback() override;
void ShowResetScreen() override;
void LaunchKioskApp(const std::string& app_id) override;
void LaunchArcKioskApp(const AccountId& account_id) override;
......
......@@ -829,7 +829,6 @@ void GaiaScreenHandler::HandleShowAddUser(const base::ListValue* args) {
TRACE_EVENT_ASYNC_STEP_INTO0("ui", "ShowLoginWebUI",
LoginDisplayHostWebUI::kShowLoginWebUIid,
"ShowAddUser");
std::string email;
// |args| can be null if it's OOBE.
if (args)
......@@ -837,6 +836,7 @@ void GaiaScreenHandler::HandleShowAddUser(const base::ListValue* args) {
set_populated_email(email);
if (!email.empty())
SendReauthReason(AccountId::FromUserEmail(email));
OnShowAddUser();
}
......
......@@ -56,6 +56,7 @@ class GaiaScreenHandler : public BaseScreenHandler,
void ShowSigninScreenForTest(const std::string& username,
const std::string& password,
const std::string& services) override;
void CancelShowGaiaAsync() override;
private:
// TODO (xiaoyinh): remove this dependency.
......@@ -171,10 +172,6 @@ class GaiaScreenHandler : public BaseScreenHandler,
// principals API was used during SAML login.
void SetSAMLPrincipalsAPIUsed(bool api_used);
// Cancels the request to show the sign-in screen while the asynchronous
// clean-up process that precedes the screen showing is in progress.
void CancelShowGaiaAsync();
// Shows signin screen after dns cache and cookie cleanup operations finish.
void ShowGaiaScreenIfReady();
......
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