| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/language_settings_private/language_setti
ngs_private_api.h" | 5 #include "chrome/browser/extensions/api/language_settings_private/language_setti
ngs_private_api.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 LanguageSettingsPrivateGetSpellcheckDictionaryStatusesFunction:: | 168 LanguageSettingsPrivateGetSpellcheckDictionaryStatusesFunction:: |
| 169 ~LanguageSettingsPrivateGetSpellcheckDictionaryStatusesFunction() { | 169 ~LanguageSettingsPrivateGetSpellcheckDictionaryStatusesFunction() { |
| 170 } | 170 } |
| 171 | 171 |
| 172 ExtensionFunction::ResponseAction | 172 ExtensionFunction::ResponseAction |
| 173 LanguageSettingsPrivateGetSpellcheckDictionaryStatusesFunction::Run() { | 173 LanguageSettingsPrivateGetSpellcheckDictionaryStatusesFunction::Run() { |
| 174 LanguageSettingsPrivateDelegate* delegate = | 174 LanguageSettingsPrivateDelegate* delegate = |
| 175 LanguageSettingsPrivateDelegateFactory::GetForBrowserContext( | 175 LanguageSettingsPrivateDelegateFactory::GetForBrowserContext( |
| 176 browser_context()); | 176 browser_context()); |
| 177 | 177 |
| 178 scoped_ptr<base::ListValue> return_list(new base::ListValue()); | 178 return RespondNow(OneArgument( |
| 179 for (const auto& status : delegate->GetHunspellDictionaryStatuses()) | 179 language_settings_private::GetSpellcheckDictionaryStatuses::Results:: |
| 180 return_list->Append(status->ToValue()); | 180 Create(delegate->GetHunspellDictionaryStatuses()))); |
| 181 return RespondNow(OneArgument(return_list.release())); | |
| 182 } | 181 } |
| 183 | 182 |
| 184 LanguageSettingsPrivateGetSpellcheckWordsFunction:: | 183 LanguageSettingsPrivateGetSpellcheckWordsFunction:: |
| 185 LanguageSettingsPrivateGetSpellcheckWordsFunction() { | 184 LanguageSettingsPrivateGetSpellcheckWordsFunction() { |
| 186 } | 185 } |
| 187 | 186 |
| 188 LanguageSettingsPrivateGetSpellcheckWordsFunction:: | 187 LanguageSettingsPrivateGetSpellcheckWordsFunction:: |
| 189 ~LanguageSettingsPrivateGetSpellcheckWordsFunction() { | 188 ~LanguageSettingsPrivateGetSpellcheckWordsFunction() { |
| 190 } | 189 } |
| 191 | 190 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return RespondNow(OneArgument(new base::StringValue( | 290 return RespondNow(OneArgument(new base::StringValue( |
| 292 TranslateService::GetTargetLanguage( | 291 TranslateService::GetTargetLanguage( |
| 293 chrome_details_.GetProfile()->GetPrefs())))); | 292 chrome_details_.GetProfile()->GetPrefs())))); |
| 294 } | 293 } |
| 295 | 294 |
| 296 #if defined(OS_CHROMEOS) | 295 #if defined(OS_CHROMEOS) |
| 297 // Populates the vector of input methods using information in the list of | 296 // Populates the vector of input methods using information in the list of |
| 298 // descriptors. Used for languageSettingsPrivate.getInputMethodLists(). | 297 // descriptors. Used for languageSettingsPrivate.getInputMethodLists(). |
| 299 void PopulateInputMethodListFromDescriptors( | 298 void PopulateInputMethodListFromDescriptors( |
| 300 const InputMethodDescriptors& descriptors, | 299 const InputMethodDescriptors& descriptors, |
| 301 std::vector<linked_ptr<language_settings_private::InputMethod>>* | 300 std::vector<language_settings_private::InputMethod>* input_methods) { |
| 302 input_methods) { | |
| 303 InputMethodManager* manager = InputMethodManager::Get(); | 301 InputMethodManager* manager = InputMethodManager::Get(); |
| 304 InputMethodUtil* util = manager->GetInputMethodUtil(); | 302 InputMethodUtil* util = manager->GetInputMethodUtil(); |
| 305 scoped_refptr<InputMethodManager::State> ime_state = | 303 scoped_refptr<InputMethodManager::State> ime_state = |
| 306 manager->GetActiveIMEState(); | 304 manager->GetActiveIMEState(); |
| 307 if (!ime_state.get()) | 305 if (!ime_state.get()) |
| 308 return; | 306 return; |
| 309 | 307 |
| 310 // Get the list of enabled IDs and convert to a set for membership testing. | 308 // Get the list of enabled IDs and convert to a set for membership testing. |
| 311 const std::vector<std::string>& active_ids_list = | 309 const std::vector<std::string>& active_ids_list = |
| 312 ime_state->GetActiveInputMethodIds(); | 310 ime_state->GetActiveInputMethodIds(); |
| 313 const std::set<std::string> active_ids( | 311 const std::set<std::string> active_ids( |
| 314 active_ids_list.begin(), active_ids_list.end()); | 312 active_ids_list.begin(), active_ids_list.end()); |
| 315 | 313 |
| 316 for (const auto& descriptor : descriptors) { | 314 for (const auto& descriptor : descriptors) { |
| 317 linked_ptr<language_settings_private::InputMethod> input_method( | 315 language_settings_private::InputMethod input_method; |
| 318 new language_settings_private::InputMethod()); | 316 input_method.id = descriptor.id(); |
| 319 input_method->id = descriptor.id(); | 317 input_method.display_name = util->GetLocalizedDisplayName(descriptor); |
| 320 input_method->display_name = util->GetLocalizedDisplayName(descriptor); | 318 input_method.language_codes = descriptor.language_codes(); |
| 321 input_method->language_codes = descriptor.language_codes(); | 319 bool enabled = active_ids.find(input_method.id) != active_ids.end(); |
| 322 bool enabled = active_ids.find(input_method->id) != active_ids.end(); | |
| 323 if (enabled) | 320 if (enabled) |
| 324 input_method->enabled.reset(new bool(true)); | 321 input_method.enabled.reset(new bool(true)); |
| 325 if (descriptor.options_page_url().is_valid()) | 322 if (descriptor.options_page_url().is_valid()) |
| 326 input_method->has_options_page.reset(new bool(true)); | 323 input_method.has_options_page.reset(new bool(true)); |
| 327 input_methods->push_back(input_method); | 324 input_methods->push_back(std::move(input_method)); |
| 328 } | 325 } |
| 329 } | 326 } |
| 330 #endif | 327 #endif |
| 331 | 328 |
| 332 LanguageSettingsPrivateGetInputMethodListsFunction:: | 329 LanguageSettingsPrivateGetInputMethodListsFunction:: |
| 333 LanguageSettingsPrivateGetInputMethodListsFunction() { | 330 LanguageSettingsPrivateGetInputMethodListsFunction() { |
| 334 } | 331 } |
| 335 | 332 |
| 336 LanguageSettingsPrivateGetInputMethodListsFunction:: | 333 LanguageSettingsPrivateGetInputMethodListsFunction:: |
| 337 ~LanguageSettingsPrivateGetInputMethodListsFunction() { | 334 ~LanguageSettingsPrivateGetInputMethodListsFunction() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 LanguageSettingsPrivateRemoveInputMethodFunction:: | 383 LanguageSettingsPrivateRemoveInputMethodFunction:: |
| 387 ~LanguageSettingsPrivateRemoveInputMethodFunction() { | 384 ~LanguageSettingsPrivateRemoveInputMethodFunction() { |
| 388 } | 385 } |
| 389 | 386 |
| 390 ExtensionFunction::ResponseAction | 387 ExtensionFunction::ResponseAction |
| 391 LanguageSettingsPrivateRemoveInputMethodFunction::Run() { | 388 LanguageSettingsPrivateRemoveInputMethodFunction::Run() { |
| 392 return RespondNow(OneArgument(new base::FundamentalValue(true))); | 389 return RespondNow(OneArgument(new base::FundamentalValue(true))); |
| 393 } | 390 } |
| 394 | 391 |
| 395 } // namespace extensions | 392 } // namespace extensions |
| OLD | NEW |