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

Unified Diff: chrome/browser/chromeos/extensions/input_method_api.cc

Issue 2025103003: ExtensionFunction: don't pass ownership of base::Value by raw pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/chromeos/extensions/input_method_api.cc
diff --git a/chrome/browser/chromeos/extensions/input_method_api.cc b/chrome/browser/chromeos/extensions/input_method_api.cc
index 531e5f99406e0b5cfd73f1a5226ead58cc773eb5..7c947e106e87aa6a2d1b1e048a5a13c83acd366f 100644
--- a/chrome/browser/chromeos/extensions/input_method_api.cc
+++ b/chrome/browser/chromeos/extensions/input_method_api.cc
@@ -12,6 +12,7 @@
#include "ash/shell.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/chromeos/extensions/dictionary_event_router.h"
@@ -75,7 +76,7 @@ InputMethodPrivateGetInputMethodConfigFunction::Run() {
#if !defined(OS_CHROMEOS)
EXTENSION_FUNCTION_VALIDATE(false);
#else
- base::DictionaryValue* output = new base::DictionaryValue();
+ std::unique_ptr<base::DictionaryValue> output(new base::DictionaryValue());
output->SetBoolean(
"isPhysicalKeyboardAutocorrectEnabled",
!base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -85,7 +86,7 @@ InputMethodPrivateGetInputMethodConfigFunction::Run() {
Profile::FromBrowserContext(browser_context())
->GetPrefs()
->GetBoolean(prefs::kLanguageImeMenuActivated));
- return RespondNow(OneArgument(output));
+ return RespondNow(OneArgument(std::move(output)));
#endif
}
@@ -96,7 +97,7 @@ InputMethodPrivateGetCurrentInputMethodFunction::Run() {
#else
chromeos::input_method::InputMethodManager* manager =
chromeos::input_method::InputMethodManager::Get();
- return RespondNow(OneArgument(new base::StringValue(
+ return RespondNow(OneArgument(base::MakeUnique<base::StringValue>(
manager->GetActiveIMEState()->GetCurrentInputMethod().id())));
#endif
}
@@ -130,7 +131,7 @@ InputMethodPrivateGetInputMethodsFunction::Run() {
#if !defined(OS_CHROMEOS)
EXTENSION_FUNCTION_VALIDATE(false);
#else
- base::ListValue* output = new base::ListValue();
+ std::unique_ptr<base::ListValue> output(new base::ListValue());
chromeos::input_method::InputMethodManager* manager =
chromeos::input_method::InputMethodManager::Get();
chromeos::input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
@@ -147,7 +148,7 @@ InputMethodPrivateGetInputMethodsFunction::Run() {
val->SetString("indicator", util->GetInputMethodShortName(input_method));
output->Append(val);
}
- return RespondNow(OneArgument(output));
+ return RespondNow(OneArgument(std::move(output)));
#endif
}
@@ -167,11 +168,11 @@ InputMethodPrivateFetchAllDictionaryWordsFunction::Run() {
}
const std::set<std::string>& words = dictionary->GetWords();
- base::ListValue* output = new base::ListValue();
+ std::unique_ptr<base::ListValue> output(new base::ListValue());
for (auto it = words.begin(); it != words.end(); ++it) {
output->AppendString(*it);
}
- return RespondNow(OneArgument(output));
+ return RespondNow(OneArgument(std::move(output)));
#endif
}

Powered by Google App Engine
This is Rietveld 408576698