Index: chrome/browser/extensions/api/system_private/system_private_api.cc |
diff --git a/chrome/browser/extensions/api/system_private/system_private_api.cc b/chrome/browser/extensions/api/system_private/system_private_api.cc |
index 025154a5bb015bbc0873ec8fa871141c46d1d900..d128aa247344e237e0fc6e013a779190220993f7 100644 |
--- a/chrome/browser/extensions/api/system_private/system_private_api.cc |
+++ b/chrome/browser/extensions/api/system_private/system_private_api.cc |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/extensions/api/system_private/system_private_api.h" |
+#include <memory> |
#include <utility> |
#include "base/macros.h" |
@@ -54,10 +55,10 @@ const char kUpdatingState[] = "Updating"; |
// Dispatches an extension event with |argument| |
void DispatchEvent(extensions::events::HistogramValue histogram_value, |
const std::string& event_name, |
- base::Value* argument) { |
+ std::unique_ptr<base::Value> argument) { |
std::unique_ptr<base::ListValue> list_args(new base::ListValue()); |
if (argument) { |
- list_args->Append(argument); |
+ list_args->Append(std::move(argument)); |
} |
g_browser_process->extension_event_router_forwarder() |
->BroadcastEventToRenderers(histogram_value, event_name, |
@@ -149,29 +150,30 @@ ExtensionFunction::ResponseAction SystemPrivateGetApiKeyFunction::Run() { |
} |
void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) { |
- base::DictionaryValue* dict = new base::DictionaryValue(); |
+ std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
dict->SetDouble(kVolumeKey, volume); |
dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted); |
DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_VOLUME_CHANGED, |
- system_private::OnVolumeChanged::kEventName, dict); |
+ system_private::OnVolumeChanged::kEventName, std::move(dict)); |
} |
void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) { |
- base::DictionaryValue* dict = new base::DictionaryValue(); |
+ std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
dict->SetInteger(kBrightnessKey, brightness); |
dict->SetBoolean(kUserInitiatedKey, user_initiated); |
DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_BRIGHTNESS_CHANGED, |
- system_private::OnBrightnessChanged::kEventName, dict); |
+ system_private::OnBrightnessChanged::kEventName, |
+ std::move(dict)); |
} |
void DispatchScreenUnlockedEvent() { |
DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_SCREEN_UNLOCKED, |
- system_private::OnScreenUnlocked::kEventName, NULL); |
+ system_private::OnScreenUnlocked::kEventName, nullptr); |
} |
void DispatchWokeUpEvent() { |
DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_WOKE_UP, |
- system_private::OnWokeUp::kEventName, NULL); |
+ system_private::OnWokeUp::kEventName, nullptr); |
} |
} // namespace extensions |