OOBE - Polymer3 Migration - EULA Screen
Migrate the EULA screen to ES6 class syntax and add
directives to generate its modularised version.
Bug: 1184731, 1252778
Change-Id: Ifbfa03a0f76f33f4bbe3ffc3cee323166e635f2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3205362
Commit-Queue: Renato Silva <rrsilva@google.com>
Reviewed-by: Roman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#929321}
diff --git a/chrome/browser/resources/chromeos/login/BUILD.gn b/chrome/browser/resources/chromeos/login/BUILD.gn
index 4e20188c..f54371c 100644
--- a/chrome/browser/resources/chromeos/login/BUILD.gn
+++ b/chrome/browser/resources/chromeos/login/BUILD.gn
@@ -173,6 +173,8 @@
"screens/common/gesture_navigation.js",
"screens/common/marketing_opt_in.html",
"screens/common/marketing_opt_in.js",
+ "screens/oobe/oobe_eula.html",
+ "screens/oobe/oobe_eula.js",
"screens/common/parental_handoff.html",
"screens/common/parental_handoff.js",
"screens/common/sync_consent.html",
@@ -262,6 +264,7 @@
"screens/login/management_transition.m.js",
"screens/oobe/auto_enrollment_check.m.js",
"screens/oobe/hid_detection.m.js",
+ "screens/oobe/oobe_eula.m.js",
"screens/oobe/packaged_license.m.js",
# Special files.
diff --git a/chrome/browser/resources/chromeos/login/oobe_polymer3.html b/chrome/browser/resources/chromeos/login/oobe_polymer3.html
index ee0116a..6bdcc04 100644
--- a/chrome/browser/resources/chromeos/login/oobe_polymer3.html
+++ b/chrome/browser/resources/chromeos/login/oobe_polymer3.html
@@ -33,6 +33,8 @@
</hid-detection-element>
<packaged-license-element id="packaged-license" class="step hidden" hidden>
</packaged-license-element>
+ <oobe-eula-element id="oobe-eula-md" class="step hidden" hidden>
+ </oobe-eula-element>
<sync-consent-element id="sync-consent" class="step hidden" hidden>
</sync-consent-element>
<app-downloading-element id="app-downloading" class="step hidden" hidden>
diff --git a/chrome/browser/resources/chromeos/login/oobe_polymer3.js b/chrome/browser/resources/chromeos/login/oobe_polymer3.js
index ce9caaf..8d989945 100644
--- a/chrome/browser/resources/chromeos/login/oobe_polymer3.js
+++ b/chrome/browser/resources/chromeos/login/oobe_polymer3.js
@@ -14,6 +14,7 @@
import 'chrome://oobe/screens/login/management_transition.m.js';
import 'chrome://oobe/screens/oobe/auto_enrollment_check.m.js';
import 'chrome://oobe/screens/oobe/hid_detection.m.js';
+import 'chrome://oobe/screens/oobe/oobe_eula.m.js';
import 'chrome://oobe/screens/oobe/packaged_license.m.js';
import {Oobe} from './cr_ui.m.js';
diff --git a/chrome/browser/resources/chromeos/login/screens/oobe/BUILD.gn b/chrome/browser/resources/chromeos/login/screens/oobe/BUILD.gn
index f30a83b..6d1dcae4 100644
--- a/chrome/browser/resources/chromeos/login/screens/oobe/BUILD.gn
+++ b/chrome/browser/resources/chromeos/login/screens/oobe/BUILD.gn
@@ -11,6 +11,7 @@
public_deps = [
":auto_enrollment_check_module",
":hid_detection_module",
+ ":oobe_eula_module",
":packaged_license_module",
]
}
@@ -25,7 +26,6 @@
":demo_preferences",
":demo_setup",
":enable_debugging",
- ":oobe_eula",
":oobe_network",
]
}
@@ -36,6 +36,7 @@
deps = [
":auto_enrollment_check.m",
":hid_detection.m",
+ ":oobe_eula.m",
":packaged_license.m",
]
}
@@ -75,17 +76,6 @@
]
}
-js_library("oobe_eula") {
- deps = [
- "../../components:web_view_helper",
- "../../components/behaviors:login_screen_behavior",
- "../../components/behaviors:oobe_dialog_host_behavior",
- "../../components/behaviors:oobe_i18n_behavior",
- "../../components/dialogs:oobe_adaptive_dialog",
- "../../components/dialogs:oobe_modal_dialog",
- ]
-}
-
js_library("oobe_network") {
deps = [
# TODO(crbug.com/251576): Restore when migrate to Polymer 3.
@@ -121,6 +111,21 @@
extra_deps = [ ":hid_detection_module" ]
}
+js_library("oobe_eula.m") {
+ sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/oobe/oobe_eula.m.js" ]
+ deps = [
+ "../../:display_manager.m",
+ "../../components:web_view_helper.m",
+ "../../components/behaviors:login_screen_behavior.m",
+ "../../components/behaviors:multi_step_behavior.m",
+ "../../components/behaviors:oobe_i18n_behavior.m",
+ "../../components/dialogs:oobe_adaptive_dialog.m",
+ "../../components/dialogs:oobe_modal_dialog.m",
+ "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
+ ]
+ extra_deps = [ ":oobe_eula_module" ]
+}
+
js_library("packaged_license.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/oobe/packaged_license.m.js" ]
deps = [
@@ -149,6 +154,14 @@
namespace_rewrites = oobe_namespace_rewrites
}
+polymer_modulizer("oobe_eula") {
+ js_file = "oobe_eula.js"
+ html_file = "oobe_eula.html"
+ html_type = "dom-module"
+ auto_imports = oobe_auto_imports
+ namespace_rewrites = oobe_namespace_rewrites
+}
+
polymer_modulizer("packaged_license") {
js_file = "packaged_license.js"
html_file = "packaged_license.html"
diff --git a/chrome/browser/resources/chromeos/login/screens/oobe/oobe_eula.html b/chrome/browser/resources/chromeos/login/screens/oobe/oobe_eula.html
index 1ec4505..9f10f5a 100644
--- a/chrome/browser/resources/chromeos/login/screens/oobe/oobe_eula.html
+++ b/chrome/browser/resources/chromeos/login/screens/oobe/oobe_eula.html
@@ -7,19 +7,23 @@
<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/html/action_link.html">
+<link rel="import" href="chrome://resources/html/assert.html">
+<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
-<link rel="import" href="/components/oobe_icons.html">
-<link rel="import" href="/components/behaviors/login_screen_behavior.html">
-<link rel="import" href="/components/behaviors/multi_step_behavior.html">
-<link rel="import" href="/components/behaviors/oobe_i18n_behavior.html">
-<link rel="import" href="/components/buttons/oobe_back_button.html">
-<link rel="import" href="/components/buttons/oobe_text_button.html">
-<link rel="import" href="/components/common_styles/common_styles.html">
-<link rel="import" href="/components/common_styles/oobe_dialog_host_styles.html">
-<link rel="import" href="/components/dialogs/oobe_adaptive_dialog.html">
-<link rel="import" href="/components/dialogs/oobe_modal_dialog.html">
+<link rel="import" href="../../cr_ui.html">
+<link rel="import" href="../../components/oobe_icons.html">
+<link rel="import" href="../../components/web_view_helper.html">
+<link rel="import" href="../../components/behaviors/login_screen_behavior.html">
+<link rel="import" href="../../components/behaviors/multi_step_behavior.html">
+<link rel="import" href="../../components/behaviors/oobe_i18n_behavior.html">
+<link rel="import" href="../../components/buttons/oobe_back_button.html">
+<link rel="import" href="../../components/buttons/oobe_text_button.html">
+<link rel="import" href="../../components/common_styles/common_styles.html">
+<link rel="import" href="../../components/common_styles/oobe_dialog_host_styles.html">
+<link rel="import" href="../../components/dialogs/oobe_adaptive_dialog.html">
+<link rel="import" href="../../components/dialogs/oobe_modal_dialog.html">
<dom-module id="oobe-eula-element">
<template>
@@ -181,4 +185,5 @@
</oobe-text-button>
</oobe-modal-dialog>
</template>
+ <script src="oobe_eula.js"></script>
</dom-module>
diff --git a/chrome/browser/resources/chromeos/login/screens/oobe/oobe_eula.js b/chrome/browser/resources/chromeos/login/screens/oobe/oobe_eula.js
index 628acb4..dddfd85 100644
--- a/chrome/browser/resources/chromeos/login/screens/oobe/oobe_eula.js
+++ b/chrome/browser/resources/chromeos/login/screens/oobe/oobe_eula.js
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function() {
+/* #js_imports_placeholder */
// Enum that describes the current state of the Terms Of Service screen
-const UIState = {
+const EulaScreenState = {
LOADING: 'loading',
EULA: 'eula',
SECURITY: 'security',
};
-const CLEAR_ANCHORS_CONTENT_SCRIPT = {
+const EULA_CLEAR_ANCHORS_CONTENT_SCRIPT = {
code: 'A=Array.from(document.getElementsByTagName("a"));' +
'for(var i = 0; i < A.length; ++i) {' +
' const el = A[i];' +
@@ -49,7 +49,7 @@
* URL to use when online page is not available.
* @type {string}
*/
-const TERMS_URL = 'chrome://terms';
+const EULA_TERMS_URL = 'chrome://terms';
// EulaLoader assists on the process of loading an URL into a webview.
// It listens for events from the webRequest API for the given URL and
@@ -81,15 +81,15 @@
this.url_ = '';
if (clear_anchors) {
- // Add the CLEAR_ANCHORS_CONTENT_SCRIPT that will clear <a><\a>
+ // Add the EULA_CLEAR_ANCHORS_CONTENT_SCRIPT that will clear <a><\a>
// (anchors) in order to prevent any navigation in the webview itself.
webview.addContentScripts([{
name: 'clearAnchors',
matches: ['<all_urls>'],
- js: CLEAR_ANCHORS_CONTENT_SCRIPT,
+ js: EULA_CLEAR_ANCHORS_CONTENT_SCRIPT,
}]);
webview.addEventListener('contentload', () => {
- webview.executeScript(CLEAR_ANCHORS_CONTENT_SCRIPT);
+ webview.executeScript(EULA_CLEAR_ANCHORS_CONTENT_SCRIPT);
});
}
webview.addEventListener('contentload', () => {
@@ -236,75 +236,90 @@
* screen.
*/
-Polymer({
- is: 'oobe-eula-element',
+/**
+ * @constructor
+ * @extends {PolymerElement}
+ * @implements {LoginScreenBehaviorInterface}
+ * @implements {MultiStepBehaviorInterface}
+ * @implements {OobeI18nBehaviorInterface}
+ */
+ const EulaScreenBase = Polymer.mixinBehaviors(
+ [OobeI18nBehavior, LoginScreenBehavior, MultiStepBehavior],
+ Polymer.Element);
- behaviors: [
- OobeI18nBehavior,
- LoginScreenBehavior,
- MultiStepBehavior,
- ],
+class EulaScreen extends EulaScreenBase {
- EXTERNAL_API: [
- 'setUsageStats',
- 'showAdditionalTosDialog',
- 'showSecuritySettingsDialog',
- 'setTpmDesc',
- ],
+ static get is() { return 'oobe-eula-element'; }
- properties: {
- /**
- * "Accepot and continue" button is disabled until content is loaded.
- */
- acceptButtonDisabled: {
- type: Boolean,
- value: true,
- },
+ /* #html_template_placeholder */
- /**
- * If "Report anonymous usage stats" checkbox is checked.
- */
- usageStatsChecked: {
- type: Boolean,
- value: false,
- },
+ static get properties() {
+ return {
+ /**
+ * "Accept and continue" button is disabled until content is loaded.
+ */
+ acceptButtonDisabled: {
+ type: Boolean,
+ },
- /*
- * @type {string}
- */
- tpmDescription_: {
- type: String,
- value: '',
- },
- },
+ /**
+ * If "Report anonymous usage stats" checkbox is checked.
+ */
+ usageStatsChecked: {
+ type: Boolean,
+ },
- /**
- * Flag that ensures that eula screen set up once.
- * @private {boolean}
- */
- initialized_: false,
+ tpmDescription_: {
+ type: String,
+ },
+
+ /**
+ * Flag that ensures that eula screen set up once.
+ * @private
+ */
+ initialized_: {
+ type: Boolean,
+ },
+ };
+ }
+
+ constructor() {
+ super();
+ this.UI_STEPS = EulaScreenState;
+ this.acceptButtonDisabled = true;
+ this.usageStatsChecked = false;
+ this.tpmDescription_ = '';
+ this.initialized_ = false;
+ }
+
+ get EXTERNAL_API() {
+ return ['setUsageStats',
+ 'showAdditionalTosDialog',
+ 'showSecuritySettingsDialog',
+ 'setTpmDesc'];
+ }
defaultUIStep() {
- return UIState.LOADING;
- },
-
- UI_STEPS: UIState,
+ return EulaScreenState.LOADING;
+ }
/** Called just before the dialog is shown */
onBeforeShow() {
window.setTimeout(this.initializeScreen_.bind(this), 0);
this.updateLocalizedContent();
- },
+ }
ready() {
+ super.ready();
this.initializeLoginScreen('EulaScreen', {
resetAllowed: true,
});
- },
+ }
/**
* Set up dialog before shown it for the first time.
* @private
+ * @suppress {missingProperties}
*/
initializeScreen_() {
if (this.initialized_)
@@ -312,7 +327,7 @@
this.$.eulaDialog.scrollToBottom();
this.applyOobeConfiguration_();
this.initialized_ = true;
- },
+ }
/**
* Called when dialog is shown for the first time.
@@ -328,17 +343,18 @@
if (configuration.eulaAutoAccept) {
this.eulaAccepted_();
}
- },
+ }
/**
* Event handler that is invoked when EULA is loaded. Either online version or
* 'chrome://terms' fallback.
+ * @suppress {missingProperties}
*/
onFrameLoad_() {
this.acceptButtonDisabled = false;
- this.setUIStep(UIState.EULA);
+ this.setUIStep(EulaScreenState.EULA);
this.$.eulaDialog.scrollToBottom();
- },
+ }
/**
* Load Eula into the given webview. Online version is attempted first with
@@ -358,7 +374,7 @@
var loadBundledEula = function() {
WebViewHelper.loadUrlContentToWebView(
- webview, TERMS_URL, WebViewHelper.ContentType.HTML);
+ webview, EULA_TERMS_URL, WebViewHelper.ContentType.HTML);
};
// Load online Eula with a timeout to fallback to the offline version.
@@ -367,16 +383,17 @@
webview, ONLINE_EULA_LOAD_TIMEOUT_IN_MS, loadBundledEula,
clear_anchors);
eulaLoader.setUrl(onlineEulaUrl);
- },
+ }
/**
* This is called when strings are updated.
+ * @suppress {missingProperties}
*/
updateLocalizedContent() {
// This forces frame to reload.
const onlineEulaUrl = loadTimeData.getString('eulaOnlineUrl');
- this.setUIStep(UIState.LOADING);
+ this.setUIStep(EulaScreenState.LOADING);
this.loadEulaToWebview_(
this.$.crosEulaFrame, onlineEulaUrl, false /* clear_anchors */);
@@ -386,7 +403,7 @@
this.$.additionalChromeToSFrame, additionalToSUrl,
true /* clear_anchors */);
this.i18nUpdateLocale();
- },
+ }
/**
* This is 'on-tap' event handler for 'Accept' button.
@@ -395,7 +412,7 @@
*/
eulaAccepted_() {
this.userActed('accept-button');
- },
+ }
/**
* On-change event handler for usageStats.
@@ -408,40 +425,43 @@
} else {
this.userActed('unselect-stats-usage');
}
- },
+ }
/**
* @private
*/
onAdditionalTermsClicked_() {
this.userActed('show-additional-tos');
- },
+ }
/**
* Shows additional terms of service dialog.
+ * @suppress {missingProperties}
*/
showAdditionalTosDialog() {
this.$.additionalToS.showDialog();
this.$.closeAdditionalTos.focus();
- },
+ }
/**
* On-click event handler for close button of the additional ToS dialog.
*
* @private
+ * @suppress {missingProperties}
*/
hideToSDialog_() {
this.$.additionalToS.hideDialog();
this.focusAdditionalTermsLink_();
- },
+ }
/**
* @private
+ * @suppress {missingProperties}
*/
focusAdditionalTermsLink_() {
Polymer.RenderStatus.afterNextRender(
this, () => this.$.additionalTerms.focus());
- },
+ }
/**
* On-tap event handler for securitySettings.
@@ -450,43 +470,45 @@
*/
onSecuritySettingsClicked_() {
this.userActed('show-security-settings');
- },
+ }
/**
* Shows system security settings dialog.
*/
showSecuritySettingsDialog() {
- this.setUIStep(UIState.SECURITY);
- },
+ this.setUIStep(EulaScreenState.SECURITY);
+ }
/**
* Sets TPM description message.
*/
setTpmDesc(description) {
this.tpmDescription_ = description;
- },
+ }
/**
* On-tap event handler for the close button on security settings page.
*
* @private
+ * @suppress {missingProperties}
*/
onSecuritySettingsCloseClicked_() {
- this.setUIStep(UIState.EULA);
+ this.setUIStep(EulaScreenState.EULA);
Polymer.RenderStatus.afterNextRender(
this, () => this.$.securitySettings.focus());
- },
+ }
/**
* On-tap event handler for stats-help-link.
*
* @private
+ * @suppress {missingProperties}
*/
onUsageStatsHelpLinkClicked_(e) {
this.userActed('show-stats-usage-learn-more');
this.$.learnMore.focus();
e.stopPropagation();
- },
+ }
/**
* On-tap event handler for back button.
@@ -495,7 +517,7 @@
*/
onEulaBackButtonPressed_() {
this.userActed('back-button');
- },
+ }
/**
* Sets usage statistics checkbox.
@@ -503,6 +525,7 @@
*/
setUsageStats(checked) {
this.usageStatsChecked = checked;
- },
-});
-})();
+ }
+}
+
+customElements.define(EulaScreen.is, EulaScreen);
diff --git a/chrome/browser/resources/chromeos/login/structure/components_oobe.html b/chrome/browser/resources/chromeos/login/structure/components_oobe.html
index e2c2a12..c22688a 100644
--- a/chrome/browser/resources/chromeos/login/structure/components_oobe.html
+++ b/chrome/browser/resources/chromeos/login/structure/components_oobe.html
@@ -6,6 +6,7 @@
<link rel="import" href="/screens/oobe/auto_enrollment_check.html">
<link rel="import" href="/screens/oobe/hid_detection.html">
<link rel="import" href="/screens/oobe/packaged_license.html">
+<link rel="import" href="/screens/oobe/oobe_eula.html">
<include src="../components/oobe_i18n_dropdown.html">
@@ -13,7 +14,6 @@
<include src="../oobe_welcome_dialog.html">
<include src="../oobe_welcome.html">
<include src="../screens/oobe/oobe_network.html">
-<include src="../screens/oobe/oobe_eula.html">
<include src="../oobe_update.html">
<include src="../screens/oobe/demo_setup.html">
<include src="../screens/oobe/demo_preferences.html">
diff --git a/chrome/browser/resources/chromeos/login/structure/components_oobe.js b/chrome/browser/resources/chromeos/login/structure/components_oobe.js
index 491d2a44..4382976 100644
--- a/chrome/browser/resources/chromeos/login/structure/components_oobe.js
+++ b/chrome/browser/resources/chromeos/login/structure/components_oobe.js
@@ -10,7 +10,6 @@
// <include src="../oobe_welcome_dialog.js">
// <include src="../oobe_welcome.js">
// <include src="../screens/oobe/oobe_network.js">
-// <include src="../screens/oobe/oobe_eula.js">
// <include src="../oobe_update.js">
// <include src="../screens/oobe/demo_setup.js">
// <include src="../screens/oobe/demo_preferences.js">