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

Unified 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 side-by-side diff with in-line comments
Download patch
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..99b041aa5749bf8bcc80b5dd166bfd7b0e3c51f6 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,47 @@ bool AutotestPrivateSetPrimaryButtonRightFunction::RunSync() {
return true;
}
+// static
+std::string AutotestPrivateGetVisibleNotificationsFunction::ConvertToString(
+ message_center::NotificationType type) {
+#if defined(OS_CHROMEOS)
+ 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";
+ }
+#endif
+ 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());
+ result->SetInteger("progress", notification->progress());
+ values->Append(result);
+ }
+
+#endif
+ SetResult(values);
+ return true;
+}
+
static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;

Powered by Google App Engine
This is Rietveld 408576698