Commit f29defcf authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: autogenerate grd for optimized build

Last portion of a rebase of:
https://chromium-review.googlesource.com/c/chromium/src/+/2443211
by dpapad@
onto the addition of a new resource_path grit property.

This CL updates Print Preview to use the new manifest generation
option in optimize_webui, combined with the resource_path grit
property and generate_grd changes, to autogenerate the grd file
in optimized builds.

Bug: 1132403
Change-Id: I8f03064bbacd0ce993f59cf008ee27112d1934cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2458878
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816217}
parent c92ce91f
......@@ -590,21 +590,19 @@ if (enable_print_preview) {
grit_flags = [
"-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
"-E",
"root_src_dir=" + rebase_path("//", root_build_dir),
]
defines = chrome_grit_defines
if (optimize_webui) {
source = "print_preview/print_preview_resources_vulcanized.grd"
deps = [ "//chrome/browser/resources/print_preview:build" ]
} else {
# These arguments are needed since the grd is generated at build time.
enable_input_discovery_for_gn_analyze = false
defines += [ "SHARED_INTERMEDIATE_DIR=" +
rebase_path(root_gen_dir, root_build_dir) ]
print_gen_dir = "$root_gen_dir/chrome/browser/resources/print_preview"
source = "$print_gen_dir/print_preview_resources.grd"
deps = [ "//chrome/browser/resources/print_preview:build_grd" ]
}
# These arguments are needed since the grd is generated at build time.
enable_input_discovery_for_gn_analyze = false
defines += [ "SHARED_INTERMEDIATE_DIR=" +
rebase_path(root_gen_dir, root_build_dir) ]
print_gen_dir = "$root_gen_dir/chrome/browser/resources/print_preview"
source = "$print_gen_dir/print_preview_resources.grd"
deps = [ "//chrome/browser/resources/print_preview:build_grd" ]
outputs = [
"grit/print_preview_resources.h",
......
......@@ -13,11 +13,14 @@ preprocess_manifest = "preprocessed_manifest.json"
preprocess_gen_manifest = "preprocessed_gen_manifest.json"
if (optimize_webui) {
build_manifest = "build_manifest.json"
optimize_webui("build") {
host = "print"
input = rebase_path("$target_gen_dir/$preprocess_folder", root_build_dir)
js_out_files = [ "print_preview.rollup.js" ]
js_module_in_files = [ "print_preview.js" ]
out_manifest = "$target_gen_dir/$build_manifest"
deps = [
":preprocess",
......@@ -29,8 +32,15 @@ if (optimize_webui) {
"pdf/pdf_scripting_api.js",
]
}
} else {
generate_grd("build_grd") {
}
generate_grd("build_grd") {
input_files = [ "print_preview.html" ]
input_files_base_dir = rebase_path(".", "//")
if (optimize_webui) {
deps = [ ":build" ]
manifest_files = [ "$target_gen_dir/$build_manifest" ]
} else {
deps = [
":preprocess",
":preprocess_generated",
......@@ -39,9 +49,9 @@ if (optimize_webui) {
"$target_gen_dir/$preprocess_manifest",
"$target_gen_dir/$preprocess_gen_manifest",
]
grd_prefix = "print_preview"
out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
}
grd_prefix = "print_preview"
out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
}
preprocess_grit("preprocess") {
......@@ -49,7 +59,6 @@ preprocess_grit("preprocess") {
out_folder = "$target_gen_dir/$preprocess_folder"
out_manifest = "$target_gen_dir/$preprocess_manifest"
in_files = [
"print_preview.html",
"cloud_print_interface.js",
"cloud_print_interface_impl.js",
"dark_mode_behavior.js",
......
<?xml version="1.0" encoding="UTF-8"?>
<grit latest_public_release="0" current_release="1" output_all_resource_defines="false">
<outputs>
<output filename="grit/print_preview_resources.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="grit/print_preview_resources_map.cc"
type="resource_map_source" />
<output filename="grit/print_preview_resources_map.h"
type="resource_map_header" />
<output filename="print_preview_resources.pak" type="data_package" />
</outputs>
<release seq="1">
<includes>
<include name="IDR_PRINT_PREVIEW_PRINT_PREVIEW_HTML"
file="print_preview.html"
type="chrome_html" />
<include name="IDR_PRINT_PREVIEW_PRINT_PREVIEW_ROLLUP_JS"
file="${root_gen_dir}\chrome\browser\resources\print_preview\print_preview.rollup.js"
use_base_dir="false"
type="BINDATA" />
</includes>
</release>
</grit>
......@@ -466,16 +466,10 @@ void SetupPrintPreviewPlugin(content::WebUIDataSource* source) {
content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIPrintHost);
#if BUILDFLAG(OPTIMIZE_WEBUI)
webui::SetupBundledWebUIDataSource(source, "print_preview.js",
IDR_PRINT_PREVIEW_PRINT_PREVIEW_ROLLUP_JS,
IDR_PRINT_PREVIEW_PRINT_PREVIEW_HTML);
#else
webui::SetupWebUIDataSource(
source,
base::make_span(kPrintPreviewResources, kPrintPreviewResourcesSize), "",
IDR_PRINT_PREVIEW_PRINT_PREVIEW_HTML);
#endif
AddPrintPreviewStrings(source);
SetupPrintPreviewPlugin(source);
AddPrintPreviewFlags(source, profile);
......
......@@ -168,9 +168,6 @@
"chrome/browser/resources/new_tab_page/new_tab_page_resources.grd": {
"includes": [1680],
},
"chrome/browser/resources/print_preview/print_preview_resources_vulcanized.grd": {
"includes": [1700],
},
"<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/print_preview/print_preview_resources.grd": {
"META": {"sizes": {"includes": [500],}},
"includes": [1720],
......
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