# Copyright 2022 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//chrome/common/features.gni")
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/preprocess_if_expr.gni")
import("//tools/polymer/css_to_wrapper.gni")
import("//tools/polymer/html_to_js.gni")
import("//tools/polymer/html_to_wrapper.gni")
import("//ui/webui/resources/tools/generate_grd.gni")
assert(is_chromeos_ash, "Only available in ash Chrome.")
###################
#### RESOURCES ####
###################
grit("resources") {
defines = chrome_grit_defines
# This is necessary since the GRD is generated during build time.
enable_input_discovery_for_gn_analyze = false
source = "$target_gen_dir/assistant_optin_resources.grd"
deps = [ ":build_grd" ]
outputs = [
"grit/assistant_optin_resources.h",
"grit/assistant_optin_resources_map.h",
"grit/assistant_optin_resources_map.cc",
"assistant_optin_resources.pak",
]
output_dir = "$root_gen_dir/chrome"
}
########################
#### GRD GENERATION ####
########################
existing_files_manifest = "existing_files_manifest.json"
web_components_manifest = "web_components_manifest.json"
preprocessed_folder = "assistant_optin_preprocessed"
generate_grd("build_grd") {
grd_prefix = "assistant_optin"
out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
deps = [
":preprocess",
":preprocess_gen_js_files",
]
manifest_files = [
"$target_gen_dir/$existing_files_manifest",
"$target_gen_dir/$web_components_manifest",
]
input_files_base_dir = rebase_path(".", "//")
input_files = [
"voice_laptop.json",
"voice_tablet.json",
]
resource_path_prefix = "assistant_optin"
}
# Preprocess existing files.
preprocess_if_expr("preprocess") {
out_folder = "$target_gen_dir/$preprocessed_folder"
out_manifest = "$target_gen_dir/$existing_files_manifest"
in_files = [
"assistant_optin.html",
"assistant_optin.js",
"browser_proxy.js",
"utils.js",
]
}
# Preprocess autogenerated files
preprocess_if_expr("preprocess_gen_js_files") {
defines = chrome_grit_defines
deps = [
":css_wrapper_files",
":html_wrapper_files",
":web_components",
]
in_folder = target_gen_dir
out_folder = "$target_gen_dir/$preprocessed_folder"
out_manifest = "$target_gen_dir/$web_components_manifest"
in_files = [
"assistant_common_styles.css.js",
"assistant_icons.html.js",
"assistant_loading.js",
"assistant_optin_flow.js",
"assistant_related_info.js",
"assistant_value_prop.js",
"assistant_voice_match.js",
"setting_zippy.js",
"voice_match_entry.js",
]
}
#############################
#### CLOSURE COMPILATION ####
#############################
js_type_check("closure_compile") {
is_polymer3 = true
closure_flags = default_closure_args
deps = [
":assistant_common_styles.css",
":assistant_icons.html",
":browser_proxy",
":voice_match_entry",
]
}
js_library("assistant_common_styles.css") {
sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/assistant_optin/assistant_common_styles.css.js" ]
deps = [
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
extra_deps = [ ":css_wrapper_files" ]
}
js_library("assistant_icons.html") {
sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/assistant_optin/assistant_icons.html.js" ]
deps = [
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
extra_deps = [ ":html_wrapper_files" ]
}
js_library("voice_match_entry") {
sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/assistant_optin/voice_match_entry.js" ]
deps = [
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
extra_deps = [ ":web_components" ]
}
js_library("browser_proxy") {
externs_list = [ "$externs_path/chrome_send.js" ]
}
##########################
#### POLYMER3 MODULES ####
##########################
html_to_js("web_components") {
js_files = [
"assistant_loading.js",
"assistant_optin_flow.js",
"assistant_related_info.js",
"assistant_value_prop.js",
"assistant_voice_match.js",
"setting_zippy.js",
"voice_match_entry.js",
]
}
css_to_wrapper("css_wrapper_files") {
in_files = [ "assistant_common_styles.css" ]
use_js = true
}
html_to_wrapper("html_wrapper_files") {
in_files = [ "assistant_icons.html" ]
use_js = true
}