OLD | NEW |
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" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 return "unknown"; | 356 return "unknown"; |
357 } | 357 } |
358 | 358 |
359 ExtensionFunction::ResponseAction | 359 ExtensionFunction::ResponseAction |
360 AutotestPrivateGetVisibleNotificationsFunction::Run() { | 360 AutotestPrivateGetVisibleNotificationsFunction::Run() { |
361 DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction"; | 361 DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction"; |
362 std::unique_ptr<base::ListValue> values(new base::ListValue); | 362 std::unique_ptr<base::ListValue> values(new base::ListValue); |
363 #if defined(OS_CHROMEOS) | 363 #if defined(OS_CHROMEOS) |
364 for (auto* notification : | 364 for (auto* notification : |
365 message_center::MessageCenter::Get()->GetVisibleNotifications()) { | 365 message_center::MessageCenter::Get()->GetVisibleNotifications()) { |
366 base::DictionaryValue* result(new base::DictionaryValue); | 366 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
367 result->SetString("id", notification->id()); | 367 result->SetString("id", notification->id()); |
368 result->SetString("type", ConvertToString(notification->type())); | 368 result->SetString("type", ConvertToString(notification->type())); |
369 result->SetString("title", notification->title()); | 369 result->SetString("title", notification->title()); |
370 result->SetString("message", notification->message()); | 370 result->SetString("message", notification->message()); |
371 result->SetInteger("priority", notification->priority()); | 371 result->SetInteger("priority", notification->priority()); |
372 result->SetInteger("progress", notification->progress()); | 372 result->SetInteger("progress", notification->progress()); |
373 values->Append(result); | 373 values->Append(std::move(result)); |
374 } | 374 } |
375 | 375 |
376 #endif | 376 #endif |
377 return RespondNow(OneArgument(std::move(values))); | 377 return RespondNow(OneArgument(std::move(values))); |
378 } | 378 } |
379 | 379 |
380 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> > | 380 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> > |
381 g_factory = LAZY_INSTANCE_INITIALIZER; | 381 g_factory = LAZY_INSTANCE_INITIALIZER; |
382 | 382 |
383 // static | 383 // static |
384 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* | 384 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* |
385 AutotestPrivateAPI::GetFactoryInstance() { | 385 AutotestPrivateAPI::GetFactoryInstance() { |
386 return g_factory.Pointer(); | 386 return g_factory.Pointer(); |
387 } | 387 } |
388 | 388 |
389 template <> | 389 template <> |
390 KeyedService* | 390 KeyedService* |
391 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( | 391 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( |
392 content::BrowserContext* context) const { | 392 content::BrowserContext* context) const { |
393 return new AutotestPrivateAPI(); | 393 return new AutotestPrivateAPI(); |
394 } | 394 } |
395 | 395 |
396 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { | 396 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { |
397 } | 397 } |
398 | 398 |
399 AutotestPrivateAPI::~AutotestPrivateAPI() { | 399 AutotestPrivateAPI::~AutotestPrivateAPI() { |
400 } | 400 } |
401 | 401 |
402 } // namespace extensions | 402 } // namespace extensions |
OLD | NEW |