OLD | NEW |
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 "components/translate/core/browser/translate_language_list.h" | 5 #include "components/translate/core/browser/translate_language_list.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 bool TranslateLanguageList::SetSupportedLanguages( | 283 bool TranslateLanguageList::SetSupportedLanguages( |
284 const std::string& language_list) { | 284 const std::string& language_list) { |
285 // The format is in JSON as: | 285 // The format is in JSON as: |
286 // { | 286 // { |
287 // "sl": {"XX": "LanguageName", ...}, | 287 // "sl": {"XX": "LanguageName", ...}, |
288 // "tl": {"XX": "LanguageName", ...}, | 288 // "tl": {"XX": "LanguageName", ...}, |
289 // "al": {"XX": 1, ...} | 289 // "al": {"XX": 1, ...} |
290 // } | 290 // } |
291 // Where "tl" and "al" are set in kTargetLanguagesKey and kAlphaLanguagesKey. | 291 // Where "tl" and "al" are set in kTargetLanguagesKey and kAlphaLanguagesKey. |
292 scoped_ptr<base::Value> json_value(base::JSONReader::DeprecatedRead( | 292 scoped_ptr<base::Value> json_value = |
293 language_list, base::JSON_ALLOW_TRAILING_COMMAS)); | 293 base::JSONReader::Read(language_list, base::JSON_ALLOW_TRAILING_COMMAS); |
294 | 294 |
295 if (json_value == NULL || !json_value->IsType(base::Value::TYPE_DICTIONARY)) { | 295 if (json_value == NULL || !json_value->IsType(base::Value::TYPE_DICTIONARY)) { |
296 NotifyEvent(__LINE__, "Language list is invalid"); | 296 NotifyEvent(__LINE__, "Language list is invalid"); |
297 NOTREACHED(); | 297 NOTREACHED(); |
298 return false; | 298 return false; |
299 } | 299 } |
300 // The first level dictionary contains three sub-dict, first for source | 300 // The first level dictionary contains three sub-dict, first for source |
301 // languages and second for target languages, we want to use the target | 301 // languages and second for target languages, we want to use the target |
302 // languages. The last is for alpha languages. | 302 // languages. The last is for alpha languages. |
303 base::DictionaryValue* language_dict = | 303 base::DictionaryValue* language_dict = |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 !iter.IsAtEnd(); iter.Advance()) { | 350 !iter.IsAtEnd(); iter.Advance()) { |
351 const std::string& lang = iter.key(); | 351 const std::string& lang = iter.key(); |
352 if (!l10n_util::IsLocaleNameTranslated(lang.c_str(), locale)) | 352 if (!l10n_util::IsLocaleNameTranslated(lang.c_str(), locale)) |
353 continue; | 353 continue; |
354 alpha_languages_.insert(lang); | 354 alpha_languages_.insert(lang); |
355 } | 355 } |
356 return true; | 356 return true; |
357 } | 357 } |
358 | 358 |
359 } // namespace translate | 359 } // namespace translate |
OLD | NEW |