Commit 917dcb41 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Remove deprecated SetString in WebUIDataSourceImpl

This removes the use of the deprecated method
DictionaryValue::SetString in WebUIDataSourceImpl.

It also fixes an unintended side effect where

WebUIDataSourceImpl::Add{Localized}String("foo.bar", value)
would create a nested 'foo' dictionary in the JS string
list, causing "foo.bar" to fail to localize when using
loadTimeData.getString('foo.bar').

Bug: None
Change-Id: I1da5f7da168acb681b93bbacccd361bea07800a7
Reviewed-on: https://chromium-review.googlesource.com/875158Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarDave Schuyler <dschuyler@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530542}
parent 26ecbe37
......@@ -115,22 +115,21 @@ WebUIDataSourceImpl::~WebUIDataSourceImpl() {
void WebUIDataSourceImpl::AddString(const std::string& name,
const base::string16& value) {
// TODO(dschuyler): Share only one copy of these strings.
localized_strings_.SetString(name, value);
localized_strings_.SetKey(name, base::Value(value));
replacements_[name] = base::UTF16ToUTF8(value);
}
void WebUIDataSourceImpl::AddString(const std::string& name,
const std::string& value) {
localized_strings_.SetString(name, value);
localized_strings_.SetKey(name, base::Value(value));
replacements_[name] = value;
}
void WebUIDataSourceImpl::AddLocalizedString(const std::string& name,
int ids) {
localized_strings_.SetString(
name, GetContentClient()->GetLocalizedString(ids));
replacements_[name] =
void WebUIDataSourceImpl::AddLocalizedString(const std::string& name, int ids) {
std::string utf8_str =
base::UTF16ToUTF8(GetContentClient()->GetLocalizedString(ids));
localized_strings_.SetKey(name, base::Value(utf8_str));
replacements_[name] = utf8_str;
}
void WebUIDataSourceImpl::AddLocalizedStrings(
......
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