Commit 83f96b38 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Downloads: Autogenerate grd files

Bug: 1132403
Change-Id: I282c778d5f8bd3368bd894fcfc5b0239e6c1794d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469284
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817173}
parent 94ae480b
...@@ -299,23 +299,23 @@ if (!is_android) { ...@@ -299,23 +299,23 @@ if (!is_android) {
} }
grit("downloads_resources") { grit("downloads_resources") {
if (optimize_webui) {
source = "downloads/downloads_resources_vulcanized.grd"
deps = [ "//chrome/browser/resources/downloads:build" ]
} else {
source = "downloads/downloads_resources.grd"
deps = [ "//chrome/browser/resources/downloads:web_components" ]
}
deps += [ "//chrome/browser/ui/webui/downloads:mojo_bindings_js" ]
grit_flags = [ grit_flags = [
"-E", "-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir), "root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
"-E",
"root_src_dir=" + rebase_path("//", root_build_dir),
] ]
defines = chrome_grit_defines defines = chrome_grit_defines
# 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) ]
downloads_gen_dir = "$root_gen_dir/chrome/browser/resources/downloads"
source = "$downloads_gen_dir/downloads_resources.grd"
deps = [ "//chrome/browser/resources/downloads:build_grd" ]
outputs = [ outputs = [
"grit/downloads_resources.h", "grit/downloads_resources.h",
"grit/downloads_resources_map.cc", "grit/downloads_resources_map.cc",
......
...@@ -6,16 +6,23 @@ import("//chrome/common/features.gni") ...@@ -6,16 +6,23 @@ import("//chrome/common/features.gni")
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//tools/grit/preprocess_grit.gni") import("//tools/grit/preprocess_grit.gni")
import("//tools/polymer/html_to_js.gni") import("//tools/polymer/html_to_js.gni")
import("//ui/webui/resources/tools/generate_grd.gni")
import("../optimize_webui.gni") import("../optimize_webui.gni")
preprocess_folder = "preprocessed"
preprocess_manifest = "preprocessed_manifest.json"
preprocess_web_components_manifest = "preprocessed_gen_manifest.json"
preprocess_mojo_manifest = "preprocessed_mojo_manifest.json"
if (optimize_webui) { if (optimize_webui) {
preprocess_folder = "preprocess" build_manifest = "build_manifest.json"
optimize_webui("build") { optimize_webui("build") {
host = "downloads" host = "downloads"
input = rebase_path("$target_gen_dir/$preprocess_folder", root_build_dir) input = rebase_path("$target_gen_dir/$preprocess_folder", root_build_dir)
js_out_files = [ "downloads.rollup.js" ] js_out_files = [ "downloads.rollup.js" ]
js_module_in_files = [ "downloads.js" ] js_module_in_files = [ "downloads.js" ]
out_manifest = "$target_gen_dir/$build_manifest"
excludes = [ excludes = [
"chrome://resources/js/cr.m.js", "chrome://resources/js/cr.m.js",
"chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js", "chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js",
...@@ -23,15 +30,43 @@ if (optimize_webui) { ...@@ -23,15 +30,43 @@ if (optimize_webui) {
deps = [ deps = [
":preprocess", ":preprocess",
":preprocess_generated",
":preprocess_mojo", ":preprocess_mojo",
":preprocess_web_components",
"../../../../ui/webui/resources:preprocess", "../../../../ui/webui/resources:preprocess",
] ]
} }
}
generate_grd("build_grd") {
input_files = [
"downloads.html",
"images/incognito_marker.svg",
"images/no_downloads.svg",
]
input_files_base_dir = rebase_path(".", "//")
if (optimize_webui) {
deps = [ ":build" ]
manifest_files = [ "$target_gen_dir/$build_manifest" ]
} else {
deps = [
":preprocess",
":preprocess_mojo",
":preprocess_web_components",
]
manifest_files = [
"$target_gen_dir/$preprocess_manifest",
"$target_gen_dir/$preprocess_web_components_manifest",
"$target_gen_dir/$preprocess_mojo_manifest",
]
}
grd_prefix = "downloads"
out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
}
preprocess_grit("preprocess") { preprocess_grit("preprocess") {
in_folder = "./" in_folder = "./"
out_folder = "$target_gen_dir/$preprocess_folder" out_folder = "$target_gen_dir/$preprocess_folder"
out_manifest = "$target_gen_dir/$preprocess_manifest"
in_files = [ in_files = [
"browser_proxy.js", "browser_proxy.js",
"constants.js", "constants.js",
...@@ -40,27 +75,27 @@ if (optimize_webui) { ...@@ -40,27 +75,27 @@ if (optimize_webui) {
"icon_loader.js", "icon_loader.js",
"search_service.js", "search_service.js",
] ]
} }
preprocess_grit("preprocess_generated") { preprocess_grit("preprocess_web_components") {
deps = [ ":web_components" ] deps = [ ":web_components" ]
in_folder = target_gen_dir in_folder = target_gen_dir
out_folder = "$target_gen_dir/$preprocess_folder" out_folder = "$target_gen_dir/$preprocess_folder"
out_manifest = "$target_gen_dir/$preprocess_web_components_manifest"
in_files = [ in_files = [
"icons.js", "icons.js",
"item.js", "item.js",
"manager.js", "manager.js",
"toolbar.js", "toolbar.js",
] ]
} }
copy("preprocess_mojo") { preprocess_grit("preprocess_mojo") {
deps = [ "//chrome/browser/ui/webui/downloads:mojo_bindings_js" ] deps = [ "//chrome/browser/ui/webui/downloads:mojo_bindings_js" ]
sources = [ in_folder = get_path_info("../../ui/webui/downloads/", "gen_dir")
"$root_gen_dir/chrome/browser/ui/webui/downloads/downloads.mojom-lite.js", out_folder = "$target_gen_dir/$preprocess_folder"
] out_manifest = "$target_gen_dir/$preprocess_mojo_manifest"
outputs = [ "$target_gen_dir/$preprocess_folder/downloads.mojom-lite.js" ] in_files = [ "downloads.mojom-lite.js" ]
}
} }
js_type_check("closure_compile") { js_type_check("closure_compile") {
......
<?xml version="1.0" encoding="UTF-8"?>
<grit latest_public_release="0" current_release="1" output_all_resource_defines="false">
<outputs>
<output filename="grit/downloads_resources.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="grit/downloads_resources_map.cc"
type="resource_file_map_source" />
<output filename="grit/downloads_resources_map.h"
type="resource_map_header" />
<output filename="downloads_resources.pak" type="data_package" />
</outputs>
<release seq="1">
<includes>
<include name="IDR_DOWNLOADS_IMAGES_INCOGNITO_MARKER_SVG"
file="images\incognito_marker.svg"
type="BINDATA" />
<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="chrome_html" />
<include name="IDR_DOWNLOADS_MANAGER_JS"
file="${root_gen_dir}\chrome\browser\resources\downloads\manager.js"
use_base_dir="false"
preprocess="true"
type="chrome_html" />
<include name="IDR_DOWNLOADS_ITEM_JS"
file="${root_gen_dir}\chrome\browser\resources\downloads\item.js"
use_base_dir="false"
type="chrome_html" />
<include name="IDR_DOWNLOADS_TOOLBAR_JS"
file="${root_gen_dir}\chrome\browser\resources\downloads\toolbar.js"
use_base_dir="false"
type="chrome_html" />
<include name="IDR_DOWNLOADS_ICONS_JS"
file="${root_gen_dir}\chrome\browser\resources\downloads\icons.js"
use_base_dir="false"
type="chrome_html" />
</includes>
<structures>
<structure name="IDR_DOWNLOADS_DOWNLOADS_HTML"
file="downloads.html"
preprocess="true"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_BROWSER_PROXY_JS"
file="browser_proxy.js"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_CONSTANTS_JS"
file="constants.js"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_DOWNLOADS_JS"
file="downloads.js"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_ICON_LOADER_JS"
file="icon_loader.js"
type="chrome_html" />
<structure name="IDR_DOWNLOADS_SEARCH_SERVICE_JS"
file="search_service.js"
type="chrome_html" />
</structures>
</release>
</grit>
<?xml version="1.0" encoding="UTF-8"?>
<grit latest_public_release="0" current_release="1" output_all_resource_defines="false">
<outputs>
<output filename="grit/downloads_resources.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="grit/downloads_resources_map.cc"
type="resource_map_source" />
<output filename="grit/downloads_resources_map.h"
type="resource_map_header" />
<output filename="downloads_resources.pak" type="data_package" />
</outputs>
<release seq="1">
<includes>
<include name="IDR_DOWNLOADS_IMAGES_INCOGNITO_MARKER_SVG"
file="images\incognito_marker.svg"
type="BINDATA" />
<include name="IDR_DOWNLOADS_IMAGES_NO_DOWNLOADS_SVG"
file="images\no_downloads.svg"
type="BINDATA" />
<include name="IDR_DOWNLOADS_DOWNLOADS_HTML"
file="downloads.html"
preprocess="true"
type="chrome_html" />
<include name="IDR_DOWNLOADS_DOWNLOADS_ROLLUP_JS"
file="${root_gen_dir}\chrome\browser\resources\downloads\downloads.rollup.js"
use_base_dir="false"
type="BINDATA" />
</includes>
</release>
</grit>
...@@ -53,24 +53,12 @@ using content::WebContents; ...@@ -53,24 +53,12 @@ using content::WebContents;
namespace { namespace {
#if !BUILDFLAG(OPTIMIZE_WEBUI)
constexpr char kGeneratedPath[] =
"@out_folder@/gen/chrome/browser/resources/downloads/";
#endif
content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) { content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
content::WebUIDataSource* source = content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIDownloadsHost); content::WebUIDataSource::Create(chrome::kChromeUIDownloadsHost);
#if BUILDFLAG(OPTIMIZE_WEBUI)
webui::SetupBundledWebUIDataSource(source, "downloads.js",
IDR_DOWNLOADS_DOWNLOADS_ROLLUP_JS,
IDR_DOWNLOADS_DOWNLOADS_HTML);
#else
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, base::make_span(kDownloadsResources, kDownloadsResourcesSize), source, base::make_span(kDownloadsResources, kDownloadsResourcesSize), "",
kGeneratedPath, IDR_DOWNLOADS_DOWNLOADS_HTML); IDR_DOWNLOADS_DOWNLOADS_HTML);
#endif
bool requests_ap_verdicts = bool requests_ap_verdicts =
safe_browsing::AdvancedProtectionStatusManagerFactory::GetForProfile( safe_browsing::AdvancedProtectionStatusManagerFactory::GetForProfile(
...@@ -163,15 +151,6 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) { ...@@ -163,15 +151,6 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
source->AddLocalizedString("inIncognito", IDS_DOWNLOAD_IN_INCOGNITO); source->AddLocalizedString("inIncognito", IDS_DOWNLOAD_IN_INCOGNITO);
source->AddResourcePath("images/incognito_marker.svg",
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( source->AddBoolean(
"allowOpenNow", "allowOpenNow",
!enterprise_connectors::ConnectorsManager::GetInstance() !enterprise_connectors::ConnectorsManager::GetInstance()
......
...@@ -124,12 +124,9 @@ ...@@ -124,12 +124,9 @@
"includes": [1420], "includes": [1420],
"structures": [1440], "structures": [1440],
}, },
"chrome/browser/resources/downloads/downloads_resources_vulcanized.grd": { "<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/downloads/downloads_resources.grd": {
"includes": [1460], "META": {"sizes": {"includes": [50],}},
},
"chrome/browser/resources/downloads/downloads_resources.grd": {
"includes": [1480], "includes": [1480],
"structures": [1500],
}, },
"<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/extensions/extensions_resources.grd": { "<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/extensions/extensions_resources.grd": {
"META": {"sizes": {"includes": [50],}}, "META": {"sizes": {"includes": [50],}},
......
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