Commit 5f73f588 authored by Ossama Mahmoud's avatar Ossama Mahmoud Committed by Chromium LUCI CQ

Migrate AutolaunchScreen to LoginScreenBehavior

Bug: 1153306
Change-Id: I425eba7b9d8b15c6538f4dc49ddd4db893779128
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566993Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Commit-Queue: Ossama Mahmoud <osamafathy@google.com>
Cr-Commit-Position: refs/heads/master@{#836580}
parent e2b5130c
...@@ -134,6 +134,8 @@ namespace chromeos { ...@@ -134,6 +134,8 @@ namespace chromeos {
namespace { namespace {
const test::UIPath kConfigNetwork = {"app-launch-splash", "configNetwork"}; const test::UIPath kConfigNetwork = {"app-launch-splash", "configNetwork"};
const test::UIPath kAutolaunchConfirmButton = {"autolaunch", "confirmButton"};
const test::UIPath kAutolaunchCancelButton = {"autolaunch", "cancelButton"};
// This is a simple test app that creates an app window and immediately closes // This is a simple test app that creates an app window and immediately closes
// it again. Webstore data json is in // it again. Webstore data json is in
...@@ -805,7 +807,7 @@ class KioskTest : public OobeBaseTest { ...@@ -805,7 +807,7 @@ class KioskTest : public OobeBaseTest {
} }
} }
void WaitForAuthLaunchWarning(bool visibility) { void WaitForAutoLaunchWarning(bool visibility) {
test::OobeJS().CreateVisibilityWaiter(visibility, {"autolaunch"})->Wait(); test::OobeJS().CreateVisibilityWaiter(visibility, {"autolaunch"})->Wait();
} }
...@@ -1137,12 +1139,11 @@ IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) { ...@@ -1137,12 +1139,11 @@ IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) {
wizard_controller->SkipToLoginForTesting(); wizard_controller->SkipToLoginForTesting();
// Wait for the auto launch warning come up. // Wait for the auto launch warning come up.
WaitForAuthLaunchWarning(/*visibility=*/true); WaitForAutoLaunchWarning(/*visibility=*/true);
test::ExecuteOobeJS( test::OobeJS().ClickOnPath(kAutolaunchCancelButton);
"login.AutolaunchScreen.confirmAutoLaunchForTesting(false);");
// Wait for the auto launch warning to go away. // Wait for the auto launch warning to go away.
WaitForAuthLaunchWarning(/*visibility=*/false); WaitForAutoLaunchWarning(/*visibility=*/false);
EXPECT_FALSE(KioskAppManager::Get()->IsAutoLaunchEnabled()); EXPECT_FALSE(KioskAppManager::Get()->IsAutoLaunchEnabled());
} }
...@@ -1164,13 +1165,12 @@ IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningConfirm) { ...@@ -1164,13 +1165,12 @@ IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningConfirm) {
wizard_controller->SkipToLoginForTesting(); wizard_controller->SkipToLoginForTesting();
// Wait for the auto launch warning come up. // Wait for the auto launch warning come up.
WaitForAuthLaunchWarning(/*visibility=*/true); WaitForAutoLaunchWarning(/*visibility=*/true);
test::ExecuteOobeJS( test::OobeJS().ClickOnPath(kAutolaunchConfirmButton);
"login.AutolaunchScreen.confirmAutoLaunchForTesting(true);");
// Wait for the auto launch warning to go away. // Wait for the auto launch warning to go away.
WaitForAuthLaunchWarning(/*visibility=*/false); WaitForAutoLaunchWarning(/*visibility=*/false);
EXPECT_FALSE(KioskAppManager::Get()->GetAutoLaunchApp().empty()); EXPECT_FALSE(KioskAppManager::Get()->GetAutoLaunchApp().empty());
EXPECT_TRUE(KioskAppManager::Get()->IsAutoLaunchEnabled()); EXPECT_TRUE(KioskAppManager::Get()->IsAutoLaunchEnabled());
...@@ -1323,14 +1323,13 @@ IN_PROC_BROWSER_TEST_F(KioskTest, NoConsumerAutoLaunchWhenUntrusted) { ...@@ -1323,14 +1323,13 @@ IN_PROC_BROWSER_TEST_F(KioskTest, NoConsumerAutoLaunchWhenUntrusted) {
wizard_controller->AdvanceToScreen(WelcomeView::kScreenId); wizard_controller->AdvanceToScreen(WelcomeView::kScreenId);
ReloadAutolaunchKioskApps(); ReloadAutolaunchKioskApps();
wizard_controller->SkipToLoginForTesting(); wizard_controller->SkipToLoginForTesting();
WaitForAuthLaunchWarning(/*visibility=*/true); WaitForAutoLaunchWarning(/*visibility=*/true);
// Make cros settings untrusted. // Make cros settings untrusted.
settings_helper_.SetTrustedStatus( settings_helper_.SetTrustedStatus(
CrosSettingsProvider::PERMANENTLY_UNTRUSTED); CrosSettingsProvider::PERMANENTLY_UNTRUSTED);
test::ExecuteOobeJS( test::OobeJS().ClickOnPath(kAutolaunchConfirmButton);
"login.AutolaunchScreen.confirmAutoLaunchForTesting(true);");
// Check that the attempt to auto-launch a kiosk app fails with an error. // Check that the attempt to auto-launch a kiosk app fails with an error.
OobeScreenWaiter(ErrorScreenView::kScreenId).Wait(); OobeScreenWaiter(ErrorScreenView::kScreenId).Wait();
...@@ -2786,7 +2785,7 @@ IN_PROC_BROWSER_TEST_F(KioskHiddenWebUITest, AutolaunchWarning) { ...@@ -2786,7 +2785,7 @@ IN_PROC_BROWSER_TEST_F(KioskHiddenWebUITest, AutolaunchWarning) {
EXPECT_FALSE(KioskAppManager::Get()->IsAutoLaunchEnabled()); EXPECT_FALSE(KioskAppManager::Get()->IsAutoLaunchEnabled());
// Wait for the auto launch warning come up. // Wait for the auto launch warning come up.
WaitForAuthLaunchWarning(/*visibility=*/true); WaitForAutoLaunchWarning(/*visibility=*/true);
// Wait for the wallpaper to load. // Wait for the wallpaper to load.
WaitForWallpaper(); WaitForWallpaper();
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
<script src="chrome://oobe/strings.js"></script> <script src="chrome://oobe/strings.js"></script>
<script defer src="chrome://oobe/test_api.js"></script> <script defer src="chrome://oobe/test_api.js"></script>
<link rel="stylesheet" href="api_keys_notice.css"> <link rel="stylesheet" href="api_keys_notice.css">
<link rel="stylesheet" href="oobe_screen_autolaunch.css">
<link rel="stylesheet" href="screen_error_message.css"> <link rel="stylesheet" href="screen_error_message.css">
<script src="chrome://oobe/keyboard_utils.js"></script> <script src="chrome://oobe/keyboard_utils.js"></script>
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
// <include // <include
// src="../../../../../ui/login/account_picker/chromeos_user_pod_row.js"> // src="../../../../../ui/login/account_picker/chromeos_user_pod_row.js">
// <include src="cr_ui.js"> // <include src="cr_ui.js">
// <include src="oobe_screen_autolaunch.js">
// <include src="oobe_select.js"> // <include src="oobe_select.js">
// <include src="screen_error_message.js"> // <include src="screen_error_message.js">
...@@ -48,7 +47,6 @@ HTMLImports.whenReady(() => { ...@@ -48,7 +47,6 @@ HTMLImports.whenReady(() => {
initialize() { initialize() {
cr.ui.login.DisplayManager.initialize(); cr.ui.login.DisplayManager.initialize();
login.AccountPickerScreen.register(); login.AccountPickerScreen.register();
login.AutolaunchScreen.register();
login.ErrorMessageScreen.register(); login.ErrorMessageScreen.register();
login.DiscoverScreen.register(); login.DiscoverScreen.register();
......
...@@ -59,8 +59,6 @@ ...@@ -59,8 +59,6 @@
<script defer src="chrome://oobe/test_api.js"></script> <script defer src="chrome://oobe/test_api.js"></script>
<link rel="stylesheet" href="api_keys_notice.css"> <link rel="stylesheet" href="api_keys_notice.css">
<link rel="stylesheet" href="oobe_screen_autolaunch.css">
<link rel="stylesheet" href="screen_error_message.css"> <link rel="stylesheet" href="screen_error_message.css">
<script src="chrome://oobe/keyboard_utils.js"></script> <script src="chrome://oobe/keyboard_utils.js"></script>
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
// <include // <include
// src="../../../../../ui/login/account_picker/chromeos_user_pod_row.js"> // src="../../../../../ui/login/account_picker/chromeos_user_pod_row.js">
// <include src="cr_ui.js"> // <include src="cr_ui.js">
// <include src="oobe_screen_autolaunch.js">
// <include src="oobe_select.js"> // <include src="oobe_select.js">
// <include src="screen_error_message.js"> // <include src="screen_error_message.js">
...@@ -39,7 +38,6 @@ HTMLImports.whenReady(() => { ...@@ -39,7 +38,6 @@ HTMLImports.whenReady(() => {
*/ */
initialize() { initialize() {
cr.ui.login.DisplayManager.initialize(); cr.ui.login.DisplayManager.initialize();
login.AutolaunchScreen.register();
login.AccountPickerScreen.register(); login.AccountPickerScreen.register();
login.ErrorMessageScreen.register(); login.ErrorMessageScreen.register();
login.DiscoverScreen.register(); login.DiscoverScreen.register();
......
/* Copyright 2013 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
#autolaunch {
min-height: 423px;
padding: 40px 17px 80px;
text-align: center;
width: 722px;
}
#autolaunch-controls {
bottom: 80px;
justify-content: center;
}
#autolaunch-warning-title {
color: #606060;
font-size: 22px;
padding: 5px 45px 30px;
}
#autolaunch-warning {
color: #606060;
font-size: 16px;
padding: 35px 40px 10px;
}
#autolaunch-app {
padding-bottom: 40px;
}
#autolaunch-app-container {
-webkit-align-items: center;
-webkit-justify-content: center;
display: -webkit-flex;
}
#autolaunch-app-name {
color: #404040;
font-size: 22px;
padding-left: 10px;
}
<div class="step hidden" id="autolaunch" hidden> <dom-module id="autolaunch-element">
<div class="step-contents"> <template>
<div id="autolaunch-warning-title" i18n-content="autolaunchTitle"></div> <style include="oobe-dialog-host">
<div id="autolaunch-app-container"> #warning{
<img id="autolaunch-app-icon" alt=""> color: #606060;
<div id="autolaunch-app-name"></div> }
</div>
<div id="autolaunch-warning" i18n-content="autolaunchWarning"></div> #appName {
</div> color: #404040;
<div id="autolaunch-controls" class="step-controls"></div> font-size: 22px;
</div> }
</style>
<oobe-dialog id="autolaunch" role="dialog" title-key="autolaunchTitle"
aria-label$="[[i18nDynamic(locale, 'autolaunchTitle')]]" has-buttons>
<div id="footer" slot="footer">
<img id="appIcon" src="[[appIcon_]]" alt="">
<div id="appName">[[appName_]]</div>
<div id="warning" slot="subtitle">[[i18nDynamic(locale, 'autolaunchWarning')]]</div>
</div>
<div slot="bottom-buttons" class="layout horizontal end-justified">
<oobe-text-button id="cancelButton" on-click="onCancel_" text-key="autolaunchCancelButton"
class="focus-on-show">
</oobe-text-button>
<oobe-text-button id="confirmButton" on-click="onConfirm_"
text-key="autolaunchConfirmButton" inverse>
</oobe-text-button>
</div>
</oobe-dialog>
</template>
</dom-module>
\ No newline at end of file
...@@ -6,81 +6,56 @@ ...@@ -6,81 +6,56 @@
* @fileoverview Oobe reset screen implementation. * @fileoverview Oobe reset screen implementation.
*/ */
login.createScreen('AutolaunchScreen', 'autolaunch', function() { Polymer({
return { is: 'autolaunch-element',
EXTERNAL_API: ['updateApp', 'confirmAutoLaunchForTesting'],
behaviors: [OobeI18nBehavior, OobeDialogHostBehavior, LoginScreenBehavior],
/**
* Buttons in oobe wizard's button strip. EXTERNAL_API: [
* @type {array} Array of Buttons. 'updateApp',
*/ ],
get buttons() {
var buttons = []; properties: {
appName_: {type: String, value: ''},
var confirmButton = this.ownerDocument.createElement('button'); appIconUrl_: {type: String, value: ''},
confirmButton.id = 'autolaunch-confirm-button'; },
confirmButton.textContent =
loadTimeData.getString('autolaunchConfirmButton');
confirmButton.addEventListener('click', function(e) { ready() {
chrome.send('autolaunchOnConfirm'); this.initializeLoginScreen('AutolaunchScreen', {
e.stopPropagation(); resetAllowed: true,
}); });
buttons.push(confirmButton); },
var cancelButton = this.ownerDocument.createElement('button'); onConfirm_() {
cancelButton.id = 'autolaunch-cancel-button'; chrome.send('autolaunchOnConfirm');
cancelButton.textContent = },
loadTimeData.getString('autolaunchCancelButton');
cancelButton.addEventListener('click', function(e) { onCancel_() {
chrome.send('autolaunchOnCancel'); chrome.send('autolaunchOnCancel');
e.stopPropagation(); },
});
buttons.push(cancelButton); /**
return buttons; * Event handler invoked when the page is shown and ready.
}, */
onBeforeShow() {
/** chrome.send('autolaunchVisible');
* Event handler invoked when the page is shown and ready. },
*/
onBeforeShow() { /**
chrome.send('autolaunchVisible'); * Cancels the reset and drops the user back to the login screen.
}, */
cancel() {
/** chrome.send('autolaunchOnCancel');
* Returns a control which should receive an initial focus. },
*/
get defaultControl() { /**
return $('autolaunch-cancel-button'); * Sets app to be displayed in the auto-launch warning.
}, * @param {!Object} app An dictionary with app info.
*/
/** updateApp(app) {
* Cancels the reset and drops the user back to the login screen. this.appName_ = app.appName;
*/ if (app.appIconUrl && app.appIconUrl.length)
cancel() { this.appIconUrl_ = app.appIconUrl;
chrome.send('autolaunchOnCancel'); },
},
/**
* Sets app to be displayed in the auto-launch warning.
* @param {!Object} app An dictionary with app info.
*/
updateApp(app) {
if (app.appIconUrl && app.appIconUrl.length)
$('autolaunch-app-icon').src = app.appIconUrl;
$('autolaunch-app-name').innerText = app.appName;
},
/**
* Initiates confirm/cancel response for testing.
* @param {boolean} confirm True if the screen should confirm auto-launch.
*/
confirmAutoLaunchForTesting(confirm) {
var button = confirm ? $('autolaunch-confirm-button') :
$('autolaunch-cancel-button');
var clickEvent = document.createEvent('Event');
clickEvent.initEvent('click', true, true);
button.dispatchEvent(clickEvent);
}
};
}); });
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<include src="../screen_signin_fatal_error.html"> <include src="../screen_signin_fatal_error.html">
<include src="../parental_handoff.html"> <include src="../parental_handoff.html">
<include src="../screen_app_launch_splash.html"> <include src="../screen_app_launch_splash.html">
<include src="../oobe_screen_autolaunch.html">
<include src="components_[OOBE].html"> <include src="components_[OOBE].html">
......
...@@ -53,6 +53,7 @@ function loadCommonComponents() { ...@@ -53,6 +53,7 @@ function loadCommonComponents() {
// <include src="../screen_signin_fatal_error.js"> // <include src="../screen_signin_fatal_error.js">
// <include src="../parental_handoff.js"> // <include src="../parental_handoff.js">
// <include src="../screen_app_launch_splash.js"> // <include src="../screen_app_launch_splash.js">
// <include src="../oobe_screen_autolaunch.js">
// <include src="components_[OOBE].js"> // <include src="components_[OOBE].js">
// TODO(crbug.com/1111387) - Remove excessive logging. // TODO(crbug.com/1111387) - Remove excessive logging.
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
<!-- Screens that can appear both in OOBE and Login modes. --> <!-- Screens that can appear both in OOBE and Login modes. -->
<oobe-reset-element id="reset" class="step" hidden></oobe-reset-element> <oobe-reset-element id="reset" class="step" hidden></oobe-reset-element>
<include src="../oobe_screen_autolaunch.html"> <autolaunch-element id="autolaunch" class="step hidden" hidden>
</autolaunch-element>
<oobe-adb-sideloading-element id="adb-sideloading" class="step hidden" hidden> <oobe-adb-sideloading-element id="adb-sideloading" class="step hidden" hidden>
</oobe-adb-sideloading-element> </oobe-adb-sideloading-element>
<kiosk-enable-element id="kiosk-enable" class="step hidden" hidden> <kiosk-enable-element id="kiosk-enable" class="step hidden" hidden>
......
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