Commit 9dffda5d authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

Flags WebUI: Remove unnecessary |flattenhtml| and absolute chrome:// paths.

Previously the code relied on some fragile coincidence to work:
 1) flags.html was using |flattenhtml| to inline flags.css at build time.
 2) flags.html was using absolute chrome://flags/strings.js and
    chrome://flags/flags.js URLs, to prevent those files from being
    inlined (which would violate CSP and result in a runtime error).

1 and 2 above resulted in a breakage (runtime error) if one changes
<script src="chrome://flags/flags.js"></script>
to
<script src="flags.js"></script>

which is confusing, since those URLs are equivalent and should be treated
exactly the same.

Removing |flattenhtml| from flags.js GRIT entry fixes the weirdness.

This is in preparation of converting this page to use JS modules.

Bug: 1029094
Change-Id: I394ce31f082372758ea6d34ce607c0794e27b4c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941207
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721109}
parent 175d2afc
......@@ -75,6 +75,7 @@ content::WebUIDataSource* CreateFlagsUIHTMLSource() {
#endif
source->AddResourcePath(flags_ui::kFlagsJS, IDR_FLAGS_UI_FLAGS_JS);
source->AddResourcePath(flags_ui::kFlagsCSS, IDR_FLAGS_UI_FLAGS_CSS);
source->SetDefaultResource(IDR_FLAGS_UI_FLAGS_HTML);
source->UseStringsJs();
return source;
......
......@@ -8,6 +8,7 @@ namespace flags_ui {
// Resource paths.
const char kFlagsJS[] = "flags.js";
const char kFlagsCSS[] = "flags.css";
// Message handlers.
const char kEnableExperimentalFeature[] = "enableExperimentalFeature";
......
......@@ -10,6 +10,7 @@ namespace flags_ui {
// Resource paths.
// Must match the resource file names.
extern const char kFlagsJS[];
extern const char kFlagsCSS[];
// Message handlers.
// Must match the constants used in the resource files.
......
......@@ -21,7 +21,7 @@
<script src="chrome://resources/js/cr/ui/focus_outline_manager.js"></script>
<script src="chrome://resources/js/util.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://flags/strings.js"></script>
<script src="strings.js"></script>
</head>
<body>
<div id="header">
......@@ -224,7 +224,7 @@
</div>
</div>
</div>
<script src="chrome://flags/flags.js"></script>
<script src="flags.js"></script>
<script src="chrome://resources/js/jstemplate_compiled.js"></script>
</body>
</html>
......@@ -10,6 +10,7 @@ per-file data_reduction_proxy*=file://components/data_reduction_proxy/OWNERS
per-file dom_distiller*=mdjones@chromium.org
per-file dom_distiller*=nyquist@chromium.org
per-file dom_distiller*=wychen@chromium.org
per-file flags_ui*=file://components/flags_ui/OWNERS
per-file gcm_driver_resources.grdp=dimich@chromium.org
per-file gcm_driver_resources.grdp=fgorski@chromium.org
per-file gcm_driver_resources.grdp=jianli@chromium.org
......
<?xml version="1.0" encoding="utf-8"?>
<grit-part>
<include name="IDR_FLAGS_UI_FLAGS_HTML" file="../flags_ui/resources/flags.html" flattenhtml="true" type="BINDATA" compress="gzip" />
<include name="IDR_FLAGS_UI_FLAGS_HTML" file="../flags_ui/resources/flags.html" preprocess="true" type="BINDATA" compress="gzip" />
<include name="IDR_FLAGS_UI_FLAGS_JS" file="../flags_ui/resources/flags.js" type="BINDATA" compress="gzip" />
<include name="IDR_FLAGS_UI_FLAGS_CSS" file="../flags_ui/resources/flags.css" flattenhtml="true" type="BINDATA" compress="gzip" />
</grit-part>
......@@ -44,6 +44,7 @@ web::WebUIIOSDataSource* CreateFlagsUIHTMLSource() {
source->UseStringsJs();
FlagsUI::AddFlagsIOSStrings(source);
source->AddResourcePath(flags_ui::kFlagsJS, IDR_FLAGS_UI_FLAGS_JS);
source->AddResourcePath(flags_ui::kFlagsCSS, IDR_FLAGS_UI_FLAGS_CSS);
source->SetDefaultResource(IDR_FLAGS_UI_FLAGS_HTML);
source->UseStringsJs();
return source;
......@@ -237,4 +238,4 @@ void FlagsUI::AddFlagsIOSStrings(web::WebUIIOSDataSource* source) {
IDS_FLAGS_UI_SEARCH_RESULTS_SINGULAR);
source->AddLocalizedString("searchResultsPlural",
IDS_FLAGS_UI_SEARCH_RESULTS_PLURAL);
}
\ No newline at end of file
}
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