Commit 6b8d9984 authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

Remove unnecessary html files in print management build resources

- Polymer3 does not require html files in its build resources.
- Streamlined adding new resource files for print management.

Bug: 1053704
Change-Id: If9c993aec0380315058296cfc83f90623e5b5871
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2259137
Commit-Queue: Jimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784230}
parent 566022c6
......@@ -10,6 +10,7 @@
#include "chromeos/components/print_management/url_constants.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/grit/chromeos_print_management_resources.h"
#include "chromeos/grit/chromeos_print_management_resources_map.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
......@@ -22,6 +23,26 @@ namespace chromeos {
namespace printing {
namespace printing_manager {
namespace {
constexpr char kGeneratedPath[] =
"@out_folder@/gen/chromeos/components/print_management/resources/";
void SetUpWebUIDataSource(content::WebUIDataSource* source,
base::span<const GritResourceMap> resources,
const std::string& generated_path,
int default_resource) {
for (const auto& resource : resources) {
std::string path = resource.name;
if (path.rfind(generated_path, 0) == 0) {
path = path.substr(generated_path.size());
}
source->AddResourcePath(path, resource.value);
}
source->SetDefaultResource(default_resource);
source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER);
source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER);
}
void AddPrintManagementStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"completionStatusCanceled",
......@@ -83,43 +104,17 @@ PrintManagementUI::PrintManagementUI(
network::mojom::CSPDirectiveName::ScriptSrc,
"script-src chrome://resources chrome://test 'self';");
html_source->AddResourcePath("print_management.js", IDR_PRINT_MANAGEMENT_JS);
html_source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER);
html_source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER);
const auto resources = base::make_span(kChromeosPrintManagementResources,
kChromeosPrintManagementResourcesSize);
SetUpWebUIDataSource(html_source.get(), resources, kGeneratedPath,
IDR_PRINT_MANAGEMENT_INDEX_HTML);
html_source->AddResourcePath("printing_manager.mojom-lite.js",
IDR_PRINTING_MANAGER_MOJO_LITE_JS);
html_source->AddResourcePath("mojo_interface_provider.js",
IDR_PRINT_MANAGEMENT_MOJO_INTERFACE_PROVIDER_JS);
html_source->AddResourcePath("pwa.html", IDR_PRINT_MANAGEMENT_PWA_HTML);
html_source->AddResourcePath("manifest.json", IDR_PRINT_MANAGEMENT_MANIFEST);
html_source->AddResourcePath("printing_app_icon.svg",
IDR_PRINT_MANAGEMENT_ICON);
html_source->AddResourcePath("print_job_entry.html",
IDR_PRINT_MANAGEMENT_PRINT_JOB_ENTRY_HTML);
html_source->AddResourcePath("print_job_entry.js",
IDR_PRINT_MANAGEMENT_PRINT_JOB_ENTRY_JS);
html_source->AddResourcePath("print_management_fonts_css.html",
IDR_PRINT_MANAGEMENT_FONTS_CSS_HTML);
html_source->AddResourcePath("print_management_fonts_css.js",
IDR_PRINT_MANAGEMENT_FONTS_CSS_JS);
html_source->AddResourcePath("print_management_shared_css.html",
IDR_PRINT_MANAGEMENT_SHARED_CSS_HTML);
html_source->AddResourcePath("print_management_shared_css.js",
IDR_PRINT_MANAGEMENT_SHARED_CSS_JS);
html_source->AddResourcePath(
"print_job_clear_history_dialog.html",
IDR_PRINT_MANAGEMENT_PRINT_JOB_CLEAR_HISTORY_DIALOG_HTML);
html_source->AddResourcePath(
"print_job_clear_history_dialog.js",
IDR_PRINT_MANAGEMENT_PRINT_JOB_CLEAR_HISTORY_DIALOG_JS);
html_source->AddResourcePath("icons.html", IDR_PRINT_MANAGEMENT_ICONS_HTML);
html_source->AddResourcePath("icons.js", IDR_PRINT_MANAGEMENT_ICONS_JS);
html_source->SetDefaultResource(IDR_PRINT_MANAGEMENT_INDEX_HTML);
AddPrintManagementStrings(html_source.get());
if (base::FeatureList::IsEnabled(chromeos::features::kScanningUI)) {
html_source->AddResourcePath("scanning.html", IDR_SCANNING_HTML);
html_source->AddResourcePath("scanning_page.js", IDR_SCANNING_PAGE_JS);
}
......
......@@ -5,7 +5,7 @@
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/repack.gni")
import("//tools/polymer/polymer.gni")
import("//tools/polymer/html_to_js.gni")
js_type_check("closure_compile_module") {
is_polymer3 = true
......@@ -64,56 +64,14 @@ js_library("mojo_interface_provider") {
]
}
polymer_modulizer("icons") {
js_file = "icons.js"
html_file = "icons.html"
html_type = "v3-ready"
}
polymer_modulizer("print_management") {
js_file = "print_management.js"
html_file = "print_management.html"
html_type = "v3-ready"
}
polymer_modulizer("print_job_entry") {
js_file = "print_job_entry.js"
html_file = "print_job_entry.html"
html_type = "v3-ready"
}
polymer_modulizer("print_management_shared_css") {
html_file = "print_management_shared_css.html"
js_file = "print_management_shared_css.js"
html_type = "v3-ready"
}
polymer_modulizer("print_management_fonts_css") {
html_file = "print_management_fonts_css.html"
js_file = "print_management_fonts_css.js"
html_type = "v3-ready"
}
polymer_modulizer("print_job_clear_history_dialog") {
html_file = "print_job_clear_history_dialog.html"
js_file = "print_job_clear_history_dialog.js"
html_type = "v3-ready"
}
polymer_modulizer("scanning_page") {
js_file = "scanning_page.js"
html_file = "scanning_page.html"
html_type = "v3-ready"
}
group("polymer3_elements") {
public_deps = [
":icons_module",
":print_job_clear_history_dialog_module",
":print_job_entry_module",
":print_management_fonts_css_module",
":print_management_module",
":print_management_shared_css_module",
":scanning_page_module",
html_to_js("web_components") {
js_files = [
"icons.js",
"print_job_clear_history_dialog.js",
"print_job_entry.js",
"print_management_fonts_css.js",
"print_management.js",
"print_management_shared_css.js",
"scanning_page.js",
]
}
......@@ -13,23 +13,17 @@
<release seq="1">
<includes>
<!-- Privileged app host contents. -->
<include name="IDR_PRINT_MANAGEMENT_ICONS_HTML" file="icons.html" type="BINDATA" />
<include name="IDR_PRINT_MANAGEMENT_ICONS_JS" file="${root_gen_dir}/chromeos/components/print_management/resources/icons.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_INDEX_HTML" file="index.html" type="BINDATA" />
<include name="IDR_PRINT_MANAGEMENT_INDEX_HTML" file="index.html" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_JS" file="${root_gen_dir}/chromeos/components/print_management/resources/print_management.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_PRINT_JOB_ENTRY_HTML" file="print_job_entry.html" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_PRINT_JOB_ENTRY_JS" file="${root_gen_dir}/chromeos/components/print_management/resources/print_job_entry.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_FONTS_CSS_HTML" file="print_management_fonts_css.html" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_FONTS_CSS_JS" file="${root_gen_dir}/chromeos/components/print_management/resources/print_management_fonts_css.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_SHARED_CSS_HTML" file="print_management_shared_css.html" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_SHARED_CSS_JS" file="${root_gen_dir}/chromeos/components/print_management/resources/print_management_shared_css.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_PRINT_JOB_CLEAR_HISTORY_DIALOG_HTML" file="print_job_clear_history_dialog.html" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_PRINT_JOB_CLEAR_HISTORY_DIALOG_JS" file="${root_gen_dir}/chromeos/components/print_management/resources/print_job_clear_history_dialog.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_MANIFEST" file="manifest.json" type="BINDATA" compress="gzip" />
<include name="IDR_PRINT_MANAGEMENT_ICON" file="printing_app_icon.svg" type="BINDATA" />
<include name="IDR_PRINT_MANAGEMENT_MANIFEST" file="manifest.json" type="BINDATA"/>
<include name="IDR_PRINT_MANAGEMENT_ICON" file="printing_app_icon.svg" type="BINDATA"/>
<include name="IDR_PRINTING_MANAGER_MOJO_LITE_JS" file="${root_gen_dir}/chromeos/components/print_management/mojom/printing_manager.mojom-lite.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_PRINT_MANAGEMENT_PWA_HTML" file="pwa.html" type="BINDATA" />
<include name="IDR_SCANNING_HTML" file="scanning.html" type="BINDATA" />
<include name="IDR_SCANNING_PAGE_JS" file="${root_gen_dir}/chromeos/components/print_management/resources/scanning_page.js" use_base_dir="false" type="BINDATA"/>
</includes>
......
......@@ -189,7 +189,7 @@ grit("print_management_resources") {
deps = [
"../components/print_management/mojom:mojom_js",
"../components/print_management/resources:polymer3_elements",
"../components/print_management/resources:web_components",
]
outputs = [
......
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