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

Unified Diff: chrome/browser/ui/cocoa/notifications/alert_notification_service.mm

Issue 2714743002: Retrive displayed notifications asynchronously
Patch Set: apply review comments from https://codereview.chromium.org/2709213005/ Created 3 years, 10 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/ui/cocoa/notifications/alert_notification_service.mm
diff --git a/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm b/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
index d81f2b6ef1ad8514bcabd04e5fd7dbc3d27a5e66..8d100ac073a8aedb69710eabe943f469997d91b4 100644
--- a/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
+++ b/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
@@ -59,4 +59,23 @@
[transactionHandler_ closeTransactionIfNeeded];
}
+- (void)getDisplayedAlertsForProfileId:(NSString*)profileId
+ withReply:(void (^)(NSArray*))reply {
+ NSUserNotificationCenter* notificationCenter =
+ [NSUserNotificationCenter defaultUserNotificationCenter];
+ NSMutableArray* notificationIds = [NSMutableArray
+ arrayWithCapacity:[[notificationCenter deliveredNotifications] count]];
+ for (NSUserNotification* toast in
+ [notificationCenter deliveredNotifications]) {
+ NSString* candidateProfileId = [toast.userInfo
+ objectForKey:notification_constants::kNotificationProfileId];
+ if ([candidateProfileId isEqualToString:profileId]) {
+ [notificationIds
+ addObject:[toast.userInfo
+ objectForKey:notification_constants::kNotificationId]];
+ }
+ }
+ reply(notificationIds);
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698