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

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

Issue 2392693002: Rewrite simple uses of base::ListValue::Append(base::Value*) on CrOS. (Closed)
Patch Set: MakeUnique Created 4 years, 2 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> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/memory/ptr_util.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "chrome/browser/extensions/extension_action_manager.h" 14 #include "chrome/browser/extensions/extension_action_manager.h"
14 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/extension_util.h" 16 #include "chrome/browser/extensions/extension_util.h"
16 #include "chrome/browser/lifetime/application_lifetime.h" 17 #include "chrome/browser/lifetime/application_lifetime.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/extensions/api/autotest_private.h" 19 #include "chrome/common/extensions/api/autotest_private.h"
19 #include "extensions/browser/extension_function_registry.h" 20 #include "extensions/browser/extension_function_registry.h"
20 #include "extensions/browser/extension_registry.h" 21 #include "extensions/browser/extension_registry.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return "unknown"; 357 return "unknown";
357 } 358 }
358 359
359 ExtensionFunction::ResponseAction 360 ExtensionFunction::ResponseAction
360 AutotestPrivateGetVisibleNotificationsFunction::Run() { 361 AutotestPrivateGetVisibleNotificationsFunction::Run() {
361 DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction"; 362 DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction";
362 std::unique_ptr<base::ListValue> values(new base::ListValue); 363 std::unique_ptr<base::ListValue> values(new base::ListValue);
363 #if defined(OS_CHROMEOS) 364 #if defined(OS_CHROMEOS)
364 for (auto* notification : 365 for (auto* notification :
365 message_center::MessageCenter::Get()->GetVisibleNotifications()) { 366 message_center::MessageCenter::Get()->GetVisibleNotifications()) {
366 base::DictionaryValue* result(new base::DictionaryValue); 367 auto result = base::MakeUnique<base::DictionaryValue>();
367 result->SetString("id", notification->id()); 368 result->SetString("id", notification->id());
368 result->SetString("type", ConvertToString(notification->type())); 369 result->SetString("type", ConvertToString(notification->type()));
369 result->SetString("title", notification->title()); 370 result->SetString("title", notification->title());
370 result->SetString("message", notification->message()); 371 result->SetString("message", notification->message());
371 result->SetInteger("priority", notification->priority()); 372 result->SetInteger("priority", notification->priority());
372 result->SetInteger("progress", notification->progress()); 373 result->SetInteger("progress", notification->progress());
373 values->Append(result); 374 values->Append(std::move(result));
374 } 375 }
375 376
376 #endif 377 #endif
377 return RespondNow(OneArgument(std::move(values))); 378 return RespondNow(OneArgument(std::move(values)));
378 } 379 }
379 380
380 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> > 381 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> >
381 g_factory = LAZY_INSTANCE_INITIALIZER; 382 g_factory = LAZY_INSTANCE_INITIALIZER;
382 383
383 // static 384 // static
384 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* 385 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>*
385 AutotestPrivateAPI::GetFactoryInstance() { 386 AutotestPrivateAPI::GetFactoryInstance() {
386 return g_factory.Pointer(); 387 return g_factory.Pointer();
387 } 388 }
388 389
389 template <> 390 template <>
390 KeyedService* 391 KeyedService*
391 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( 392 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor(
392 content::BrowserContext* context) const { 393 content::BrowserContext* context) const {
393 return new AutotestPrivateAPI(); 394 return new AutotestPrivateAPI();
394 } 395 }
395 396
396 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { 397 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) {
397 } 398 }
398 399
399 AutotestPrivateAPI::~AutotestPrivateAPI() { 400 AutotestPrivateAPI::~AutotestPrivateAPI() {
400 } 401 }
401 402
402 } // namespace extensions 403 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698