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

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

Issue 1872873002: Add autotestPrivate.getVisibleNotifications API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/extensions/extension_action_manager.h" 10 #include "chrome/browser/extensions/extension_action_manager.h"
(...skipping 11 matching lines...) Expand all
22 #include "extensions/common/permissions/permission_set.h" 22 #include "extensions/common/permissions/permission_set.h"
23 #include "extensions/common/permissions/permissions_data.h" 23 #include "extensions/common/permissions/permissions_data.h"
24 24
25 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
26 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 26 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
27 #include "chrome/browser/chromeos/system/input_device_settings.h" 27 #include "chrome/browser/chromeos/system/input_device_settings.h"
28 #include "chromeos/dbus/dbus_thread_manager.h" 28 #include "chromeos/dbus/dbus_thread_manager.h"
29 #include "chromeos/dbus/session_manager_client.h" 29 #include "chromeos/dbus/session_manager_client.h"
30 #include "components/user_manager/user.h" 30 #include "components/user_manager/user.h"
31 #include "components/user_manager/user_manager.h" 31 #include "components/user_manager/user_manager.h"
32 #include "ui/message_center/message_center.h"
33 #include "ui/message_center/notification.h"
32 #endif 34 #endif
33 35
34 namespace extensions { 36 namespace extensions {
35 namespace { 37 namespace {
36 38
37 base::ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) { 39 base::ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) {
38 const PermissionsData* permissions_data = ext->permissions_data(); 40 const PermissionsData* permissions_data = ext->permissions_data();
39 const URLPatternSet& pattern_set = 41 const URLPatternSet& pattern_set =
40 effective_perm ? permissions_data->GetEffectiveHostPermissions() 42 effective_perm ? permissions_data->GetEffectiveHostPermissions()
41 : permissions_data->active_permissions().explicit_hosts(); 43 : permissions_data->active_permissions().explicit_hosts();
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 317
316 DVLOG(1) << "AutotestPrivateSetPrimaryButtonRightFunction " << params->right; 318 DVLOG(1) << "AutotestPrivateSetPrimaryButtonRightFunction " << params->right;
317 319
318 #if defined(OS_CHROMEOS) 320 #if defined(OS_CHROMEOS)
319 chromeos::system::InputDeviceSettings::Get()->SetPrimaryButtonRight( 321 chromeos::system::InputDeviceSettings::Get()->SetPrimaryButtonRight(
320 params->right); 322 params->right);
321 #endif 323 #endif
322 return true; 324 return true;
323 } 325 }
324 326
327 // static
328 std::string AutotestPrivateGetVisibleNotificationsFunction::ConvertToString(
329 message_center::NotificationType type) {
330 #if defined(OS_CHROMEOS)
331 switch (type) {
332 case message_center::NOTIFICATION_TYPE_SIMPLE:
333 return "simple";
334 case message_center::NOTIFICATION_TYPE_BASE_FORMAT:
335 return "base_format";
336 case message_center::NOTIFICATION_TYPE_IMAGE:
337 return "image";
338 case message_center::NOTIFICATION_TYPE_MULTIPLE:
339 return "multiple";
340 case message_center::NOTIFICATION_TYPE_PROGRESS:
341 return "progress";
342 }
343 #endif
344 return "unknown";
345 }
346
347 bool AutotestPrivateGetVisibleNotificationsFunction::RunSync() {
348 DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction";
349 base::ListValue* values = new base::ListValue;
350 #if defined(OS_CHROMEOS)
351 for (auto notification :
352 message_center::MessageCenter::Get()->GetVisibleNotifications()) {
353 base::DictionaryValue* result(new base::DictionaryValue);
354 result->SetString("id", notification->id());
355 result->SetString("type", ConvertToString(notification->type()));
356 result->SetString("title", notification->title());
357 result->SetString("message", notification->message());
358 result->SetInteger("priority", notification->priority());
359 result->SetInteger("progress", notification->progress());
360 values->Append(result);
361 }
362
363 #endif
364 SetResult(values);
365 return true;
366 }
367
325 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> > 368 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> >
326 g_factory = LAZY_INSTANCE_INITIALIZER; 369 g_factory = LAZY_INSTANCE_INITIALIZER;
327 370
328 // static 371 // static
329 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* 372 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>*
330 AutotestPrivateAPI::GetFactoryInstance() { 373 AutotestPrivateAPI::GetFactoryInstance() {
331 return g_factory.Pointer(); 374 return g_factory.Pointer();
332 } 375 }
333 376
334 template <> 377 template <>
335 KeyedService* 378 KeyedService*
336 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( 379 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor(
337 content::BrowserContext* context) const { 380 content::BrowserContext* context) const {
338 return new AutotestPrivateAPI(); 381 return new AutotestPrivateAPI();
339 } 382 }
340 383
341 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { 384 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) {
342 } 385 }
343 386
344 AutotestPrivateAPI::~AutotestPrivateAPI() { 387 AutotestPrivateAPI::~AutotestPrivateAPI() {
345 } 388 }
346 389
347 } // namespace extensions 390 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698