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

Side by Side Diff: chrome/browser/extensions/api/autotest_private/autotest_private_api.cc

Issue 1991083002: Remove ExtensionFunction::SetResult(T*) overload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU 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 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/autotest_private/autotest_private_api.h" 5 #include "chrome/browser/extensions/api/autotest_private/autotest_private_api.h"
6 6
7 #include <memory>
8 #include <utility>
9
7 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
8 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
9 #include "build/build_config.h" 12 #include "build/build_config.h"
10 #include "chrome/browser/extensions/extension_action_manager.h" 13 #include "chrome/browser/extensions/extension_action_manager.h"
11 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_util.h" 15 #include "chrome/browser/extensions/extension_util.h"
13 #include "chrome/browser/lifetime/application_lifetime.h" 16 #include "chrome/browser/lifetime/application_lifetime.h"
14 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/extensions/api/autotest_private.h" 18 #include "chrome/common/extensions/api/autotest_private.h"
16 #include "extensions/browser/extension_function_registry.h" 19 #include "extensions/browser/extension_function_registry.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 DVLOG(1) << "AutotestPrivateShutdownFunction " << params->force; 94 DVLOG(1) << "AutotestPrivateShutdownFunction " << params->force;
92 95
93 if (!IsTestMode(GetProfile())) 96 if (!IsTestMode(GetProfile()))
94 chrome::AttemptExit(); 97 chrome::AttemptExit();
95 return true; 98 return true;
96 } 99 }
97 100
98 bool AutotestPrivateLoginStatusFunction::RunSync() { 101 bool AutotestPrivateLoginStatusFunction::RunSync() {
99 DVLOG(1) << "AutotestPrivateLoginStatusFunction"; 102 DVLOG(1) << "AutotestPrivateLoginStatusFunction";
100 103
101 base::DictionaryValue* result(new base::DictionaryValue); 104 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
102 #if defined(OS_CHROMEOS) 105 #if defined(OS_CHROMEOS)
103 const user_manager::UserManager* user_manager = 106 const user_manager::UserManager* user_manager =
104 user_manager::UserManager::Get(); 107 user_manager::UserManager::Get();
105 const bool is_screen_locked = 108 const bool is_screen_locked =
106 !!chromeos::ScreenLocker::default_screen_locker(); 109 !!chromeos::ScreenLocker::default_screen_locker();
107 110
108 if (user_manager) { 111 if (user_manager) {
109 result->SetBoolean("isLoggedIn", user_manager->IsUserLoggedIn()); 112 result->SetBoolean("isLoggedIn", user_manager->IsUserLoggedIn());
110 result->SetBoolean("isOwner", user_manager->IsCurrentUserOwner()); 113 result->SetBoolean("isOwner", user_manager->IsCurrentUserOwner());
111 result->SetBoolean("isScreenLocked", is_screen_locked); 114 result->SetBoolean("isScreenLocked", is_screen_locked);
(...skipping 19 matching lines...) Expand all
131 134
132 default: 135 default:
133 user_image = base::IntToString(user->image_index()); 136 user_image = base::IntToString(user->image_index());
134 break; 137 break;
135 } 138 }
136 result->SetString("userImage", user_image); 139 result->SetString("userImage", user_image);
137 } 140 }
138 } 141 }
139 #endif 142 #endif
140 143
141 SetResult(result); 144 SetResult(std::move(result));
142 return true; 145 return true;
143 } 146 }
144 147
145 bool AutotestPrivateLockScreenFunction::RunSync() { 148 bool AutotestPrivateLockScreenFunction::RunSync() {
146 DVLOG(1) << "AutotestPrivateLockScreenFunction"; 149 DVLOG(1) << "AutotestPrivateLockScreenFunction";
147 #if defined(OS_CHROMEOS) 150 #if defined(OS_CHROMEOS)
148 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> 151 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
149 RequestLockScreen(); 152 RequestLockScreen();
150 #endif 153 #endif
151 return true; 154 return true;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 extension_value->SetBoolean("isEnabled", service->IsExtensionEnabled(id)); 201 extension_value->SetBoolean("isEnabled", service->IsExtensionEnabled(id));
199 extension_value->SetBoolean("allowedInIncognito", 202 extension_value->SetBoolean("allowedInIncognito",
200 util::IsIncognitoEnabled(id, GetProfile())); 203 util::IsIncognitoEnabled(id, GetProfile()));
201 extension_value->SetBoolean( 204 extension_value->SetBoolean(
202 "hasPageAction", 205 "hasPageAction",
203 extension_action_manager->GetPageAction(*extension) != NULL); 206 extension_action_manager->GetPageAction(*extension) != NULL);
204 207
205 extensions_values->Append(extension_value); 208 extensions_values->Append(extension_value);
206 } 209 }
207 210
208 base::DictionaryValue* return_value(new base::DictionaryValue); 211 std::unique_ptr<base::DictionaryValue> return_value(
212 new base::DictionaryValue);
209 return_value->Set("extensions", extensions_values); 213 return_value->Set("extensions", extensions_values);
210 SetResult(return_value); 214 SetResult(std::move(return_value));
211 return true; 215 return true;
212 } 216 }
213 217
214 static int AccessArray(const volatile int arr[], const volatile int *index) { 218 static int AccessArray(const volatile int arr[], const volatile int *index) {
215 return arr[*index]; 219 return arr[*index];
216 } 220 }
217 221
218 bool AutotestPrivateSimulateAsanMemoryBugFunction::RunSync() { 222 bool AutotestPrivateSimulateAsanMemoryBugFunction::RunSync() {
219 DVLOG(1) << "AutotestPrivateSimulateAsanMemoryBugFunction"; 223 DVLOG(1) << "AutotestPrivateSimulateAsanMemoryBugFunction";
220 if (!IsTestMode(GetProfile())) { 224 if (!IsTestMode(GetProfile())) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return "multiple"; 343 return "multiple";
340 case message_center::NOTIFICATION_TYPE_PROGRESS: 344 case message_center::NOTIFICATION_TYPE_PROGRESS:
341 return "progress"; 345 return "progress";
342 } 346 }
343 #endif 347 #endif
344 return "unknown"; 348 return "unknown";
345 } 349 }
346 350
347 bool AutotestPrivateGetVisibleNotificationsFunction::RunSync() { 351 bool AutotestPrivateGetVisibleNotificationsFunction::RunSync() {
348 DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction"; 352 DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction";
349 base::ListValue* values = new base::ListValue; 353 std::unique_ptr<base::ListValue> values(new base::ListValue);
350 #if defined(OS_CHROMEOS) 354 #if defined(OS_CHROMEOS)
351 for (auto notification : 355 for (auto* notification :
352 message_center::MessageCenter::Get()->GetVisibleNotifications()) { 356 message_center::MessageCenter::Get()->GetVisibleNotifications()) {
353 base::DictionaryValue* result(new base::DictionaryValue); 357 base::DictionaryValue* result(new base::DictionaryValue);
354 result->SetString("id", notification->id()); 358 result->SetString("id", notification->id());
355 result->SetString("type", ConvertToString(notification->type())); 359 result->SetString("type", ConvertToString(notification->type()));
356 result->SetString("title", notification->title()); 360 result->SetString("title", notification->title());
357 result->SetString("message", notification->message()); 361 result->SetString("message", notification->message());
358 result->SetInteger("priority", notification->priority()); 362 result->SetInteger("priority", notification->priority());
359 result->SetInteger("progress", notification->progress()); 363 result->SetInteger("progress", notification->progress());
360 values->Append(result); 364 values->Append(result);
361 } 365 }
362 366
363 #endif 367 #endif
364 SetResult(values); 368 SetResult(std::move(values));
365 return true; 369 return true;
366 } 370 }
367 371
368 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> > 372 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> >
369 g_factory = LAZY_INSTANCE_INITIALIZER; 373 g_factory = LAZY_INSTANCE_INITIALIZER;
370 374
371 // static 375 // static
372 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* 376 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>*
373 AutotestPrivateAPI::GetFactoryInstance() { 377 AutotestPrivateAPI::GetFactoryInstance() {
374 return g_factory.Pointer(); 378 return g_factory.Pointer();
375 } 379 }
376 380
377 template <> 381 template <>
378 KeyedService* 382 KeyedService*
379 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( 383 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor(
380 content::BrowserContext* context) const { 384 content::BrowserContext* context) const {
381 return new AutotestPrivateAPI(); 385 return new AutotestPrivateAPI();
382 } 386 }
383 387
384 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { 388 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) {
385 } 389 }
386 390
387 AutotestPrivateAPI::~AutotestPrivateAPI() { 391 AutotestPrivateAPI::~AutotestPrivateAPI() {
388 } 392 }
389 393
390 } // namespace extensions 394 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698