Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3850)

Unified Diff: chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc

Issue 2812953002: Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: No ListValue::SetDouble Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
index be140f8e199f99926698e3c214094d89d1a31778..1c938f22190fb048d977f0d23b42011b44fafa61 100644
--- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
@@ -94,7 +94,7 @@ void CrosLanguageOptionsHandler::GetLocalizedValues(
IDS_OPTIONS_SETTINGS_LANGUAGES_ACTIVATE_IME_MENU));
// GetSupportedInputMethods() never returns NULL.
- localized_strings->Set("languageList", GetAcceptLanguageList().release());
+ localized_strings->Set("languageList", GetAcceptLanguageList());
localized_strings->Set("inputMethodList", GetInputMethodList());
input_method::InputMethodManager* manager =
@@ -102,10 +102,10 @@ void CrosLanguageOptionsHandler::GetLocalizedValues(
input_method::InputMethodDescriptors ext_ime_descriptors;
manager->GetActiveIMEState()->GetInputMethodExtensions(&ext_ime_descriptors);
- base::ListValue* ext_ime_list = ConvertInputMethodDescriptorsToIMEList(
- ext_ime_descriptors);
- AddImeProvider(ext_ime_list);
- localized_strings->Set("extensionImeList", ext_ime_list);
+ std::unique_ptr<base::ListValue> ext_ime_list =
+ ConvertInputMethodDescriptorsToIMEList(ext_ime_descriptors);
+ AddImeProvider(ext_ime_list.get());
+ localized_strings->Set("extensionImeList", std::move(ext_ime_list));
ComponentExtensionIMEManager* component_extension_manager =
input_method::InputMethodManager::Get()
@@ -134,14 +134,15 @@ void CrosLanguageOptionsHandler::RegisterMessages() {
}
// static
-base::ListValue* CrosLanguageOptionsHandler::GetInputMethodList() {
+std::unique_ptr<base::ListValue>
+CrosLanguageOptionsHandler::GetInputMethodList() {
input_method::InputMethodManager* manager =
input_method::InputMethodManager::Get();
// GetSupportedInputMethods() never return NULL.
std::unique_ptr<input_method::InputMethodDescriptors> descriptors(
manager->GetSupportedInputMethods());
- base::ListValue* input_method_list = new base::ListValue();
+ auto input_method_list = base::MakeUnique<base::ListValue>();
for (size_t i = 0; i < descriptors->size(); ++i) {
const input_method::InputMethodDescriptor& descriptor =
@@ -155,11 +156,11 @@ base::ListValue* CrosLanguageOptionsHandler::GetInputMethodList() {
// One input method can be associated with multiple languages, hence
// we use a dictionary here.
- base::DictionaryValue* languages = new base::DictionaryValue();
+ auto languages = base::MakeUnique<base::DictionaryValue>();
for (size_t i = 0; i < descriptor.language_codes().size(); ++i) {
languages->SetBoolean(descriptor.language_codes().at(i), true);
}
- dictionary->Set("languageCodeSet", languages);
+ dictionary->Set("languageCodeSet", std::move(languages));
input_method_list->Append(std::move(dictionary));
}
@@ -167,9 +168,9 @@ base::ListValue* CrosLanguageOptionsHandler::GetInputMethodList() {
return input_method_list;
}
-base::ListValue*
- CrosLanguageOptionsHandler::ConvertInputMethodDescriptorsToIMEList(
- const input_method::InputMethodDescriptors& descriptors) {
+std::unique_ptr<base::ListValue>
+CrosLanguageOptionsHandler::ConvertInputMethodDescriptorsToIMEList(
+ const input_method::InputMethodDescriptors& descriptors) {
input_method::InputMethodUtil* util =
input_method::InputMethodManager::Get()->GetInputMethodUtil();
std::unique_ptr<base::ListValue> ime_ids_list(new base::ListValue());
@@ -185,10 +186,10 @@ base::ListValue*
new base::DictionaryValue());
for (size_t i = 0; i < descriptor.language_codes().size(); ++i)
language_codes->SetBoolean(descriptor.language_codes().at(i), true);
- dictionary->Set("languageCodeSet", language_codes.release());
+ dictionary->Set("languageCodeSet", std::move(language_codes));
ime_ids_list->Append(std::move(dictionary));
}
- return ime_ids_list.release();
+ return ime_ids_list;
}
void CrosLanguageOptionsHandler::SetApplicationLocale(

Powered by Google App Engine
This is Rietveld 408576698