| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/dom_ui/language_options_handler.h" | 5 #include "chrome/browser/chromeos/dom_ui/language_options_handler.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 12 #include "chrome/browser/chromeos/cros/input_method_library.h" |
| 11 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 13 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 12 #include "grit/chromium_strings.h" | 14 #include "grit/chromium_strings.h" |
| 13 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 14 | 16 |
| 15 LanguageOptionsHandler::LanguageOptionsHandler() { | 17 LanguageOptionsHandler::LanguageOptionsHandler() { |
| 16 } | 18 } |
| 17 | 19 |
| 18 LanguageOptionsHandler::~LanguageOptionsHandler() { | 20 LanguageOptionsHandler::~LanguageOptionsHandler() { |
| 19 } | 21 } |
| 20 | 22 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 44 IDS_OPTIONS_SETTINGS_LANGUAGES_DISPLAY_IN_THIS_LANGUAGE, | 46 IDS_OPTIONS_SETTINGS_LANGUAGES_DISPLAY_IN_THIS_LANGUAGE, |
| 45 l10n_util::GetString(IDS_PRODUCT_OS_NAME))); | 47 l10n_util::GetString(IDS_PRODUCT_OS_NAME))); |
| 46 | 48 |
| 47 // Build mappings of locale code (language code) to display name | 49 // Build mappings of locale code (language code) to display name |
| 48 // (ex. "en-US" => "English (United States)". | 50 // (ex. "en-US" => "English (United States)". |
| 49 const std::vector<std::string>& locales = l10n_util::GetAvailableLocales(); | 51 const std::vector<std::string>& locales = l10n_util::GetAvailableLocales(); |
| 50 for (size_t i = 0; i < locales.size(); ++i) { | 52 for (size_t i = 0; i < locales.size(); ++i) { |
| 51 localized_strings->SetString(UTF8ToWide(locales[i]), | 53 localized_strings->SetString(UTF8ToWide(locales[i]), |
| 52 chromeos::input_method::GetLanguageDisplayNameFromCode(locales[i])); | 54 chromeos::input_method::GetLanguageDisplayNameFromCode(locales[i])); |
| 53 } | 55 } |
| 56 |
| 57 localized_strings->Set(L"inputMethodList", GetInputMethodList()); |
| 54 } | 58 } |
| 59 |
| 60 ListValue* LanguageOptionsHandler::GetInputMethodList() { |
| 61 using chromeos::CrosLibrary; |
| 62 |
| 63 ListValue* input_method_list = new ListValue(); |
| 64 |
| 65 // GetSupportedLanguages() never return NULL. |
| 66 scoped_ptr<chromeos::InputMethodDescriptors> descriptors( |
| 67 CrosLibrary::Get()->GetInputMethodLibrary()->GetSupportedInputMethods()); |
| 68 for (size_t i = 0; i < descriptors->size(); ++i) { |
| 69 const chromeos::InputMethodDescriptor& descriptor = descriptors->at(i); |
| 70 const std::string language_code = |
| 71 chromeos::input_method::GetLanguageCodeFromDescriptor(descriptor); |
| 72 const std::string display_name = |
| 73 chromeos::input_method::GetInputMethodDisplayNameFromId(descriptor.id); |
| 74 |
| 75 DictionaryValue* dictionary = new DictionaryValue(); |
| 76 dictionary->SetString(L"id", UTF8ToWide(descriptor.id)); |
| 77 dictionary->SetString(L"displayName", UTF8ToWide(display_name)); |
| 78 dictionary->SetString(L"languageCode", UTF8ToWide(language_code)); |
| 79 input_method_list->Append(dictionary); |
| 80 } |
| 81 |
| 82 return input_method_list; |
| 83 } |
| OLD | NEW |