0

Revert "WebUI: Delete SetupBundledWebUIDataSource()"

This reverts commit f99198c064.

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/+/2505359
Reviewed-by: Patti <patricialor@chromium.org>
Commit-Queue: Patti <patricialor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822006}
This commit is contained in:
Patti
2020-10-29 03:05:02 +00:00
committed by Commit Bot
parent a06c1f9c75
commit f15a4115c5
3 changed files with 34 additions and 6 deletions

@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/webui_util.h"
#include "build/build_config.h"
#include "chrome/common/buildflags.h"
#include "content/public/browser/web_ui_data_source.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/webui/web_ui_util.h"
@ -56,6 +57,17 @@ void SetupWebUIDataSource(content::WebUIDataSource* source,
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,
base::span<const LocalizedString> strings) {
for (const auto& str : strings)

@ -9,6 +9,7 @@
#include "base/containers/span.h"
#include "base/strings/string_piece.h"
#include "chrome/common/buildflags.h"
struct GritResourceMap;
@ -34,6 +35,15 @@ void SetupWebUIDataSource(content::WebUIDataSource* source,
const std::string& generated_path,
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
// |strings|. Reduces code size vs. reimplementing the same for-loop.
void AddLocalizedStringsBulk(content::WebUIDataSource* html_source,

@ -407,12 +407,12 @@ resource map can be added as follows:
```
<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
that uses JS modules. When creating a Web UI that uses JS modules, use this
utility instead of duplicating the configuration steps it performs elsewhere.
Specific setup steps include:
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 these
utilities instead of duplicating the configuration steps they perform elsewhere.
Specific setup steps performed by these utilities include:
* 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
@ -422,7 +422,13 @@ Specific setup steps include:
* Adding the test loader files to the data source, so that test files can be
loaded as JS modules.
* 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)