Commit 1c169bad authored by rbpotter's avatar rbpotter Committed by Chromium LUCI CQ

WebUI: Remove generated path from SetupWebUIDataSource

Change-Id: I3a329883d475d30ac4b95d404c8b1abc1b69eb41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583842
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836916}
parent 1a92604a
...@@ -47,7 +47,7 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) { ...@@ -47,7 +47,7 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) {
content::WebUIDataSource* source = content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIBookmarksHost); content::WebUIDataSource::Create(chrome::kChromeUIBookmarksHost);
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, base::make_span(kBookmarksResources, kBookmarksResourcesSize), "", source, base::make_span(kBookmarksResources, kBookmarksResourcesSize),
IDR_BOOKMARKS_BOOKMARKS_HTML); IDR_BOOKMARKS_BOOKMARKS_HTML);
// Build an Accelerator to describe undo shortcut // Build an Accelerator to describe undo shortcut
......
...@@ -110,7 +110,6 @@ BluetoothPairingDialogUI::BluetoothPairingDialogUI(content::WebUI* web_ui) ...@@ -110,7 +110,6 @@ BluetoothPairingDialogUI::BluetoothPairingDialogUI(content::WebUI* web_ui)
source, source,
base::make_span(kBluetoothPairingDialogResources, base::make_span(kBluetoothPairingDialogResources,
kBluetoothPairingDialogResourcesSize), kBluetoothPairingDialogResourcesSize),
std::string(),
IDR_BLUETOOTH_PAIRING_DIALOG_BLUETOOTH_PAIRING_DIALOG_CONTAINER_HTML); IDR_BLUETOOTH_PAIRING_DIALOG_BLUETOOTH_PAIRING_DIALOG_CONTAINER_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
} }
......
...@@ -35,7 +35,7 @@ EmojiPicker::EmojiPicker(content::WebUI* web_ui) ...@@ -35,7 +35,7 @@ EmojiPicker::EmojiPicker(content::WebUI* web_ui)
// Add required resources. // Add required resources.
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
html_source.get(), html_source.get(),
base::make_span(kEmojiPickerResources, kEmojiPickerResourcesSize), "", base::make_span(kEmojiPickerResources, kEmojiPickerResourcesSize),
IDR_EMOJI_PICKER_EMOJI_PICKER_HTML); IDR_EMOJI_PICKER_EMOJI_PICKER_HTML);
content::BrowserContext* browser_context = content::BrowserContext* browser_context =
......
...@@ -29,7 +29,7 @@ MultideviceInternalsUI::MultideviceInternalsUI(content::WebUI* web_ui) ...@@ -29,7 +29,7 @@ MultideviceInternalsUI::MultideviceInternalsUI(content::WebUI* web_ui)
html_source, html_source,
base::make_span(kMultideviceInternalsResources, base::make_span(kMultideviceInternalsResources,
kMultideviceInternalsResourcesSize), kMultideviceInternalsResourcesSize),
"", IDR_MULTIDEVICE_INTERNALS_INDEX_HTML); IDR_MULTIDEVICE_INTERNALS_INDEX_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
web_ui->AddMessageHandler( web_ui->AddMessageHandler(
......
...@@ -24,7 +24,7 @@ CommanderUI::CommanderUI(content::WebUI* web_ui) ...@@ -24,7 +24,7 @@ CommanderUI::CommanderUI(content::WebUI* web_ui)
content::WebUIDataSource* source = content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUICommanderHost); content::WebUIDataSource::Create(chrome::kChromeUICommanderHost);
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, base::make_span(kCommanderResources, kCommanderResourcesSize), "", source, base::make_span(kCommanderResources, kCommanderResourcesSize),
IDR_COMMANDER_COMMANDER_HTML); IDR_COMMANDER_COMMANDER_HTML);
Profile* profile = Profile::FromWebUI(web_ui); Profile* profile = Profile::FromWebUI(web_ui);
......
...@@ -235,7 +235,7 @@ DiscardsUI::DiscardsUI(content::WebUI* web_ui) ...@@ -235,7 +235,7 @@ DiscardsUI::DiscardsUI(content::WebUI* web_ui)
{"chrome/browser/ui/webui/discards/site_data.mojom-webui.js", {"chrome/browser/ui/webui/discards/site_data.mojom-webui.js",
IDR_DISCARDS_SITE_DATA_MOJOM_WEBUI_JS}, IDR_DISCARDS_SITE_DATA_MOJOM_WEBUI_JS},
}; };
webui::SetupWebUIDataSource(source.get(), kResources, "", IDR_DISCARDS_HTML); webui::SetupWebUIDataSource(source.get(), kResources, IDR_DISCARDS_HTML);
Profile* profile = Profile::FromWebUI(web_ui); Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, source.release()); content::WebUIDataSource::Add(profile, source.release());
......
...@@ -57,7 +57,7 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) { ...@@ -57,7 +57,7 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
content::WebUIDataSource* source = content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIDownloadsHost); content::WebUIDataSource::Create(chrome::kChromeUIDownloadsHost);
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, base::make_span(kDownloadsResources, kDownloadsResourcesSize), "", source, base::make_span(kDownloadsResources, kDownloadsResourcesSize),
IDR_DOWNLOADS_DOWNLOADS_HTML); IDR_DOWNLOADS_DOWNLOADS_HTML);
bool requests_ap_verdicts = bool requests_ap_verdicts =
......
...@@ -70,7 +70,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile, ...@@ -70,7 +70,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
content::WebUIDataSource::Create(chrome::kChromeUIExtensionsHost); content::WebUIDataSource::Create(chrome::kChromeUIExtensionsHost);
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, base::make_span(kExtensionsResources, kExtensionsResourcesSize), source, base::make_span(kExtensionsResources, kExtensionsResourcesSize),
"", IDR_EXTENSIONS_EXTENSIONS_HTML); IDR_EXTENSIONS_EXTENSIONS_HTML);
static constexpr webui::LocalizedString kLocalizedStrings[] = { static constexpr webui::LocalizedString kLocalizedStrings[] = {
// Add common strings. // Add common strings.
......
...@@ -113,7 +113,7 @@ content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) { ...@@ -113,7 +113,7 @@ content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) {
source->AddBoolean(kIsUserSignedInKey, IsUserSignedIn(profile)); source->AddBoolean(kIsUserSignedInKey, IsUserSignedIn(profile));
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, base::make_span(kHistoryResources, kHistoryResourcesSize), "", source, base::make_span(kHistoryResources, kHistoryResourcesSize),
IDR_HISTORY_HISTORY_HTML); IDR_HISTORY_HISTORY_HTML);
return source; return source;
......
...@@ -37,7 +37,7 @@ NearbyInternalsUI::NearbyInternalsUI(content::WebUI* web_ui) ...@@ -37,7 +37,7 @@ NearbyInternalsUI::NearbyInternalsUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
html_source, html_source,
base::make_span(kNearbyInternalsResources, kNearbyInternalsResourcesSize), base::make_span(kNearbyInternalsResources, kNearbyInternalsResourcesSize),
/*generated_path=*/std::string(), IDR_NEARBY_INTERNALS_INDEX_HTML); IDR_NEARBY_INTERNALS_INDEX_HTML);
content::WebUIDataSource::Add(profile, html_source); content::WebUIDataSource::Add(profile, html_source);
content::BrowserContext* context = content::BrowserContext* context =
......
...@@ -49,7 +49,6 @@ NearbyShareDialogUI::NearbyShareDialogUI(content::WebUI* web_ui) ...@@ -49,7 +49,6 @@ NearbyShareDialogUI::NearbyShareDialogUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource(html_source, webui::SetupWebUIDataSource(html_source,
base::make_span(kNearbyShareDialogResources, base::make_span(kNearbyShareDialogResources,
kNearbyShareDialogResourcesSize), kNearbyShareDialogResourcesSize),
/*generated_path=*/std::string(),
IDR_NEARBY_SHARE_DIALOG_NEARBY_SHARE_DIALOG_HTML); IDR_NEARBY_SHARE_DIALOG_NEARBY_SHARE_DIALOG_HTML);
// To use lottie, the worker-src CSP needs to be updated for the web ui that // To use lottie, the worker-src CSP needs to be updated for the web ui that
......
...@@ -255,7 +255,7 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) { ...@@ -255,7 +255,7 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, base::make_span(kNewTabPageResources, kNewTabPageResourcesSize), source, base::make_span(kNewTabPageResources, kNewTabPageResourcesSize),
"", IDR_NEW_TAB_PAGE_NEW_TAB_PAGE_HTML); IDR_NEW_TAB_PAGE_NEW_TAB_PAGE_HTML);
// Allows creating <script> and inlining as well as network requests to // Allows creating <script> and inlining as well as network requests to
// support inlining the OneGoogleBar. // support inlining the OneGoogleBar.
......
...@@ -450,7 +450,7 @@ content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) { ...@@ -450,7 +450,7 @@ content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) {
content::WebUIDataSource::Create(chrome::kChromeUIPrintHost); content::WebUIDataSource::Create(chrome::kChromeUIPrintHost);
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, source,
base::make_span(kPrintPreviewResources, kPrintPreviewResourcesSize), "", base::make_span(kPrintPreviewResources, kPrintPreviewResourcesSize),
IDR_PRINT_PREVIEW_PRINT_PREVIEW_HTML); IDR_PRINT_PREVIEW_PRINT_PREVIEW_HTML);
AddPrintPreviewStrings(source); AddPrintPreviewStrings(source);
SetupPrintPreviewPlugin(source); SetupPrintPreviewPlugin(source);
......
...@@ -48,7 +48,7 @@ ReadLaterUI::ReadLaterUI(content::WebUI* web_ui) ...@@ -48,7 +48,7 @@ ReadLaterUI::ReadLaterUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, base::make_span(kReadLaterResources, kReadLaterResourcesSize), source, base::make_span(kReadLaterResources, kReadLaterResourcesSize),
/*generated_path=*/std::string(), IDR_READ_LATER_READ_LATER_HTML); IDR_READ_LATER_READ_LATER_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
source); source);
} }
......
...@@ -76,7 +76,7 @@ OSSettingsUI::OSSettingsUI(content::WebUI* web_ui) ...@@ -76,7 +76,7 @@ OSSettingsUI::OSSettingsUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
html_source, html_source,
base::make_span(kOsSettingsResources, kOsSettingsResourcesSize), base::make_span(kOsSettingsResources, kOsSettingsResourcesSize),
/*generated_path=*/std::string(), default_resource); default_resource);
// For Polymer 2 optimized builds that rely on loading individual subpages, // For Polymer 2 optimized builds that rely on loading individual subpages,
// set the default resource for tests. // set the default resource for tests.
......
...@@ -346,7 +346,7 @@ SettingsUI::SettingsUI(content::WebUI* web_ui) ...@@ -346,7 +346,7 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
html_source, base::make_span(kSettingsResources, kSettingsResourcesSize), html_source, base::make_span(kSettingsResources, kSettingsResourcesSize),
"", IDR_SETTINGS_SETTINGS_HTML); IDR_SETTINGS_SETTINGS_HTML);
AddLocalizedStrings(html_source, profile, web_ui->GetWebContents()); AddLocalizedStrings(html_source, profile, web_ui->GetWebContents());
......
...@@ -113,7 +113,7 @@ content::WebUIDataSource* CreateWebUIDataSource(Profile* profile) { ...@@ -113,7 +113,7 @@ content::WebUIDataSource* CreateWebUIDataSource(Profile* profile) {
content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost); content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost);
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, source,
base::make_span(kGaiaAuthHostResources, kGaiaAuthHostResourcesSize), "", base::make_span(kGaiaAuthHostResources, kGaiaAuthHostResourcesSize),
IDR_INLINE_LOGIN_HTML); IDR_INLINE_LOGIN_HTML);
// Only add a filter when runing as test. // Only add a filter when runing as test.
......
...@@ -171,7 +171,7 @@ ProfilePickerUI::ProfilePickerUI(content::WebUI* web_ui) ...@@ -171,7 +171,7 @@ ProfilePickerUI::ProfilePickerUI(content::WebUI* web_ui)
AddStrings(html_source); AddStrings(html_source);
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
html_source, html_source,
base::make_span(kProfilePickerResources, kProfilePickerResourcesSize), "", base::make_span(kProfilePickerResources, kProfilePickerResourcesSize),
IDR_PROFILE_PICKER_PROFILE_PICKER_HTML); IDR_PROFILE_PICKER_PROFILE_PICKER_HTML);
content::WebUIDataSource::Add(profile, html_source); content::WebUIDataSource::Add(profile, html_source);
} }
......
...@@ -74,7 +74,7 @@ TabSearchUI::TabSearchUI(content::WebUI* web_ui) ...@@ -74,7 +74,7 @@ TabSearchUI::TabSearchUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, base::make_span(kTabSearchResources, kTabSearchResourcesSize), source, base::make_span(kTabSearchResources, kTabSearchResourcesSize),
/*generated_path=*/std::string(), IDR_TAB_SEARCH_TAB_SEARCH_HTML); IDR_TAB_SEARCH_TAB_SEARCH_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
source); source);
......
...@@ -47,7 +47,7 @@ TabStripUI::TabStripUI(content::WebUI* web_ui) ...@@ -47,7 +47,7 @@ TabStripUI::TabStripUI(content::WebUI* web_ui)
content::WebUIDataSource::Create(chrome::kChromeUITabStripHost); content::WebUIDataSource::Create(chrome::kChromeUITabStripHost);
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
html_source, base::make_span(kTabStripResources, kTabStripResourcesSize), html_source, base::make_span(kTabStripResources, kTabStripResourcesSize),
"", IDR_TAB_STRIP_TAB_STRIP_HTML); IDR_TAB_STRIP_TAB_STRIP_HTML);
html_source->AddString("tabIdDataType", kWebUITabIdDataType); html_source->AddString("tabIdDataType", kWebUITabIdDataType);
html_source->AddString("tabGroupIdDataType", kWebUITabGroupIdDataType); html_source->AddString("tabGroupIdDataType", kWebUITabGroupIdDataType);
......
...@@ -34,7 +34,7 @@ UsbInternalsUI::UsbInternalsUI(content::WebUI* web_ui) ...@@ -34,7 +34,7 @@ UsbInternalsUI::UsbInternalsUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, source,
base::make_span(kUsbInternalsResources, kUsbInternalsResourcesSize), "", base::make_span(kUsbInternalsResources, kUsbInternalsResourcesSize),
IDR_USB_INTERNALS_USB_INTERNALS_HTML); IDR_USB_INTERNALS_USB_INTERNALS_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
......
...@@ -36,7 +36,7 @@ WebUIJsErrorUI::WebUIJsErrorUI(content::WebUI* web_ui) ...@@ -36,7 +36,7 @@ WebUIJsErrorUI::WebUIJsErrorUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
source, source,
base::make_span(kWebuiJsErrorResources, kWebuiJsErrorResourcesSize), base::make_span(kWebuiJsErrorResources, kWebuiJsErrorResourcesSize),
std::string(), IDR_WEBUI_JS_ERROR_WEBUI_JS_ERROR_HTML); IDR_WEBUI_JS_ERROR_WEBUI_JS_ERROR_HTML);
Profile* profile = Profile::FromWebUI(web_ui); Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, source); content::WebUIDataSource::Add(profile, source);
} }
......
...@@ -41,19 +41,10 @@ void SetupPolymer3Defaults(content::WebUIDataSource* source) { ...@@ -41,19 +41,10 @@ void SetupPolymer3Defaults(content::WebUIDataSource* source) {
void SetupWebUIDataSource(content::WebUIDataSource* source, void SetupWebUIDataSource(content::WebUIDataSource* source,
base::span<const GritResourceMap> resources, base::span<const GritResourceMap> resources,
const std::string& generated_path,
int default_resource) { int default_resource) {
SetupPolymer3Defaults(source); SetupPolymer3Defaults(source);
// TODO (crbug.com/1132403): Replace usages of |generated_path| with the new
// |resource_path| GRD property, and remove from here.
bool has_gen_path = !generated_path.empty();
for (const GritResourceMap& resource : resources) { for (const GritResourceMap& resource : resources) {
std::string path = resource.name; source->AddResourcePath(resource.name, resource.value);
if (has_gen_path && path.rfind(generated_path, 0) == 0) {
path = path.substr(generated_path.size());
}
source->AddResourcePath(path, resource.value);
} }
source->AddResourcePath("", default_resource); source->AddResourcePath("", default_resource);
} }
......
...@@ -31,7 +31,6 @@ struct ResourcePath { ...@@ -31,7 +31,6 @@ struct ResourcePath {
// test loader files. // test loader files.
void SetupWebUIDataSource(content::WebUIDataSource* source, void SetupWebUIDataSource(content::WebUIDataSource* source,
base::span<const GritResourceMap> resources, base::span<const GritResourceMap> resources,
const std::string& generated_path,
int default_resource); int default_resource);
// Calls content::WebUIDataSource::AddLocalizedString() in a for-loop for // Calls content::WebUIDataSource::AddLocalizedString() in a for-loop for
......
...@@ -130,7 +130,7 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url) ...@@ -130,7 +130,7 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
content::WebUIDataSource::Create(url.host()); content::WebUIDataSource::Create(url.host());
webui::SetupWebUIDataSource( webui::SetupWebUIDataSource(
html_source, base::make_span(kWelcomeResources, kWelcomeResourcesSize), html_source, base::make_span(kWelcomeResources, kWelcomeResourcesSize),
"", IDR_WELCOME_WELCOME_HTML); IDR_WELCOME_WELCOME_HTML);
// Add welcome strings. // Add welcome strings.
AddStrings(html_source); AddStrings(html_source);
......
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