| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options/chromeos/cros_language_options_handler
.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler
.h" |
| 6 | 6 |
| 7 #include <algorithm> | |
| 8 #include <iterator> | |
| 9 #include <map> | |
| 10 #include <set> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/bind.h" | 7 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 15 #include "base/i18n/rtl.h" | |
| 16 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/values.h" | 11 #include "base/values.h" |
| 19 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 20 #include "chrome/browser/browser_process.h" | |
| 21 #include "chrome/browser/chromeos/customization_document.h" | |
| 22 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 13 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 23 #include "chrome/browser/chromeos/login/users/user_manager.h" | 14 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 24 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 15 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 25 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
| 26 #include "chrome/browser/lifetime/application_lifetime.h" | 17 #include "chrome/browser/lifetime/application_lifetime.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 29 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 30 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
| 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 23 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
| 32 #include "chrome/common/extensions/manifest_url_handler.h" | 24 #include "chrome/common/extensions/manifest_url_handler.h" |
| 33 #include "chromeos/ime/component_extension_ime_manager.h" | 25 #include "chromeos/ime/component_extension_ime_manager.h" |
| 34 #include "chromeos/ime/extension_ime_util.h" | 26 #include "chromeos/ime/extension_ime_util.h" |
| 35 #include "chromeos/ime/input_method_manager.h" | 27 #include "chromeos/ime/input_method_manager.h" |
| 36 #include "content/public/browser/navigation_controller.h" | 28 #include "content/public/browser/navigation_controller.h" |
| 37 #include "content/public/browser/user_metrics.h" | 29 #include "content/public/browser/user_metrics.h" |
| 38 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
| 39 #include "extensions/browser/extension_registry.h" | 31 #include "extensions/browser/extension_registry.h" |
| 40 #include "extensions/common/extension.h" | 32 #include "extensions/common/extension.h" |
| 41 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
| 42 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 44 | 36 |
| 45 using base::UserMetricsAction; | 37 using base::UserMetricsAction; |
| 46 | 38 |
| 47 namespace { | |
| 48 // TODO(zork): Remove this blacklist when fonts are added to Chrome OS. | |
| 49 // see: crbug.com/240586 | |
| 50 | |
| 51 bool IsBlacklisted(const std::string& language_code) { | |
| 52 return language_code == "si"; // Sinhala | |
| 53 } | |
| 54 | |
| 55 } // namespace | |
| 56 | |
| 57 namespace chromeos { | 39 namespace chromeos { |
| 58 namespace options { | 40 namespace options { |
| 59 | 41 |
| 60 const char kVendorOtherLanguagesListDivider[] = | |
| 61 "VENDOR_OTHER_LANGUAGES_LIST_DIVIDER"; | |
| 62 | |
| 63 CrosLanguageOptionsHandler::CrosLanguageOptionsHandler() | 42 CrosLanguageOptionsHandler::CrosLanguageOptionsHandler() |
| 64 : composition_extension_appended_(false), | 43 : composition_extension_appended_(false), |
| 65 is_page_initialized_(false) { | 44 is_page_initialized_(false) { |
| 66 input_method::InputMethodManager::Get()->GetComponentExtensionIMEManager()-> | 45 input_method::InputMethodManager::Get()->GetComponentExtensionIMEManager()-> |
| 67 AddObserver(this); | 46 AddObserver(this); |
| 68 } | 47 } |
| 69 | 48 |
| 70 CrosLanguageOptionsHandler::~CrosLanguageOptionsHandler() { | 49 CrosLanguageOptionsHandler::~CrosLanguageOptionsHandler() { |
| 71 input_method::InputMethodManager::Get()->GetComponentExtensionIMEManager()-> | 50 input_method::InputMethodManager::Get()->GetComponentExtensionIMEManager()-> |
| 72 RemoveObserver(this); | 51 RemoveObserver(this); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 102 localized_strings->SetString("extensionImeLable", | 81 localized_strings->SetString("extensionImeLable", |
| 103 l10n_util::GetStringUTF16( | 82 l10n_util::GetStringUTF16( |
| 104 IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_EXTENSION_IME)); | 83 IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_EXTENSION_IME)); |
| 105 localized_strings->SetString("extensionImeDescription", | 84 localized_strings->SetString("extensionImeDescription", |
| 106 l10n_util::GetStringUTF16( | 85 l10n_util::GetStringUTF16( |
| 107 IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_EXTENSION_DESCRIPTION)); | 86 IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_EXTENSION_DESCRIPTION)); |
| 108 localized_strings->SetString("noInputMethods", | 87 localized_strings->SetString("noInputMethods", |
| 109 l10n_util::GetStringUTF16( | 88 l10n_util::GetStringUTF16( |
| 110 IDS_OPTIONS_SETTINGS_LANGUAGES_NO_INPUT_METHODS)); | 89 IDS_OPTIONS_SETTINGS_LANGUAGES_NO_INPUT_METHODS)); |
| 111 | 90 |
| 91 // GetSupportedInputMethods() never returns NULL. |
| 92 localized_strings->Set("languageList", GetAcceptLanguageList().release()); |
| 93 localized_strings->Set("inputMethodList", GetInputMethodList()); |
| 94 |
| 112 input_method::InputMethodManager* manager = | 95 input_method::InputMethodManager* manager = |
| 113 input_method::InputMethodManager::Get(); | 96 input_method::InputMethodManager::Get(); |
| 114 // GetSupportedInputMethods() never return NULL. | |
| 115 scoped_ptr<input_method::InputMethodDescriptors> descriptors( | |
| 116 manager->GetSupportedInputMethods()); | |
| 117 localized_strings->Set("languageList", GetAcceptLanguageList(*descriptors)); | |
| 118 localized_strings->Set("inputMethodList", GetInputMethodList(*descriptors)); | |
| 119 | |
| 120 input_method::InputMethodDescriptors ext_ime_descriptors; | 97 input_method::InputMethodDescriptors ext_ime_descriptors; |
| 121 manager->GetInputMethodExtensions(&ext_ime_descriptors); | 98 manager->GetInputMethodExtensions(&ext_ime_descriptors); |
| 122 | 99 |
| 123 base::ListValue* ext_ime_list = ConvertInputMethodDescriptorsToIMEList( | 100 base::ListValue* ext_ime_list = ConvertInputMethodDescriptorsToIMEList( |
| 124 ext_ime_descriptors); | 101 ext_ime_descriptors); |
| 125 AddImeProvider(ext_ime_list); | 102 AddImeProvider(ext_ime_list); |
| 126 localized_strings->Set("extensionImeList", ext_ime_list); | 103 localized_strings->Set("extensionImeList", ext_ime_list); |
| 127 | 104 |
| 128 ComponentExtensionIMEManager* component_extension_manager = | 105 ComponentExtensionIMEManager* component_extension_manager = |
| 129 input_method::InputMethodManager::Get() | 106 input_method::InputMethodManager::Get() |
| (...skipping 23 matching lines...) Expand all Loading... |
| 153 base::Unretained(this))); | 130 base::Unretained(this))); |
| 154 web_ui()->RegisterMessageCallback("inputMethodOptionsOpen", | 131 web_ui()->RegisterMessageCallback("inputMethodOptionsOpen", |
| 155 base::Bind(&CrosLanguageOptionsHandler::InputMethodOptionsOpenCallback, | 132 base::Bind(&CrosLanguageOptionsHandler::InputMethodOptionsOpenCallback, |
| 156 base::Unretained(this))); | 133 base::Unretained(this))); |
| 157 web_ui()->RegisterMessageCallback("uiLanguageRestart", | 134 web_ui()->RegisterMessageCallback("uiLanguageRestart", |
| 158 base::Bind(&CrosLanguageOptionsHandler::RestartCallback, | 135 base::Bind(&CrosLanguageOptionsHandler::RestartCallback, |
| 159 base::Unretained(this))); | 136 base::Unretained(this))); |
| 160 } | 137 } |
| 161 | 138 |
| 162 // static | 139 // static |
| 163 base::ListValue* CrosLanguageOptionsHandler::GetInputMethodList( | 140 base::ListValue* CrosLanguageOptionsHandler::GetInputMethodList() { |
| 164 const input_method::InputMethodDescriptors& descriptors) { | |
| 165 input_method::InputMethodManager* manager = | 141 input_method::InputMethodManager* manager = |
| 166 input_method::InputMethodManager::Get(); | 142 input_method::InputMethodManager::Get(); |
| 143 // GetSupportedInputMethods() never return NULL. |
| 144 scoped_ptr<input_method::InputMethodDescriptors> descriptors( |
| 145 manager->GetSupportedInputMethods()); |
| 167 | 146 |
| 168 base::ListValue* input_method_list = new base::ListValue(); | 147 base::ListValue* input_method_list = new base::ListValue(); |
| 169 | 148 |
| 170 for (size_t i = 0; i < descriptors.size(); ++i) { | 149 for (size_t i = 0; i < descriptors->size(); ++i) { |
| 171 const input_method::InputMethodDescriptor& descriptor = | 150 const input_method::InputMethodDescriptor& descriptor = |
| 172 descriptors[i]; | 151 (*descriptors)[i]; |
| 173 const std::string display_name = | 152 const std::string display_name = |
| 174 manager->GetInputMethodUtil()->GetInputMethodDisplayNameFromId( | 153 manager->GetInputMethodUtil()->GetInputMethodDisplayNameFromId( |
| 175 descriptor.id()); | 154 descriptor.id()); |
| 176 base::DictionaryValue* dictionary = new base::DictionaryValue(); | 155 base::DictionaryValue* dictionary = new base::DictionaryValue(); |
| 177 dictionary->SetString("id", descriptor.id()); | 156 dictionary->SetString("id", descriptor.id()); |
| 178 dictionary->SetString("displayName", display_name); | 157 dictionary->SetString("displayName", display_name); |
| 179 | 158 |
| 180 // One input method can be associated with multiple languages, hence | 159 // One input method can be associated with multiple languages, hence |
| 181 // we use a dictionary here. | 160 // we use a dictionary here. |
| 182 base::DictionaryValue* languages = new base::DictionaryValue(); | 161 base::DictionaryValue* languages = new base::DictionaryValue(); |
| 183 for (size_t i = 0; i < descriptor.language_codes().size(); ++i) { | 162 for (size_t i = 0; i < descriptor.language_codes().size(); ++i) { |
| 184 languages->SetBoolean(descriptor.language_codes().at(i), true); | 163 languages->SetBoolean(descriptor.language_codes().at(i), true); |
| 185 } | 164 } |
| 186 dictionary->Set("languageCodeSet", languages); | 165 dictionary->Set("languageCodeSet", languages); |
| 187 | 166 |
| 188 input_method_list->Append(dictionary); | 167 input_method_list->Append(dictionary); |
| 189 } | 168 } |
| 190 | 169 |
| 191 return input_method_list; | 170 return input_method_list; |
| 192 } | 171 } |
| 193 | 172 |
| 194 // static | |
| 195 base::ListValue* CrosLanguageOptionsHandler::GetLanguageListInternal( | |
| 196 const input_method::InputMethodDescriptors& descriptors, | |
| 197 const std::vector<std::string>& base_language_codes, | |
| 198 const bool insert_divider) { | |
| 199 const std::string app_locale = g_browser_process->GetApplicationLocale(); | |
| 200 | |
| 201 std::set<std::string> language_codes; | |
| 202 // Collect the language codes from the supported input methods. | |
| 203 for (size_t i = 0; i < descriptors.size(); ++i) { | |
| 204 const input_method::InputMethodDescriptor& descriptor = descriptors[i]; | |
| 205 const std::vector<std::string>& languages = | |
| 206 descriptor.language_codes(); | |
| 207 for (size_t i = 0; i < languages.size(); ++i) | |
| 208 language_codes.insert(languages[i]); | |
| 209 } | |
| 210 | |
| 211 const StartupCustomizationDocument* startup_manifest = | |
| 212 StartupCustomizationDocument::GetInstance(); | |
| 213 | |
| 214 const std::vector<std::string>& configured_locales = | |
| 215 startup_manifest->configured_locales(); | |
| 216 | |
| 217 // Languages sort order. | |
| 218 std::map<std::string, int /* index */> language_index; | |
| 219 for (size_t i = 0; i < configured_locales.size(); ++i) { | |
| 220 language_index[configured_locales[i]] = i; | |
| 221 } | |
| 222 | |
| 223 // Map of display name -> {language code, native_display_name}. | |
| 224 // In theory, we should be able to create a map that is sorted by | |
| 225 // display names using ICU comparator, but doing it is hard, thus we'll | |
| 226 // use an auxiliary vector to achieve the same result. | |
| 227 typedef std::pair<std::string, base::string16> LanguagePair; | |
| 228 typedef std::map<base::string16, LanguagePair> LanguageMap; | |
| 229 LanguageMap language_map; | |
| 230 | |
| 231 // The auxiliary vector mentioned above. (except vendor locales) | |
| 232 std::vector<base::string16> display_names; | |
| 233 | |
| 234 // Separate vector of vendor locales. | |
| 235 std::vector<base::string16> configured_locales_display_names( | |
| 236 configured_locales.size()); | |
| 237 | |
| 238 size_t configured_locales_count = 0; | |
| 239 | |
| 240 // Build the list of display names, and build the language map. | |
| 241 | |
| 242 // The list of configured locales might have entries not in | |
| 243 // base_language_codes. If there are unsupported language variants, | |
| 244 // but they resolve to backup locale within base_language_codes, also | |
| 245 // add them to the list. | |
| 246 for (std::map<std::string, int>::const_iterator iter = language_index.begin(); | |
| 247 iter != language_index.end(); | |
| 248 ++iter) { | |
| 249 const std::string& language_id = iter->first; | |
| 250 const int language_idx = iter->second; | |
| 251 | |
| 252 const size_t dash_pos = language_id.find_first_of('-'); | |
| 253 | |
| 254 // Ignore non-specific codes. | |
| 255 if (dash_pos == std::string::npos || dash_pos == 0) | |
| 256 continue; | |
| 257 | |
| 258 if (std::find(base_language_codes.begin(), | |
| 259 base_language_codes.end(), | |
| 260 language_id) != base_language_codes.end()) { | |
| 261 // Language is supported. No need to replace | |
| 262 continue; | |
| 263 } | |
| 264 std::string resolved_locale; | |
| 265 if (!l10n_util::CheckAndResolveLocale(language_id, &resolved_locale)) | |
| 266 continue; | |
| 267 | |
| 268 if (std::find(base_language_codes.begin(), | |
| 269 base_language_codes.end(), | |
| 270 resolved_locale) == base_language_codes.end()) { | |
| 271 // Resolved locale is not supported. | |
| 272 continue; | |
| 273 } | |
| 274 | |
| 275 const base::string16 display_name = | |
| 276 l10n_util::GetDisplayNameForLocale(language_id, app_locale, true); | |
| 277 const base::string16 native_display_name = | |
| 278 l10n_util::GetDisplayNameForLocale( | |
| 279 language_id, language_id, true); | |
| 280 | |
| 281 language_map[display_name] = | |
| 282 std::make_pair(language_id, native_display_name); | |
| 283 | |
| 284 configured_locales_display_names[language_idx] = display_name; | |
| 285 ++configured_locales_count; | |
| 286 } | |
| 287 | |
| 288 // Translate language codes, generated from input methods. | |
| 289 for (std::set<std::string>::const_iterator iter = language_codes.begin(); | |
| 290 iter != language_codes.end(); ++iter) { | |
| 291 // Exclude the language which is not in |base_langauge_codes| even it has | |
| 292 // input methods. | |
| 293 if (std::find(base_language_codes.begin(), | |
| 294 base_language_codes.end(), | |
| 295 *iter) == base_language_codes.end()) { | |
| 296 continue; | |
| 297 } | |
| 298 | |
| 299 const base::string16 display_name = | |
| 300 l10n_util::GetDisplayNameForLocale(*iter, app_locale, true); | |
| 301 const base::string16 native_display_name = | |
| 302 l10n_util::GetDisplayNameForLocale(*iter, *iter, true); | |
| 303 | |
| 304 language_map[display_name] = | |
| 305 std::make_pair(*iter, native_display_name); | |
| 306 | |
| 307 const std::map<std::string, int>::const_iterator index_pos = | |
| 308 language_index.find(*iter); | |
| 309 if (index_pos != language_index.end()) { | |
| 310 base::string16& stored_display_name = | |
| 311 configured_locales_display_names[index_pos->second]; | |
| 312 if (stored_display_name.empty()) { | |
| 313 stored_display_name = display_name; | |
| 314 ++configured_locales_count; | |
| 315 } | |
| 316 } else { | |
| 317 display_names.push_back(display_name); | |
| 318 } | |
| 319 } | |
| 320 DCHECK_EQ(display_names.size() + configured_locales_count, | |
| 321 language_map.size()); | |
| 322 | |
| 323 // Build the list of display names, and build the language map. | |
| 324 for (size_t i = 0; i < base_language_codes.size(); ++i) { | |
| 325 // Skip this language if it was already added. | |
| 326 if (language_codes.find(base_language_codes[i]) != language_codes.end()) | |
| 327 continue; | |
| 328 | |
| 329 // TODO(zork): Remove this blacklist when fonts are added to Chrome OS. | |
| 330 // see: crbug.com/240586 | |
| 331 if (IsBlacklisted(base_language_codes[i])) | |
| 332 continue; | |
| 333 | |
| 334 base::string16 display_name = | |
| 335 l10n_util::GetDisplayNameForLocale( | |
| 336 base_language_codes[i], app_locale, false); | |
| 337 base::string16 native_display_name = | |
| 338 l10n_util::GetDisplayNameForLocale( | |
| 339 base_language_codes[i], base_language_codes[i], false); | |
| 340 language_map[display_name] = | |
| 341 std::make_pair(base_language_codes[i], native_display_name); | |
| 342 | |
| 343 const std::map<std::string, int>::const_iterator index_pos = | |
| 344 language_index.find(base_language_codes[i]); | |
| 345 if (index_pos != language_index.end()) { | |
| 346 configured_locales_display_names[index_pos->second] = display_name; | |
| 347 ++configured_locales_count; | |
| 348 } else { | |
| 349 display_names.push_back(display_name); | |
| 350 } | |
| 351 } | |
| 352 | |
| 353 // Sort display names using locale specific sorter. | |
| 354 l10n_util::SortStrings16(app_locale, &display_names); | |
| 355 // Concatenate configured_locales_display_names and display_names. | |
| 356 // Insert special divider in between. | |
| 357 std::vector<base::string16> out_display_names; | |
| 358 for (size_t i = 0; i < configured_locales_display_names.size(); ++i) { | |
| 359 if (configured_locales_display_names[i].size() == 0) | |
| 360 continue; | |
| 361 out_display_names.push_back(configured_locales_display_names[i]); | |
| 362 } | |
| 363 | |
| 364 base::string16 divider16; | |
| 365 if (insert_divider) { | |
| 366 divider16 = base::ASCIIToUTF16( | |
| 367 insert_divider ? "" : kVendorOtherLanguagesListDivider); | |
| 368 out_display_names.push_back(divider16); | |
| 369 } | |
| 370 | |
| 371 std::copy(display_names.begin(), | |
| 372 display_names.end(), | |
| 373 std::back_inserter(out_display_names)); | |
| 374 | |
| 375 // Build the language list from the language map. | |
| 376 base::ListValue* language_list = new base::ListValue(); | |
| 377 for (size_t i = 0; i < out_display_names.size(); ++i) { | |
| 378 // Sets the directionality of the display language name. | |
| 379 base::string16 display_name(out_display_names[i]); | |
| 380 if (insert_divider && display_name == divider16) { | |
| 381 // Insert divider. | |
| 382 base::DictionaryValue* dictionary = new base::DictionaryValue(); | |
| 383 dictionary->SetString("code", kVendorOtherLanguagesListDivider); | |
| 384 language_list->Append(dictionary); | |
| 385 continue; | |
| 386 } | |
| 387 bool markup_removal = | |
| 388 base::i18n::UnadjustStringForLocaleDirection(&display_name); | |
| 389 DCHECK(markup_removal); | |
| 390 bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(display_name); | |
| 391 std::string directionality = has_rtl_chars ? "rtl" : "ltr"; | |
| 392 | |
| 393 const LanguagePair& pair = language_map[out_display_names[i]]; | |
| 394 base::DictionaryValue* dictionary = new base::DictionaryValue(); | |
| 395 dictionary->SetString("code", pair.first); | |
| 396 dictionary->SetString("displayName", out_display_names[i]); | |
| 397 dictionary->SetString("textDirection", directionality); | |
| 398 dictionary->SetString("nativeDisplayName", pair.second); | |
| 399 language_list->Append(dictionary); | |
| 400 } | |
| 401 | |
| 402 return language_list; | |
| 403 } | |
| 404 | |
| 405 // static | |
| 406 base::ListValue* CrosLanguageOptionsHandler::GetAcceptLanguageList( | |
| 407 const input_method::InputMethodDescriptors& descriptors) { | |
| 408 // Collect the language codes from the supported accept-languages. | |
| 409 const std::string app_locale = g_browser_process->GetApplicationLocale(); | |
| 410 std::vector<std::string> accept_language_codes; | |
| 411 l10n_util::GetAcceptLanguagesForLocale(app_locale, &accept_language_codes); | |
| 412 return GetLanguageListInternal(descriptors, accept_language_codes, false); | |
| 413 } | |
| 414 | |
| 415 // static | |
| 416 base::ListValue* CrosLanguageOptionsHandler::GetUILanguageList( | |
| 417 const input_method::InputMethodDescriptors& descriptors) { | |
| 418 // Collect the language codes from the available locales. | |
| 419 return GetLanguageListInternal( | |
| 420 descriptors, l10n_util::GetAvailableLocales(), true); | |
| 421 } | |
| 422 | |
| 423 base::ListValue* | 173 base::ListValue* |
| 424 CrosLanguageOptionsHandler::ConvertInputMethodDescriptorsToIMEList( | 174 CrosLanguageOptionsHandler::ConvertInputMethodDescriptorsToIMEList( |
| 425 const input_method::InputMethodDescriptors& descriptors) { | 175 const input_method::InputMethodDescriptors& descriptors) { |
| 426 scoped_ptr<base::ListValue> ime_ids_list(new base::ListValue()); | 176 scoped_ptr<base::ListValue> ime_ids_list(new base::ListValue()); |
| 427 for (size_t i = 0; i < descriptors.size(); ++i) { | 177 for (size_t i = 0; i < descriptors.size(); ++i) { |
| 428 const input_method::InputMethodDescriptor& descriptor = descriptors[i]; | 178 const input_method::InputMethodDescriptor& descriptor = descriptors[i]; |
| 429 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue()); | 179 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue()); |
| 430 dictionary->SetString("id", descriptor.id()); | 180 dictionary->SetString("id", descriptor.id()); |
| 431 dictionary->SetString("displayName", descriptor.name()); | 181 dictionary->SetString("displayName", descriptor.name()); |
| 432 dictionary->SetString("optionsPage", descriptor.options_page_url().spec()); | 182 dictionary->SetString("optionsPage", descriptor.options_page_url().spec()); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id); | 318 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id); |
| 569 const extensions::Extension* extension = | 319 const extensions::Extension* extension = |
| 570 enabled_extensions.GetByID(extension_id); | 320 enabled_extensions.GetByID(extension_id); |
| 571 if (extension) | 321 if (extension) |
| 572 entry->SetString("extensionName", extension->name()); | 322 entry->SetString("extensionName", extension->name()); |
| 573 } | 323 } |
| 574 } | 324 } |
| 575 | 325 |
| 576 } // namespace options | 326 } // namespace options |
| 577 } // namespace chromeos | 327 } // namespace chromeos |
| OLD | NEW |