Chromium Code Reviews| Index: chrome/browser/extensions/api/autotest_private/autotest_private_api.cc |
| diff --git a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc |
| index 39740943fee050fbe083e73d28ac3696bfde4f43..5b545f6a6629d7b65da8422f48ee2d8ba9c2232c 100644 |
| --- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc |
| +++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc |
| @@ -29,6 +29,8 @@ |
| #include "chromeos/dbus/session_manager_client.h" |
| #include "components/user_manager/user.h" |
| #include "components/user_manager/user_manager.h" |
| +#include "ui/message_center/message_center.h" |
| +#include "ui/message_center/notification.h" |
| #endif |
| namespace extensions { |
| @@ -322,6 +324,45 @@ bool AutotestPrivateSetPrimaryButtonRightFunction::RunSync() { |
| return true; |
| } |
| +// static |
| +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.
|
| + message_center::NotificationType type) { |
| + switch (type) { |
| + case message_center::NOTIFICATION_TYPE_SIMPLE: |
| + return "simple"; |
| + case message_center::NOTIFICATION_TYPE_BASE_FORMAT: |
| + return "base_format"; |
| + case message_center::NOTIFICATION_TYPE_IMAGE: |
| + return "image"; |
| + case message_center::NOTIFICATION_TYPE_MULTIPLE: |
| + return "multiple"; |
| + case message_center::NOTIFICATION_TYPE_PROGRESS: |
| + return "progress"; |
| + default: |
| + return "unknown"; |
| + } |
| +} |
| + |
| +bool AutotestPrivateGetVisibleNotificationsFunction::RunSync() { |
| + DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction"; |
| + base::ListValue* values = new base::ListValue; |
| +#if defined(OS_CHROMEOS) |
| + for (auto notification : |
| + message_center::MessageCenter::Get()->GetVisibleNotifications()) { |
| + base::DictionaryValue* result(new base::DictionaryValue); |
| + result->SetString("id", notification->id()); |
| + result->SetString("type", ConvertToString(notification->type())); |
| + result->SetString("title", notification->title()); |
| + result->SetString("message", notification->message()); |
| + result->SetInteger("priority", notification->priority()); |
| + values->Append(result); |
| + } |
| + |
| +#endif |
| + SetResult(values); |
| + return true; |
| +} |
| + |
| static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> > |
| g_factory = LAZY_INSTANCE_INITIALIZER; |