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

Unified Diff: chrome/browser/notifications/stub_alert_dispatcher_mac.mm

Issue 2709213005: [Mac] Add XPC alerts to GetDisplayedNotifications (Closed)
Patch Set: Rebase after making the whole flow async in a different patch Created 3 years, 9 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/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];
}

Powered by Google App Engine
This is Rietveld 408576698