Commit f15a4115 authored by Patti's avatar Patti Committed by Commit Bot

Revert "WebUI: Delete SetupBundledWebUIDataSource()"

This reverts commit f99198c0.

Reason for revert: Compile errors due the removal of this function after having reverted https://chromium-review.googlesource.com/q/commit:85415a2c689f29c97626748a688b58c56cc22f16. See crbug.com/1143504.

Original change's description:
> WebUI: Delete SetupBundledWebUIDataSource()
>
> With the update of OS settings to generate_grd, this method is no
> longer used.
>
> Bug: 1132403
> Change-Id: Id06f6249b05bebcc72eb22b417d0334bc4d5a708
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505936
> Reviewed-by: dpapad <dpapad@chromium.org>
> Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#821828}

TBR=dpapad@chromium.org,rbpotter@chromium.org

Change-Id: I308bddd010b80241e99d731a0bfa0989ad655d73
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1132403, 1143504
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505359Reviewed-by: default avatarPatti <patricialor@chromium.org>
Commit-Queue: Patti <patricialor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822006}
parent a06c1f9c
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/webui_util.h" #include "chrome/browser/ui/webui/webui_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/common/buildflags.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "services/network/public/mojom/content_security_policy.mojom.h" #include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
...@@ -56,6 +57,17 @@ void SetupWebUIDataSource(content::WebUIDataSource* source, ...@@ -56,6 +57,17 @@ void SetupWebUIDataSource(content::WebUIDataSource* source,
source->AddResourcePath("", default_resource); source->AddResourcePath("", default_resource);
} }
#if BUILDFLAG(OPTIMIZE_WEBUI)
void SetupBundledWebUIDataSource(content::WebUIDataSource* source,
base::StringPiece bundled_path,
int bundle,
int default_resource) {
SetupPolymer3Defaults(source);
source->AddResourcePath(bundled_path, bundle);
source->AddResourcePath("", default_resource);
}
#endif
void AddLocalizedStringsBulk(content::WebUIDataSource* html_source, void AddLocalizedStringsBulk(content::WebUIDataSource* html_source,
base::span<const LocalizedString> strings) { base::span<const LocalizedString> strings) {
for (const auto& str : strings) for (const auto& str : strings)
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/containers/span.h" #include "base/containers/span.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "chrome/common/buildflags.h"
struct GritResourceMap; struct GritResourceMap;
...@@ -34,6 +35,15 @@ void SetupWebUIDataSource(content::WebUIDataSource* source, ...@@ -34,6 +35,15 @@ void SetupWebUIDataSource(content::WebUIDataSource* source,
const std::string& generated_path, const std::string& generated_path,
int default_resource); int default_resource);
#if BUILDFLAG(OPTIMIZE_WEBUI)
// Same as SetupWebUIDataSource, but for a bundled page; this adds only the
// bundle and the default resource to |source|.
void SetupBundledWebUIDataSource(content::WebUIDataSource* source,
base::StringPiece bundled_path,
int bundle,
int default_resource);
#endif
// Calls content::WebUIDataSource::AddLocalizedString() in a for-loop for // Calls content::WebUIDataSource::AddLocalizedString() in a for-loop for
// |strings|. Reduces code size vs. reimplementing the same for-loop. // |strings|. Reduces code size vs. reimplementing the same for-loop.
void AddLocalizedStringsBulk(content::WebUIDataSource* html_source, void AddLocalizedStringsBulk(content::WebUIDataSource* html_source,
......
...@@ -407,12 +407,12 @@ resource map can be added as follows: ...@@ -407,12 +407,12 @@ resource map can be added as follows:
``` ```
<a name="SetupWebUIDataSource"></a> <a name="SetupWebUIDataSource"></a>
### webui::SetupWebUIDataSource() ### webui::SetupWebUIDataSource() and webui::SetupBundledWebUIDataSource()
This method performs common configuration tasks on a data source for a Web UI These methods perform common configuration tasks on a data source for a Web UI
that uses JS modules. When creating a Web UI that uses JS modules, use this that uses JS modules. When creating a Web UI that uses JS modules, use these
utility instead of duplicating the configuration steps it performs elsewhere. utilities instead of duplicating the configuration steps they perform elsewhere.
Specific setup steps include: Specific setup steps performed by these utilities include:
* Setting the content security policy to allow the data source to load only * Setting the content security policy to allow the data source to load only
resources from its own host (e.g. chrome://history), chrome://resources, and resources from its own host (e.g. chrome://history), chrome://resources, and
...@@ -422,7 +422,13 @@ Specific setup steps include: ...@@ -422,7 +422,13 @@ Specific setup steps include:
* Adding the test loader files to the data source, so that test files can be * Adding the test loader files to the data source, so that test files can be
loaded as JS modules. loaded as JS modules.
* Setting the resource to load for the empty path. * Setting the resource to load for the empty path.
* Adding all resources from a GritResourceMap.
The version for non-bundled UIs (<code>SetupWebUIDataSource()</code>) also adds
all resources in a GritResourceMap.
The version for bundled UIs (<code>SetupBundledWebUIDataSource()</code>) adds
a single specified bundled resource. Note that this version is only defined when
the optimize_webui build flag is enabled.
## Browser (C++) &rarr; Renderer (JS) ## Browser (C++) &rarr; Renderer (JS)
......
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