Commit 14dbbc81 authored by Christopher Lam's avatar Christopher Lam Committed by Commit Bot

Reland "Use grd generation in the Sample System Web App."

This is a reland of 43831226

Original change's description:
> Use grd generation in the Sample System Web App.
>
> Bug: None
> Change-Id: I4485ddbb595ade6ef078abda2436fa887a0d8b7c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2489060
> Commit-Queue: calamity <calamity@chromium.org>
> Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org>
> Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#820135}

Bug: None
Change-Id: I296319fc96965ca36eae58990a3c1018796b8c44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2497900Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821109}
parent 347acbb3
...@@ -24,7 +24,9 @@ std::unique_ptr<WebApplicationInfo> CreateWebAppInfoForSampleSystemWebApp() { ...@@ -24,7 +24,9 @@ std::unique_ptr<WebApplicationInfo> CreateWebAppInfoForSampleSystemWebApp() {
info->title = base::UTF8ToUTF16("Sample System Web App"); info->title = base::UTF8ToUTF16("Sample System Web App");
web_app::CreateIconInfoForSystemWebApp( web_app::CreateIconInfoForSystemWebApp(
info->start_url, info->start_url,
{{"app_icon_192.png", 192, IDR_SAMPLE_SYSTEM_WEB_APP_ICON_192}}, *info); {{"app_icon_192.png", 192,
IDR_CHROMEOS_SAMPLE_SYSTEM_WEB_APP_APP_ICON_192_PNG}},
*info);
info->theme_color = 0xFF4285F4; info->theme_color = 0xFF4285F4;
info->background_color = 0xFFFFFFFF; info->background_color = 0xFFFFFFFF;
info->display_mode = blink::mojom::DisplayMode::kStandalone; info->display_mode = blink::mojom::DisplayMode::kStandalone;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import("//chrome/test/base/js2gtest.gni") import("//chrome/test/base/js2gtest.gni")
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//ui/webui/resources/tools/generate_grd.gni")
assert(is_chromeos, "Sample System Web App is Chrome OS only") assert(is_chromeos, "Sample System Web App is Chrome OS only")
assert(!is_official_build, assert(!is_official_build,
...@@ -40,3 +41,17 @@ js2gtest("browser_tests_js") { ...@@ -40,3 +41,17 @@ js2gtest("browser_tests_js") {
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
} }
generate_grd("build_grd") {
input_files_base_dir = rebase_path("resources", "//")
input_files = [
"app_icon_192.png",
"index.html",
"sandbox.html",
"untrusted.html",
"untrusted.js",
]
manifest_files = []
grd_prefix = "chromeos_sample_system_web_app"
out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
}
<?xml version="1.0" encoding="UTF-8"?>
<grit latest_public_release="0" current_release="1" output_all_resource_defines="false">
<outputs>
<output filename="grit/chromeos_sample_system_web_app_resources.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="grit/chromeos_sample_system_web_app_resources_map.cc"
type="resource_file_map_source" />
<output filename="grit/chromeos_sample_system_web_app_resources_map.h"
type="resource_map_header" />
<output filename="chromeos_sample_system_web_app_resources.pak" type="data_package" />
</outputs>
<release seq="1">
<includes>
<if expr="is_official_build == false">
<!-- Privileged app host contents. -->
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_INDEX_HTML" file="index.html" type="BINDATA" />
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_SANDBOX_HTML" file="sandbox.html" type="BINDATA" />
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_ICON_192" file="app_icon_192.png" type="BINDATA" />
<!-- Untrusted app contents. -->
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_UNTRUSTED_HTML" file="untrusted.html" type="BINDATA" />
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_UNTRUSTED_JS" file="untrusted.js" type="BINDATA" />
</if>
</includes>
</release>
</grit>
...@@ -21,10 +21,10 @@ namespace { ...@@ -21,10 +21,10 @@ namespace {
content::WebUIDataSource* CreateUntrustedSampleSystemWebAppDataSource() { content::WebUIDataSource* CreateUntrustedSampleSystemWebAppDataSource() {
content::WebUIDataSource* untrusted_source = content::WebUIDataSource* untrusted_source =
content::WebUIDataSource::Create(kChromeUIUntrustedSampleSystemWebAppURL); content::WebUIDataSource::Create(kChromeUIUntrustedSampleSystemWebAppURL);
untrusted_source->AddResourcePath("untrusted.html", untrusted_source->AddResourcePath(
IDR_SAMPLE_SYSTEM_WEB_APP_UNTRUSTED_HTML); "untrusted.html", IDR_CHROMEOS_SAMPLE_SYSTEM_WEB_APP_UNTRUSTED_HTML);
untrusted_source->AddResourcePath("untrusted.js", untrusted_source->AddResourcePath(
IDR_SAMPLE_SYSTEM_WEB_APP_UNTRUSTED_JS); "untrusted.js", IDR_CHROMEOS_SAMPLE_SYSTEM_WEB_APP_UNTRUSTED_JS);
untrusted_source->AddFrameAncestor(GURL(kChromeUISampleSystemWebAppURL)); untrusted_source->AddFrameAncestor(GURL(kChromeUISampleSystemWebAppURL));
return untrusted_source; return untrusted_source;
} }
...@@ -35,18 +35,20 @@ SampleSystemWebAppUI::SampleSystemWebAppUI(content::WebUI* web_ui) ...@@ -35,18 +35,20 @@ SampleSystemWebAppUI::SampleSystemWebAppUI(content::WebUI* web_ui)
auto trusted_source = base::WrapUnique( auto trusted_source = base::WrapUnique(
content::WebUIDataSource::Create(kChromeUISampleSystemWebAppHost)); content::WebUIDataSource::Create(kChromeUISampleSystemWebAppHost));
trusted_source->AddResourcePath("", IDR_SAMPLE_SYSTEM_WEB_APP_INDEX_HTML); trusted_source->AddResourcePath(
trusted_source->AddResourcePath("sandbox.html", "", IDR_CHROMEOS_SAMPLE_SYSTEM_WEB_APP_INDEX_HTML);
IDR_SAMPLE_SYSTEM_WEB_APP_SANDBOX_HTML); trusted_source->AddResourcePath(
trusted_source->AddResourcePath("app_icon_192.png", "sandbox.html", IDR_CHROMEOS_SAMPLE_SYSTEM_WEB_APP_SANDBOX_HTML);
IDR_SAMPLE_SYSTEM_WEB_APP_ICON_192); trusted_source->AddResourcePath(
"app_icon_192.png", IDR_CHROMEOS_SAMPLE_SYSTEM_WEB_APP_APP_ICON_192_PNG);
#if !DCHECK_IS_ON() #if !DCHECK_IS_ON()
// If a user goes to an invalid url and non-DCHECK mode (DHECK = debug mode) // If a user goes to an invalid url and non-DCHECK mode (DHECK = debug mode)
// is set, serve a default page so the user sees your default page instead // is set, serve a default page so the user sees your default page instead
// of an unexpected error. But if DCHECK is set, the user will be a // of an unexpected error. But if DCHECK is set, the user will be a
// developer and be able to identify an error occurred. // developer and be able to identify an error occurred.
trusted_source->SetDefaultResource(IDR_SAMPLE_SYSTEM_WEB_APP_INDEX_HTML); trusted_source->SetDefaultResource(
IDR_CHROMEOS_SAMPLE_SYSTEM_WEB_APP_INDEX_HTML);
#endif // !DCHECK_IS_ON() #endif // !DCHECK_IS_ON()
// We need a CSP override to use the chrome-untrusted:// scheme in the host. // We need a CSP override to use the chrome-untrusted:// scheme in the host.
......
...@@ -136,17 +136,34 @@ grit("help_app_bundle_resources") { ...@@ -136,17 +136,34 @@ grit("help_app_bundle_resources") {
output_dir = "$root_gen_dir/chromeos" output_dir = "$root_gen_dir/chromeos"
} }
# Resources used by chrome://sample-system-web-app if (!is_official_build) {
grit("sample_system_web_app_resources") { # Resources used by chrome://sample-system-web-app
source = "../components/sample_system_web_app_ui/resources/sample_system_web_app_resources.grd" grit("sample_system_web_app_resources") {
grit_flags = [
"-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
"-E",
"root_src_dir=" + rebase_path("//", root_build_dir),
]
outputs = [ defines = [ "SHARED_INTERMEDIATE_DIR=" +
"grit/chromeos_sample_system_web_app_resources.h", rebase_path(root_gen_dir, root_build_dir) ]
"grit/chromeos_sample_system_web_app_resources_map.cc",
"grit/chromeos_sample_system_web_app_resources_map.h", # These arguments are needed since the grd is generated at build time.
"chromeos_sample_system_web_app_resources.pak", enable_input_discovery_for_gn_analyze = false
] sample_system_web_app_gen_dir =
output_dir = "$root_gen_dir/chromeos" "$root_gen_dir/chromeos/components/sample_system_web_app_ui"
source = "$sample_system_web_app_gen_dir/chromeos_sample_system_web_app_resources.grd"
deps = [ "//chromeos/components/sample_system_web_app_ui:build_grd" ]
outputs = [
"grit/chromeos_sample_system_web_app_resources.h",
"grit/chromeos_sample_system_web_app_resources_map.cc",
"grit/chromeos_sample_system_web_app_resources_map.h",
"chromeos_sample_system_web_app_resources.pak",
]
output_dir = "$root_gen_dir/chromeos"
}
} }
# Resources used by chrome://telemetry-extension # Resources used by chrome://telemetry-extension
......
...@@ -351,7 +351,8 @@ ...@@ -351,7 +351,8 @@
"includes": [2600], "includes": [2600],
"structures": [2620], "structures": [2620],
}, },
"chromeos/components/sample_system_web_app_ui/resources/sample_system_web_app_resources.grd": { "<(SHARED_INTERMEDIATE_DIR)/chromeos/components/sample_system_web_app_ui/chromeos_sample_system_web_app_resources.grd": {
"META": {"sizes": {"includes": [50],}},
"includes": [2640], "includes": [2640],
}, },
"chromeos/components/scanning/resources/scanning_app_resources.grd": { "chromeos/components/scanning/resources/scanning_app_resources.grd": {
......
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