[go: nahoru, domu]

[oobe] Import HTML templates at runtime: osauth screens part

Use html_to_wrapper() instead of html_to_js().

Besides the BUILD.gn/gni changes in this CL, the diff has been produced
with the following script https://pastebin.com/13UXcny1, along with
running "git cl format --js chrome/browser/resources".

Bug: 1292025, b:312141438
Change-Id: I91d2115075ac82069134cc314fa0abeb860cdc74
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5062834
Reviewed-by: Simon Ziegltrum <ziegltrum@google.com>
Commit-Queue: Danila Kuzmin <dkuzmin@google.com>
Cr-Commit-Position: refs/heads/main@{#1240222}
diff --git a/chrome/browser/resources/chromeos/login/login.gni b/chrome/browser/resources/chromeos/login/login.gni
index e95fdc4..b94b12c 100644
--- a/chrome/browser/resources/chromeos/login/login.gni
+++ b/chrome/browser/resources/chromeos/login/login.gni
@@ -75,18 +75,6 @@
   "components/quick_start_pin.js",
   "components/security_token_pin.js",
   "components/throbber_notice.js",
-  "screens/osauth/apply_online_password.js",
-  "screens/osauth/cryptohome_recovery.js",
-  "screens/osauth/cryptohome_recovery_setup.js",
-  "screens/osauth/factor_setup_success.js",
-  "screens/osauth/fingerprint_setup.js",
-  "screens/osauth/gaia_password_changed.js",
-  "screens/osauth/local_password_setup.js",
-  "screens/osauth/local_data_loss_warning.js",
-  "screens/osauth/enter_old_password.js",
-  "screens/osauth/osauth_error.js",
-  "screens/osauth/password_selection.js",
-  "screens/osauth/pin_setup.js",
 ]
 
 oobe_screens_js_files = [
@@ -212,6 +200,32 @@
   login_screens_html_wrapped_files += [ string_replace(f, ".html", ".html.js") ]
 }
 
+osauth_screens_js_files = [
+  "screens/osauth/apply_online_password.js",
+  "screens/osauth/cryptohome_recovery.js",
+  "screens/osauth/cryptohome_recovery_setup.js",
+  "screens/osauth/factor_setup_success.js",
+  "screens/osauth/fingerprint_setup.js",
+  "screens/osauth/gaia_password_changed.js",
+  "screens/osauth/local_password_setup.js",
+  "screens/osauth/local_data_loss_warning.js",
+  "screens/osauth/enter_old_password.js",
+  "screens/osauth/osauth_error.js",
+  "screens/osauth/password_selection.js",
+  "screens/osauth/pin_setup.js",
+]
+
+osauth_screens_html_files = []
+foreach(f, osauth_screens_js_files) {
+  osauth_screens_html_files += [ string_replace(f, ".js", ".html") ]
+}
+
+osauth_screens_html_wrapped_files = []
+foreach(f, osauth_screens_html_files) {
+  osauth_screens_html_wrapped_files +=
+      [ string_replace(f, ".html", ".html.js") ]
+}
+
 buttons_ts_files = [
   "components/buttons/oobe_back_button.ts",
   "components/buttons/oobe_icon_button.ts",
@@ -235,4 +249,5 @@
     oobe_screens_js_files + oobe_screens_html_wrapped_files +
     common_screens_js_files + common_screens_html_wrapped_files +
     login_screens_js_files + login_screens_html_wrapped_files +
+    osauth_screens_js_files + osauth_screens_html_wrapped_files +
     buttons_ts_files + buttons_html_wrapped_files
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/BUILD.gn b/chrome/browser/resources/chromeos/login/screens/osauth/BUILD.gn
index 87bc30bd..890d139 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/BUILD.gn
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/BUILD.gn
@@ -4,7 +4,8 @@
 
 import("//chrome/common/features.gni")
 import("//third_party/closure_compiler/compile_js.gni")
-import("//tools/polymer/html_to_js.gni")
+import("//tools/polymer/html_to_wrapper.gni")
+import("../../login.gni")
 
 js_type_check("closure_compile") {
   is_polymer3 = true
@@ -189,19 +190,19 @@
   extra_sources = [ "$interfaces_path/quick_unlock_private_interface.js" ]
 }
 
-html_to_js("web_components") {
-  js_files = [
-    "apply_online_password.js",
-    "cryptohome_recovery.js",
-    "cryptohome_recovery_setup.js",
-    "factor_setup_success.js",
-    "fingerprint_setup.js",
-    "gaia_password_changed.js",
-    "local_data_loss_warning.js",
-    "enter_old_password.js",
-    "local_password_setup.js",
-    "osauth_error.js",
-    "password_selection.js",
-    "pin_setup.js",
+group("web_components") {
+  public_deps = [
+    ":copy_js",
+    ":generate_web_component_html_wrapper_files",
   ]
 }
+
+html_to_wrapper("generate_web_component_html_wrapper_files") {
+  in_files = rebase_path(osauth_screens_html_files, "./screens/osauth", ".")
+  use_js = true
+}
+
+copy("copy_js") {
+  sources = rebase_path(osauth_screens_js_files, "./screens/osauth", ".")
+  outputs = [ "$target_gen_dir/{{source_file_part}}" ]
+}
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/apply_online_password.js b/chrome/browser/resources/chromeos/login/screens/osauth/apply_online_password.js
index 5e081d3..6d6cee1 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/apply_online_password.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/apply_online_password.js
@@ -14,6 +14,8 @@
 import {OobeDialogHostBehavior} from '../../components/behaviors/oobe_dialog_host_behavior.js';
 import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.js';
 
+import {getTemplate} from './apply_online_password.html.js';
+
 /**
  * @constructor
  * @extends {PolymerElement}
@@ -37,7 +39,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/cryptohome_recovery.js b/chrome/browser/resources/chromeos/login/screens/osauth/cryptohome_recovery.js
index 44b4541..064d80c 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/cryptohome_recovery.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/cryptohome_recovery.js
@@ -16,6 +16,8 @@
 import {MultiStepBehavior, MultiStepBehaviorInterface} from '../../components/behaviors/multi_step_behavior.js';
 import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.js';
 
+import {getTemplate} from './cryptohome_recovery.html.js';
+
 /**
  * UI mode for the dialog.
  * @enum {string}
@@ -46,7 +48,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/cryptohome_recovery_setup.js b/chrome/browser/resources/chromeos/login/screens/osauth/cryptohome_recovery_setup.js
index 63152a7..451ef66 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/cryptohome_recovery_setup.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/cryptohome_recovery_setup.js
@@ -16,6 +16,8 @@
 import {MultiStepBehavior, MultiStepBehaviorInterface} from '../../components/behaviors/multi_step_behavior.js';
 import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.js';
 
+import {getTemplate} from './cryptohome_recovery_setup.html.js';
+
 /**
  * UI mode for the dialog.
  * @enum {string}
@@ -44,7 +46,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/enter_old_password.js b/chrome/browser/resources/chromeos/login/screens/osauth/enter_old_password.js
index 98a219cb..d2ac60d 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/enter_old_password.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/enter_old_password.js
@@ -23,6 +23,8 @@
 import {OOBE_UI_STATE} from '../../components/display_manager_types.js';
 import {addSubmitListener} from '../../login_ui_tools.js';
 
+import {getTemplate} from './enter_old_password.html.js';
+
 
 /**
  * UI mode for the dialog.
@@ -59,7 +61,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/factor_setup_success.js b/chrome/browser/resources/chromeos/login/screens/osauth/factor_setup_success.js
index fb5c9222..37c6fcc 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/factor_setup_success.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/factor_setup_success.js
@@ -21,6 +21,8 @@
 import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.js';
 import {OOBE_UI_STATE} from '../../components/display_manager_types.js';
 
+import {getTemplate} from './factor_setup_success.html.js';
+
 /**
  * @constructor
  * @extends {PolymerElement}
@@ -67,7 +69,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
 
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/fingerprint_setup.js b/chrome/browser/resources/chromeos/login/screens/osauth/fingerprint_setup.js
index 7ce2f7b..b82be16 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/fingerprint_setup.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/fingerprint_setup.js
@@ -25,6 +25,8 @@
 import {OOBE_UI_STATE, SCREEN_GAIA_SIGNIN} from '../../components/display_manager_types.js';
 import {OobeCrLottie} from '../../components/oobe_cr_lottie.js';
 
+import {getTemplate} from './fingerprint_setup.html.js';
+
 
 /**
  * These values must be kept in sync with the values in
@@ -85,7 +87,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/gaia_password_changed.js b/chrome/browser/resources/chromeos/login/screens/osauth/gaia_password_changed.js
index 1858420..4ce3eea1 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/gaia_password_changed.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/gaia_password_changed.js
@@ -27,6 +27,8 @@
 import {OOBE_UI_STATE} from '../../components/display_manager_types.js';
 import {addSubmitListener} from '../../login_ui_tools.js';
 
+import {getTemplate} from './gaia_password_changed.html.js';
+
 
 /**
  * UI mode for the dialog.
@@ -74,7 +76,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/local_data_loss_warning.js b/chrome/browser/resources/chromeos/login/screens/osauth/local_data_loss_warning.js
index ca67371..2f5b4b9 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/local_data_loss_warning.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/local_data_loss_warning.js
@@ -22,6 +22,8 @@
 import {OOBE_UI_STATE} from '../../components/display_manager_types.js';
 import {addSubmitListener} from '../../login_ui_tools.js';
 
+import {getTemplate} from './local_data_loss_warning.html.js';
+
 /**
  * @constructor
  * @extends {PolymerElement}
@@ -41,7 +43,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/local_password_setup.js b/chrome/browser/resources/chromeos/login/screens/osauth/local_password_setup.js
index e52b940d..5af21a5 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/local_password_setup.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/local_password_setup.js
@@ -26,6 +26,8 @@
 import {OobeTypes} from '../../components/oobe_types.js';
 import {addSubmitListener} from '../../login_ui_tools.js';
 
+import {getTemplate} from './local_password_setup.html.js';
+
 
 /**
  * UI mode for the dialog.
@@ -69,7 +71,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/osauth_error.js b/chrome/browser/resources/chromeos/login/screens/osauth/osauth_error.js
index 84942ba..7078a63f 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/osauth_error.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/osauth_error.js
@@ -21,6 +21,8 @@
 import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.js';
 import {OOBE_UI_STATE} from '../../components/display_manager_types.js';
 
+import {getTemplate} from './osauth_error.html.js';
+
 /**
  * @constructor
  * @extends {PolymerElement}
@@ -40,7 +42,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
 
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/password_selection.js b/chrome/browser/resources/chromeos/login/screens/osauth/password_selection.js
index 37c37c0..feef9870 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/password_selection.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/password_selection.js
@@ -18,6 +18,8 @@
 import {OobeDialogHostBehavior} from '../../components/behaviors/oobe_dialog_host_behavior.js';
 import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.js';
 
+import {getTemplate} from './password_selection.html.js';
+
 /**
  * Type of the password for setting up for the user.
  * @enum {string}
@@ -61,7 +63,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {
diff --git a/chrome/browser/resources/chromeos/login/screens/osauth/pin_setup.js b/chrome/browser/resources/chromeos/login/screens/osauth/pin_setup.js
index 0d4be9f..6fd7fb5 100644
--- a/chrome/browser/resources/chromeos/login/screens/osauth/pin_setup.js
+++ b/chrome/browser/resources/chromeos/login/screens/osauth/pin_setup.js
@@ -25,6 +25,8 @@
 import {OOBE_UI_STATE, SCREEN_GAIA_SIGNIN} from '../../components/display_manager_types.js';
 import {OobeTypes} from '../../components/oobe_types.js';
 
+import {getTemplate} from './pin_setup.html.js';
+
 
 const PinSetupState = {
   START: 'start',
@@ -51,7 +53,7 @@
   }
 
   static get template() {
-    return html`{__html_template__}`;
+    return getTemplate();
   }
 
   static get properties() {