Move webui::AddResourcePathsBulk to content::WebUIDataSource.
Previously it was implemented as a helper function in webui_util.cc,
but it better belongs in WebUIDataSource as an instance method.
With this change, several calls like
webui::AddResourcePathsBulk(
source, base::make_span(kResources, kResourcesSize));
are converted to
source->AddResourcePaths(
base::make_span(kResources, kResourcesSize));
A concrete benefit of moving this method in WebUIDataSource is that
it now can be leveraged by more places in the code (for example
chromeos/components/ or content/browser/webui/), which do not have
permission to depend on chrome/.
Bug: 1176299
Change-Id: I4df20cb6067fef885d3b0d48e0ee500238f27177
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2692121
Commit-Queue: dpapad <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Rebekah Potter <[email protected]>
Cr-Commit-Position: refs/heads/master@{#854403}
diff --git a/docs/webui_explainer.md b/docs/webui_explainer.md
index df98e41..fbbb482 100644
--- a/docs/webui_explainer.md
+++ b/docs/webui_explainer.md
@@ -377,13 +377,12 @@
source->AddLocalizedStrings(kStrings);
```
-<a name="AddResourcePathsBulk"></a>
-### webui::AddResourcePathsBulk()
+<a name="AddResourcePaths"></a>
+### WebUIDataSource::AddResourcePaths()
Similar to the localized strings, many Web UIs need to add a large number of
-resource paths. In this case, use <code>AddResourcePathsBulk()</code> to
-replace repeated calls to <code>AddResourcePath()</code>. There are two
-versions. One works almost identically to the strings case:
+resource paths. In this case, use <code>AddResourcePaths()</code> to
+replace repeated calls to <code>AddResourcePath()</code>.
```c++
static constexpr webui::ResourcePath kPdfResources[] = {
@@ -391,20 +390,18 @@
{"pdf/constants.js", IDR_PDF_CONSTANTS_JS},
{"pdf/controller.js", IDR_PDF_CONTROLLER_JS},
};
- webui::AddResourcePathsBulk(source, kStrings);
+ source->AddResourcePaths(kStrings);
```
-The second version instead accepts a span of <code>GritResourceMap</code> so
-that it can directly use constants defined by autogenerated grit resources map
-header files. For example, the autogenerated print\_preview\_resources\_map.h
-header defines a <code>GritResourceMap</code> named
-<code>kPrintPreviewResources</code> and a
-<code>size\_t kPrintPreviewResourcesSize</code>. All the resources in this
+The same method can be leveraged for cases that directly use constants defined
+by autogenerated grit resources map header files. For example, the autogenerated
+print\_preview\_resources\_map.h header defines a
+<code>webui::ResourcePath</code> array named <code>kPrintPreviewResources</code>
+and a <code>size\_t kPrintPreviewResourcesSize</code>. All the resources in this
resource map can be added as follows:
```c++
- webui::AddResourcePathsBulk(
- source,
+ source->AddResourcePaths(
base::make_span(kPrintPreviewResources, kPrintPreviewResourcesSize));
```