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

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..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;

Powered by Google App Engine
This is Rietveld 408576698