Chromium Code Reviews| 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 "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 Loading... | |
| 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 Loading... | |
| 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( | |
|
yoshiki
2016/04/11 04:41:47
You need to wrap this method with #ifdef OS_CHROME
victorhsieh0
2016/04/11 18:28:26
Done.
| |
| 329 message_center::NotificationType type) { | |
| 330 switch (type) { | |
| 331 case message_center::NOTIFICATION_TYPE_SIMPLE: | |
| 332 return "simple"; | |
| 333 case message_center::NOTIFICATION_TYPE_BASE_FORMAT: | |
| 334 return "base_format"; | |
| 335 case message_center::NOTIFICATION_TYPE_IMAGE: | |
| 336 return "image"; | |
| 337 case message_center::NOTIFICATION_TYPE_MULTIPLE: | |
| 338 return "multiple"; | |
| 339 case message_center::NOTIFICATION_TYPE_PROGRESS: | |
| 340 return "progress"; | |
| 341 default: | |
| 342 return "unknown"; | |
| 343 } | |
| 344 } | |
| 345 | |
| 346 bool AutotestPrivateGetVisibleNotificationsFunction::RunSync() { | |
| 347 DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction"; | |
| 348 base::ListValue* values = new base::ListValue; | |
| 349 #if defined(OS_CHROMEOS) | |
| 350 for (auto notification : | |
| 351 message_center::MessageCenter::Get()->GetVisibleNotifications()) { | |
| 352 base::DictionaryValue* result(new base::DictionaryValue); | |
| 353 result->SetString("id", notification->id()); | |
| 354 result->SetString("type", ConvertToString(notification->type())); | |
| 355 result->SetString("title", notification->title()); | |
| 356 result->SetString("message", notification->message()); | |
| 357 result->SetInteger("priority", notification->priority()); | |
| 358 values->Append(result); | |
| 359 } | |
| 360 | |
| 361 #endif | |
| 362 SetResult(values); | |
| 363 return true; | |
| 364 } | |
| 365 | |
| 325 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> > | 366 static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> > |
| 326 g_factory = LAZY_INSTANCE_INITIALIZER; | 367 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 327 | 368 |
| 328 // static | 369 // static |
| 329 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* | 370 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* |
| 330 AutotestPrivateAPI::GetFactoryInstance() { | 371 AutotestPrivateAPI::GetFactoryInstance() { |
| 331 return g_factory.Pointer(); | 372 return g_factory.Pointer(); |
| 332 } | 373 } |
| 333 | 374 |
| 334 template <> | 375 template <> |
| 335 KeyedService* | 376 KeyedService* |
| 336 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( | 377 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( |
| 337 content::BrowserContext* context) const { | 378 content::BrowserContext* context) const { |
| 338 return new AutotestPrivateAPI(); | 379 return new AutotestPrivateAPI(); |
| 339 } | 380 } |
| 340 | 381 |
| 341 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { | 382 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { |
| 342 } | 383 } |
| 343 | 384 |
| 344 AutotestPrivateAPI::~AutotestPrivateAPI() { | 385 AutotestPrivateAPI::~AutotestPrivateAPI() { |
| 345 } | 386 } |
| 346 | 387 |
| 347 } // namespace extensions | 388 } // namespace extensions |
| OLD | NEW |