Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Unified Diff: content/browser/webui/web_ui_data_source_impl.cc

Issue 2544683002: [MD settings] i18n source stream filtering (Closed)
Patch Set: review nits Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/webui/web_ui_data_source_impl.cc
diff --git a/content/browser/webui/web_ui_data_source_impl.cc b/content/browser/webui/web_ui_data_source_impl.cc
index 99d12e229cae9a94a7f82939d295dde7bab5091b..e923236b94696e343d18a0eb596a5afe995f9675 100644
--- a/content/browser/webui/web_ui_data_source_impl.cc
+++ b/content/browser/webui/web_ui_data_source_impl.cc
@@ -224,6 +224,21 @@ void WebUIDataSourceImpl::DisableI18nAndUseGzipForAllPaths() {
use_gzip_for_all_paths_ = true;
}
+const ui::TemplateReplacements* WebUIDataSourceImpl::GetReplacements() const {
+ return &replacements_;
+}
+
+void WebUIDataSourceImpl::EnsureLoadTimeDataDefaultsAdded() {
+ if (!add_load_time_data_defaults_)
+ return;
+
+ add_load_time_data_defaults_ = false;
+ std::string locale = GetContentClient()->browser()->GetApplicationLocale();
+ base::DictionaryValue defaults;
+ webui::SetLoadTimeDataDefaults(locale, &defaults);
+ AddLocalizedStrings(defaults);
+}
+
std::string WebUIDataSourceImpl::GetSource() const {
return source_name_;
}
@@ -259,13 +274,7 @@ void WebUIDataSourceImpl::StartDataRequest(
return;
}
- if (add_load_time_data_defaults_) {
- std::string locale = GetContentClient()->browser()->GetApplicationLocale();
- base::DictionaryValue defaults;
- webui::SetLoadTimeDataDefaults(locale, &defaults);
- AddLocalizedStrings(defaults);
- add_load_time_data_defaults_ = false;
- }
+ EnsureLoadTimeDataDefaultsAdded();
if (!json_path_.empty() && path == json_path_) {
SendLocalizedStringsAsJSON(callback);
@@ -282,18 +291,6 @@ void WebUIDataSourceImpl::StartDataRequest(
DCHECK_NE(resource_id, -1);
scoped_refptr<base::RefCountedMemory> response(
GetContentClient()->GetDataResourceBytes(resource_id));
-
- // TODO(dschuyler): improve filtering of which resource to run template
- // expansion upon. TODO(dbeam): make a streaming filter that works on gzipped
- // content.
- if (response.get() && GetMimeType(path) == "text/html" &&
- !source()->IsGzipped(path)) {
- std::string replaced = ui::ReplaceTemplateExpressions(
- base::StringPiece(response->front_as<char>(), response->size()),
- replacements_);
- response = base::RefCountedString::TakeString(&replaced);
- }
-
callback.Run(response.get());
}
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698