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

Side by Side Diff: chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc

Issue 2030013003: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/translate_internals/translate_internals_handle r.h" 5 #include "chrome/browser/ui/webui/translate_internals/translate_internals_handle r.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 std::vector<std::string> languages; 225 std::vector<std::string> languages;
226 translate::TranslateDownloadManager::GetSupportedLanguages(&languages); 226 translate::TranslateDownloadManager::GetSupportedLanguages(&languages);
227 base::Time last_updated = 227 base::Time last_updated =
228 translate::TranslateDownloadManager::GetSupportedLanguagesLastUpdated(); 228 translate::TranslateDownloadManager::GetSupportedLanguagesLastUpdated();
229 229
230 base::ListValue* languages_list = new base::ListValue(); 230 base::ListValue* languages_list = new base::ListValue();
231 base::ListValue* alpha_languages_list = new base::ListValue(); 231 base::ListValue* alpha_languages_list = new base::ListValue();
232 for (std::vector<std::string>::iterator it = languages.begin(); 232 for (std::vector<std::string>::iterator it = languages.begin();
233 it != languages.end(); ++it) { 233 it != languages.end(); ++it) {
234 const std::string& lang = *it; 234 const std::string& lang = *it;
235 languages_list->Append(new base::StringValue(lang)); 235 languages_list->AppendString(lang);
236 if (translate::TranslateDownloadManager::IsAlphaLanguage(lang)) 236 if (translate::TranslateDownloadManager::IsAlphaLanguage(lang))
237 alpha_languages_list->Append(new base::StringValue(lang)); 237 alpha_languages_list->AppendString(lang);
238 } 238 }
239 239
240 dict.Set("languages", languages_list); 240 dict.Set("languages", languages_list);
241 dict.Set("alpha_languages", alpha_languages_list); 241 dict.Set("alpha_languages", alpha_languages_list);
242 dict.Set("last_updated", new base::FundamentalValue(last_updated.ToJsTime())); 242 dict.Set("last_updated", new base::FundamentalValue(last_updated.ToJsTime()));
243 SendMessageToJs("supportedLanguagesUpdated", dict); 243 SendMessageToJs("supportedLanguagesUpdated", dict);
244 } 244 }
245 245
246 void TranslateInternalsHandler::SendCountryToJs(bool was_updated) { 246 void TranslateInternalsHandler::SendCountryToJs(bool was_updated) {
247 std::string country; 247 std::string country;
248 variations::VariationsService* variations_service = 248 variations::VariationsService* variations_service =
249 g_browser_process->variations_service(); 249 g_browser_process->variations_service();
250 if (variations_service) 250 if (variations_service)
251 country = variations_service->GetStoredPermanentCountry(); 251 country = variations_service->GetStoredPermanentCountry();
252 252
253 base::DictionaryValue dict; 253 base::DictionaryValue dict;
254 if (!country.empty()) { 254 if (!country.empty()) {
255 dict.Set("country", new base::StringValue(country)); 255 dict.Set("country", new base::StringValue(country));
256 dict.Set("update", new base::FundamentalValue(was_updated)); 256 dict.Set("update", new base::FundamentalValue(was_updated));
257 } 257 }
258 SendMessageToJs("countryUpdated", dict); 258 SendMessageToJs("countryUpdated", dict);
259 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698