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

Side by Side Diff: chrome/browser/extensions/api/system_private/system_private_api.cc

Issue 2323993004: Remove use of deprecated base::ListValue::Append(Value*) overload in extensions. (Closed)
Patch Set: ... I hate C++ Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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/extensions/api/system_private/system_private_api.h" 5 #include "chrome/browser/extensions/api/system_private/system_private_api.h"
6 6
7 #include <memory>
7 #include <utility> 8 #include <utility>
8 9
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/event_router_forwarder.h" 15 #include "chrome/browser/extensions/event_router_forwarder.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/extensions/api/system_private.h" 17 #include "chrome/common/extensions/api/system_private.h"
(...skipping 30 matching lines...) Expand all
47 const char kNotAvailableState[] = "NotAvailable"; 48 const char kNotAvailableState[] = "NotAvailable";
48 const char kNeedRestartState[] = "NeedRestart"; 49 const char kNeedRestartState[] = "NeedRestart";
49 50
50 #if defined(OS_CHROMEOS) 51 #if defined(OS_CHROMEOS)
51 const char kUpdatingState[] = "Updating"; 52 const char kUpdatingState[] = "Updating";
52 #endif // defined(OS_CHROMEOS) 53 #endif // defined(OS_CHROMEOS)
53 54
54 // Dispatches an extension event with |argument| 55 // Dispatches an extension event with |argument|
55 void DispatchEvent(extensions::events::HistogramValue histogram_value, 56 void DispatchEvent(extensions::events::HistogramValue histogram_value,
56 const std::string& event_name, 57 const std::string& event_name,
57 base::Value* argument) { 58 std::unique_ptr<base::Value> argument) {
58 std::unique_ptr<base::ListValue> list_args(new base::ListValue()); 59 std::unique_ptr<base::ListValue> list_args(new base::ListValue());
59 if (argument) { 60 if (argument) {
60 list_args->Append(argument); 61 list_args->Append(std::move(argument));
61 } 62 }
62 g_browser_process->extension_event_router_forwarder() 63 g_browser_process->extension_event_router_forwarder()
63 ->BroadcastEventToRenderers(histogram_value, event_name, 64 ->BroadcastEventToRenderers(histogram_value, event_name,
64 std::move(list_args), GURL()); 65 std::move(list_args), GURL());
65 } 66 }
66 67
67 } // namespace 68 } // namespace
68 69
69 namespace extensions { 70 namespace extensions {
70 71
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 dict->SetDouble(kDownloadProgressKey, download_progress); 143 dict->SetDouble(kDownloadProgressKey, download_progress);
143 return RespondNow(OneArgument(std::move(dict))); 144 return RespondNow(OneArgument(std::move(dict)));
144 } 145 }
145 146
146 ExtensionFunction::ResponseAction SystemPrivateGetApiKeyFunction::Run() { 147 ExtensionFunction::ResponseAction SystemPrivateGetApiKeyFunction::Run() {
147 return RespondNow(OneArgument( 148 return RespondNow(OneArgument(
148 base::MakeUnique<base::StringValue>(google_apis::GetAPIKey()))); 149 base::MakeUnique<base::StringValue>(google_apis::GetAPIKey())));
149 } 150 }
150 151
151 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) { 152 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) {
152 base::DictionaryValue* dict = new base::DictionaryValue(); 153 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
153 dict->SetDouble(kVolumeKey, volume); 154 dict->SetDouble(kVolumeKey, volume);
154 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted); 155 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted);
155 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_VOLUME_CHANGED, 156 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_VOLUME_CHANGED,
156 system_private::OnVolumeChanged::kEventName, dict); 157 system_private::OnVolumeChanged::kEventName, std::move(dict));
157 } 158 }
158 159
159 void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) { 160 void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) {
160 base::DictionaryValue* dict = new base::DictionaryValue(); 161 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
161 dict->SetInteger(kBrightnessKey, brightness); 162 dict->SetInteger(kBrightnessKey, brightness);
162 dict->SetBoolean(kUserInitiatedKey, user_initiated); 163 dict->SetBoolean(kUserInitiatedKey, user_initiated);
163 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_BRIGHTNESS_CHANGED, 164 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_BRIGHTNESS_CHANGED,
164 system_private::OnBrightnessChanged::kEventName, dict); 165 system_private::OnBrightnessChanged::kEventName,
166 std::move(dict));
165 } 167 }
166 168
167 void DispatchScreenUnlockedEvent() { 169 void DispatchScreenUnlockedEvent() {
168 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_SCREEN_UNLOCKED, 170 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_SCREEN_UNLOCKED,
169 system_private::OnScreenUnlocked::kEventName, NULL); 171 system_private::OnScreenUnlocked::kEventName, nullptr);
170 } 172 }
171 173
172 void DispatchWokeUpEvent() { 174 void DispatchWokeUpEvent() {
173 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_WOKE_UP, 175 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_WOKE_UP,
174 system_private::OnWokeUp::kEventName, NULL); 176 system_private::OnWokeUp::kEventName, nullptr);
175 } 177 }
176 178
177 } // namespace extensions 179 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698