Index: chrome/browser/notifications/stub_alert_dispatcher_mac.mm |
diff --git a/chrome/browser/notifications/stub_alert_dispatcher_mac.mm b/chrome/browser/notifications/stub_alert_dispatcher_mac.mm |
index 2c193f78eaaf0d206a52922bb41825e410d4eb97..31a4888649b6490e8a1e587ab1bc507e262cfef8 100644 |
--- a/chrome/browser/notifications/stub_alert_dispatcher_mac.mm |
+++ b/chrome/browser/notifications/stub_alert_dispatcher_mac.mm |
@@ -4,7 +4,13 @@ |
#import "chrome/browser/notifications/stub_alert_dispatcher_mac.h" |
+#include <set> |
+#include <string> |
+ |
+#include "base/callback.h" |
#include "base/mac/scoped_nsobject.h" |
+#include "base/memory/ptr_util.h" |
+#include "base/strings/sys_string_conversions.h" |
#include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h" |
@implementation StubAlertDispatcher { |
@@ -43,6 +49,26 @@ |
[alerts_ removeAllObjects]; |
} |
+- (void) |
+getDisplayedAlertsForProfileId:(NSString*)profileId |
+ withNotificationCenter:(NSUserNotificationCenter*)notificationCenter |
+ callback:(DisplayedNotificationsCallback)callback { |
+ std::unique_ptr<std::set<std::string>> displayedNotifications = |
+ base::MakeUnique<std::set<std::string>>(); |
+ for (NSUserNotification* toast in |
+ [notificationCenter deliveredNotifications]) { |
+ NSString* toastProfileId = [toast.userInfo |
+ objectForKey:notification_constants::kNotificationProfileId]; |
+ if ([toastProfileId isEqualToString:profileId]) { |
+ displayedNotifications->insert(base::SysNSStringToUTF8([toast.userInfo |
+ objectForKey:notification_constants::kNotificationId])); |
+ } |
+ } |
+ |
+ callback.Run(std::move(displayedNotifications), |
+ true /* supports_synchronization */); |
+} |
+ |
- (NSArray*)alerts { |
return [[alerts_ copy] autorelease]; |
} |