| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 web_ui()->RegisterMessageCallback("uiLanguageRestart", | 130 web_ui()->RegisterMessageCallback("uiLanguageRestart", |
| 131 base::Bind(&CrosLanguageOptionsHandler::RestartCallback, | 131 base::Bind(&CrosLanguageOptionsHandler::RestartCallback, |
| 132 base::Unretained(this))); | 132 base::Unretained(this))); |
| 133 } | 133 } |
| 134 | 134 |
| 135 // static | 135 // static |
| 136 base::ListValue* CrosLanguageOptionsHandler::GetInputMethodList() { | 136 base::ListValue* CrosLanguageOptionsHandler::GetInputMethodList() { |
| 137 input_method::InputMethodManager* manager = | 137 input_method::InputMethodManager* manager = |
| 138 input_method::InputMethodManager::Get(); | 138 input_method::InputMethodManager::Get(); |
| 139 // GetSupportedInputMethods() never return NULL. | 139 // GetSupportedInputMethods() never return NULL. |
| 140 scoped_ptr<input_method::InputMethodDescriptors> descriptors( | 140 std::unique_ptr<input_method::InputMethodDescriptors> descriptors( |
| 141 manager->GetSupportedInputMethods()); | 141 manager->GetSupportedInputMethods()); |
| 142 | 142 |
| 143 base::ListValue* input_method_list = new base::ListValue(); | 143 base::ListValue* input_method_list = new base::ListValue(); |
| 144 | 144 |
| 145 for (size_t i = 0; i < descriptors->size(); ++i) { | 145 for (size_t i = 0; i < descriptors->size(); ++i) { |
| 146 const input_method::InputMethodDescriptor& descriptor = | 146 const input_method::InputMethodDescriptor& descriptor = |
| 147 (*descriptors)[i]; | 147 (*descriptors)[i]; |
| 148 const std::string display_name = | 148 const std::string display_name = |
| 149 manager->GetInputMethodUtil()->GetInputMethodDisplayNameFromId( | 149 manager->GetInputMethodUtil()->GetInputMethodDisplayNameFromId( |
| 150 descriptor.id()); | 150 descriptor.id()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 return input_method_list; | 166 return input_method_list; |
| 167 } | 167 } |
| 168 | 168 |
| 169 base::ListValue* | 169 base::ListValue* |
| 170 CrosLanguageOptionsHandler::ConvertInputMethodDescriptorsToIMEList( | 170 CrosLanguageOptionsHandler::ConvertInputMethodDescriptorsToIMEList( |
| 171 const input_method::InputMethodDescriptors& descriptors) { | 171 const input_method::InputMethodDescriptors& descriptors) { |
| 172 input_method::InputMethodUtil* util = | 172 input_method::InputMethodUtil* util = |
| 173 input_method::InputMethodManager::Get()->GetInputMethodUtil(); | 173 input_method::InputMethodManager::Get()->GetInputMethodUtil(); |
| 174 scoped_ptr<base::ListValue> ime_ids_list(new base::ListValue()); | 174 std::unique_ptr<base::ListValue> ime_ids_list(new base::ListValue()); |
| 175 for (size_t i = 0; i < descriptors.size(); ++i) { | 175 for (size_t i = 0; i < descriptors.size(); ++i) { |
| 176 const input_method::InputMethodDescriptor& descriptor = descriptors[i]; | 176 const input_method::InputMethodDescriptor& descriptor = descriptors[i]; |
| 177 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue()); | 177 std::unique_ptr<base::DictionaryValue> dictionary( |
| 178 new base::DictionaryValue()); |
| 178 dictionary->SetString("id", descriptor.id()); | 179 dictionary->SetString("id", descriptor.id()); |
| 179 dictionary->SetString( | 180 dictionary->SetString( |
| 180 "displayName", util->GetLocalizedDisplayName(descriptor)); | 181 "displayName", util->GetLocalizedDisplayName(descriptor)); |
| 181 dictionary->SetString("optionsPage", descriptor.options_page_url().spec()); | 182 dictionary->SetString("optionsPage", descriptor.options_page_url().spec()); |
| 182 scoped_ptr<base::DictionaryValue> language_codes( | 183 std::unique_ptr<base::DictionaryValue> language_codes( |
| 183 new base::DictionaryValue()); | 184 new base::DictionaryValue()); |
| 184 for (size_t i = 0; i < descriptor.language_codes().size(); ++i) | 185 for (size_t i = 0; i < descriptor.language_codes().size(); ++i) |
| 185 language_codes->SetBoolean(descriptor.language_codes().at(i), true); | 186 language_codes->SetBoolean(descriptor.language_codes().at(i), true); |
| 186 dictionary->Set("languageCodeSet", language_codes.release()); | 187 dictionary->Set("languageCodeSet", language_codes.release()); |
| 187 ime_ids_list->Append(dictionary.release()); | 188 ime_ids_list->Append(dictionary.release()); |
| 188 } | 189 } |
| 189 return ime_ids_list.release(); | 190 return ime_ids_list.release(); |
| 190 } | 191 } |
| 191 | 192 |
| 192 void CrosLanguageOptionsHandler::SetApplicationLocale( | 193 void CrosLanguageOptionsHandler::SetApplicationLocale( |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id); | 270 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id); |
| 270 const extensions::Extension* extension = | 271 const extensions::Extension* extension = |
| 271 enabled_extensions.GetByID(extension_id); | 272 enabled_extensions.GetByID(extension_id); |
| 272 if (extension) | 273 if (extension) |
| 273 entry->SetString("extensionName", extension->name()); | 274 entry->SetString("extensionName", extension->name()); |
| 274 } | 275 } |
| 275 } | 276 } |
| 276 | 277 |
| 277 } // namespace options | 278 } // namespace options |
| 278 } // namespace chromeos | 279 } // namespace chromeos |
| OLD | NEW |