Commit 20c703b7 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Downloads: Use preprocessing to generate rollup input

Note: This CL also demonstrates using a 3rd preprocess_grit target to
preprocess and copy the downloads mojo file to the desired relative
location in the preprocessed folder. This allows it to be included in
the bundle generated by rollup.

Bug: 1128583
Change-Id: I5a6e9825ba82110f1df4b5193dc21a8ef6178d78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414564
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808223}
parent 0d60f632
......@@ -4,58 +4,62 @@
import("//chrome/common/features.gni")
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/preprocess_grit.gni")
import("//tools/polymer/html_to_js.gni")
import("../optimize_webui.gni")
if (optimize_webui) {
downloads_pak_file = "downloads_resources.pak"
unpak_folder = "downloads_resources.unpak"
preprocess_folder = "preprocess"
optimize_webui("build") {
host = "downloads"
input = rebase_path("$target_gen_dir/$unpak_folder", root_build_dir)
input = rebase_path("$target_gen_dir/$preprocess_folder", root_build_dir)
js_out_files = [ "downloads.rollup.js" ]
js_module_in_files = [ "downloads.js" ]
excludes = [
"chrome://resources/js/cr.m.js",
"chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js",
"downloads.mojom-lite.js",
]
deps = [
":unpak",
":preprocess",
":preprocess_generated",
":preprocess_mojo",
"../../../../ui/webui/resources:preprocess",
]
}
unpak("unpak") {
pak_file = downloads_pak_file
out_folder = unpak_folder
excludes = [ "../../ui/webui/downloads/downloads.mojom-lite.js" ]
deps = [ ":flattened_resources" ]
preprocess_grit("preprocess") {
in_folder = "./"
out_folder = "$target_gen_dir/$preprocess_folder"
in_files = [
"browser_proxy.js",
"constants.js",
"downloads.js",
"externs.js",
"icon_loader.js",
"search_service.js",
]
}
grit("flattened_resources") {
source = "downloads_resources.grd"
defines = chrome_grit_defines
outputs = [
"grit/downloads_resources.h",
"grit/downloads_resources_map.cc",
"grit/downloads_resources_map.h",
downloads_pak_file,
preprocess_grit("preprocess_generated") {
deps = [ ":web_components" ]
in_folder = target_gen_dir
out_folder = "$target_gen_dir/$preprocess_folder"
in_files = [
"icons.js",
"item.js",
"manager.js",
"toolbar.js",
]
deps = [
":web_components",
"//chrome/browser/ui/webui/downloads:mojo_bindings_js",
]
grit_flags = [
"-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
}
copy("preprocess_mojo") {
deps = [ "//chrome/browser/ui/webui/downloads:mojo_bindings_js" ]
sources = [
"$root_gen_dir/chrome/browser/ui/webui/downloads/downloads.mojom-lite.js",
]
output_dir = "$root_gen_dir/chrome/browser/resources/downloads"
outputs = [ "$target_gen_dir/$preprocess_folder/downloads.mojom-lite.js" ]
}
}
......
......@@ -14,64 +14,51 @@
<includes>
<include name="IDR_DOWNLOADS_IMAGES_INCOGNITO_MARKER_SVG"
file="images\incognito_marker.svg"
compress="false"
type="BINDATA" />
<include name="IDR_DOWNLOADS_IMAGES_NO_DOWNLOADS_SVG"
file="images\no_downloads.svg"
compress="false"
type="BINDATA" />
<include name="IDR_DOWNLOADS_MOJO_LITE_JS"
file="${root_gen_dir}\chrome\browser\ui\webui\downloads\downloads.mojom-lite.js"
use_base_dir="false"
compress="false"
type="chrome_html" />
<include name="IDR_DOWNLOADS_MANAGER_JS"
file="${root_gen_dir}\chrome\browser\resources\downloads\manager.js"
use_base_dir="false"
preprocess="true"
compress="false"
type="chrome_html" />
<include name="IDR_DOWNLOADS_ITEM_JS"
file="${root_gen_dir}\chrome\browser\resources\downloads\item.js"
use_base_dir="false"
compress="false"
type="chrome_html" />
<include name="IDR_DOWNLOADS_TOOLBAR_JS"
file="${root_gen_dir}\chrome\browser\resources\downloads\toolbar.js"
use_base_dir="false"
compress="false"
type="chrome_html" />
<include name="IDR_DOWNLOADS_ICONS_JS"
file="${root_gen_dir}\chrome\browser\resources\downloads\icons.js"
use_base_dir="false"
compress="false"
type="chrome_html" />
</includes>
<structures>
<structure name="IDR_DOWNLOADS_DOWNLOADS_HTML"
file="downloads.html"
preprocess="true"
compress="false"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_BROWSER_PROXY_JS"
file="browser_proxy.js"
compress="false"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_CONSTANTS_JS"
file="constants.js"
compress="false"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_DOWNLOADS_JS"
file="downloads.js"
compress="false"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_ICON_LOADER_JS"
file="icon_loader.js"
compress="false"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_SEARCH_SERVICE_JS"
file="search_service.js"
compress="false"
type="chrome_html" />
</structures>
</release>
......
......@@ -18,10 +18,6 @@
<include name="IDR_DOWNLOADS_IMAGES_NO_DOWNLOADS_SVG"
file="images\no_downloads.svg"
type="BINDATA" />
<include name="IDR_DOWNLOADS_MOJO_LITE_JS"
file="${root_gen_dir}\chrome\browser\ui\webui\downloads\downloads.mojom-lite.js"
use_base_dir="false"
type="BINDATA" />
<include name="IDR_DOWNLOADS_DOWNLOADS_HTML"
file="downloads.html"
preprocess="true"
......
......@@ -167,8 +167,10 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
IDR_DOWNLOADS_IMAGES_INCOGNITO_MARKER_SVG);
source->AddResourcePath("images/no_downloads.svg",
IDR_DOWNLOADS_IMAGES_NO_DOWNLOADS_SVG);
#if !BUILDFLAG(OPTIMIZE_WEBUI)
source->AddResourcePath("downloads.mojom-lite.js",
IDR_DOWNLOADS_MOJO_LITE_JS);
#endif
source->AddBoolean(
"allowOpenNow",
......
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