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

cros: Show reset screen by forwarding accelerator to webui.

This change has two main effects. First, this allows for the
CoreOobeHandler to decide whether or not the powerwash dialog should be
shown (e.g. due to being enterprise enrolled). Second, this seems to fix
the race between the Gaia screen init and the powerwash dialog when the
user hits CTRL+ALT+SHIFT+R early on.

This CL also adds a unit test to ensure that the powerwash shortcut
sends a mojo call to the browser thread.

Bug: 837501
Change-Id: I345e4c4f5be7ecb64b6d7605101e93feb2fc3bbf
Reviewed-on: https://chromium-review.googlesource.com/1148646Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577998}
parent 5fabb2c2
......@@ -1722,4 +1722,22 @@ TEST_F(LockContentsViewKeyboardUnitTest, UserSwapFocusesBigView) {
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
}
TEST_F(LockContentsViewUnitTest, PowerwashShortcutSendsMojoCall) {
auto* contents = new LockContentsView(
mojom::TrayActionState::kNotAvailable, LockScreen::ScreenType::kLock,
data_dispatcher(),
std::make_unique<FakeLoginDetachableBaseModel>(data_dispatcher()));
SetUserCount(1);
SetWidget(CreateWidgetWithContent(contents));
std::unique_ptr<MockLoginScreenClient> client = BindMockLoginScreenClient();
EXPECT_CALL(*client, ShowResetScreen());
ui::test::EventGenerator* generator = GetEventGenerator();
generator->PressKey(ui::KeyboardCode::VKEY_R, ui::EF_CONTROL_DOWN |
ui::EF_ALT_DOWN |
ui::EF_SHIFT_DOWN);
base::RunLoop().RunUntilIdle();
}
} // namespace ash
......@@ -140,6 +140,8 @@ void FakeLoginDisplayHost::ResyncUserData() {}
void FakeLoginDisplayHost::ShowFeedback() {}
void FakeLoginDisplayHost::ShowResetScreen() {}
void FakeLoginDisplayHost::ShowDialogForCaptivePortal() {}
void FakeLoginDisplayHost::HideDialogForCaptivePortal() {}
......
......@@ -65,6 +65,7 @@ class FakeLoginDisplayHost : public LoginDisplayHost {
void MigrateUserData(const std::string& old_password) override;
void ResyncUserData() override;
void ShowFeedback() override;
void ShowResetScreen() override;
void ShowDialogForCaptivePortal() override;
void HideDialogForCaptivePortal() override;
void UpdateAddUserButtonStatus() override;
......
......@@ -194,6 +194,9 @@ class LoginDisplayHost {
// Shows a feedback report dialog.
virtual void ShowFeedback() = 0;
// Shows the powerwash dialog.
virtual void ShowResetScreen() = 0;
// In the views case, make the OobeUIDialogDelegate visible so that Captive
// Portal web modal can be seen. In webui login, this should be a no-op.
virtual void ShowDialogForCaptivePortal() = 0;
......
......@@ -28,6 +28,7 @@ namespace {
constexpr char kLoginDisplay[] = "login";
constexpr char kAccelSendFeedback[] = "send_feedback";
constexpr char kAccelReset[] = "reset";
} // namespace
......@@ -191,7 +192,10 @@ void LoginDisplayHostMojo::OnStartSignInScreen(
}
if (signin_screen_started_) {
// If we already have a signin screen instance, just reset the state of the
// oobe dialog.
HideOobeDialog();
GetOobeUI()->GetGaiaScreenView()->ShowGaiaAsync(base::nullopt);
return;
}
......@@ -308,6 +312,11 @@ void LoginDisplayHostMojo::ShowFeedback() {
GetOobeUI()->ForwardAccelerator(kAccelSendFeedback);
}
void LoginDisplayHostMojo::ShowResetScreen() {
DCHECK(GetOobeUI());
GetOobeUI()->ForwardAccelerator(kAccelReset);
}
void LoginDisplayHostMojo::UpdateAddUserButtonStatus() {
DCHECK(GetOobeUI());
LoginScreenClient::Get()->login_screen()->SetAddUserButtonEnabled(
......
......@@ -92,6 +92,7 @@ class LoginDisplayHostMojo : public LoginDisplayHostCommon,
const user_manager::UserList GetUsers() override;
void OnCancelPasswordChangedFlow() override;
void ShowFeedback() override;
void ShowResetScreen() override;
void ShowDialogForCaptivePortal() override;
void HideDialogForCaptivePortal() override;
void UpdateAddUserButtonStatus() override;
......
......@@ -1173,6 +1173,10 @@ void LoginDisplayHostWebUI::ShowFeedback() {
NOTREACHED();
}
void LoginDisplayHostWebUI::ShowResetScreen() {
NOTREACHED();
}
// This is handled differently in webui.
void LoginDisplayHostWebUI::ShowDialogForCaptivePortal() {}
......
......@@ -80,6 +80,7 @@ class LoginDisplayHostWebUI : public LoginDisplayHostCommon,
void UpdateOobeDialogSize(int width, int height) override;
const user_manager::UserList GetUsers() override;
void ShowFeedback() override;
void ShowResetScreen() override;
void ShowDialogForCaptivePortal() override;
void HideDialogForCaptivePortal() override;
void UpdateAddUserButtonStatus() override;
......
......@@ -72,6 +72,7 @@ class MockLoginDisplayHost : public LoginDisplayHost {
MOCK_METHOD1(MigrateUserData, void(const std::string&));
MOCK_METHOD0(ResyncUserData, void());
MOCK_METHOD0(ShowFeedback, void());
MOCK_METHOD0(ShowResetScreen, void());
MOCK_METHOD0(OnCancelPasswordChangedFlow, void());
MOCK_METHOD0(ShowDialogForCaptivePortal, void());
MOCK_METHOD0(HideDialogForCaptivePortal, void());
......
......@@ -163,8 +163,7 @@ void LoginScreenClient::LaunchArcKioskApp(const AccountId& account_id) {
}
void LoginScreenClient::ShowResetScreen() {
chromeos::LoginDisplayHost::default_host()->StartWizard(
chromeos::OobeScreen::SCREEN_OOBE_RESET);
chromeos::LoginDisplayHost::default_host()->ShowResetScreen();
}
void LoginScreenClient::LoadWallpaper(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