Index: chrome/browser/notifications/notification_platform_bridge_mac.mm |
diff --git a/chrome/browser/notifications/notification_platform_bridge_mac.mm b/chrome/browser/notifications/notification_platform_bridge_mac.mm |
index 9017890bf7aed012ac76c5bb23d71427c5ea5334..51e55bccb2b679803f1b7214a678769896a69931 100644 |
--- a/chrome/browser/notifications/notification_platform_bridge_mac.mm |
+++ b/chrome/browser/notifications/notification_platform_bridge_mac.mm |
@@ -137,6 +137,13 @@ void RecordXPCEvent(XPCConnectionEvent event) { |
// Close all notifications. |
- (void)closeAllNotifications; |
+// Get displayed alerts for |profileId| merge them with |localNotifications| |
Peter Beverloo
2017/04/03 12:33:28
nit: no double space
Robert Sesek
2017/04/03 16:51:24
I missed this earlier, but you can omit re-declari
Miguel Garcia
2017/04/04 12:21:26
Done.
Miguel Garcia
2017/04/04 12:21:26
Done.
|
+// and post |callback| to the IO thread. |
Peter Beverloo
2017/04/03 12:33:29
IO -> UI?
Miguel Garcia
2017/04/04 12:21:26
Done.
|
+- (void)getDisplayedAlertsForProfileId:(NSString*)profileId |
+ withNotificationCenter: |
+ (NSUserNotificationCenter*)notificationCenter |
+ callback:(DisplayedNotificationsCallback)callback; |
+ |
@end |
// ///////////////////////////////////////////////////////////////////////////// |
@@ -294,6 +301,14 @@ void NotificationPlatformBridgeMac::GetDisplayed( |
const std::string& profile_id, |
bool incognito, |
const DisplayedNotificationsCallback& callback) const { |
+#if BUILDFLAG(ENABLE_XPC_NOTIFICATIONS) |
+ [alert_dispatcher_ |
+ getDisplayedAlertsForProfileId:base::SysUTF8ToNSString(profile_id) |
+ withNotificationCenter:notification_center_ |
Peter Beverloo
2017/04/03 12:33:28
Shouldn't this call understand |incognito|?
Miguel Garcia
2017/04/04 12:21:26
Well I guess but since we don't support notificati
Peter Beverloo
2017/04/04 13:16:25
We absolutely do. Not Web Notifications, but exten
|
+ callback:callback]; |
+ |
+#else |
+ |
auto displayed_notifications = base::MakeUnique<std::set<std::string>>(); |
NSString* current_profile_id = base::SysUTF8ToNSString(profile_id); |
for (NSUserNotification* toast in |
@@ -309,6 +324,8 @@ void NotificationPlatformBridgeMac::GetDisplayed( |
content::BrowserThread::UI, FROM_HERE, |
base::Bind(callback, base::Passed(&displayed_notifications), |
true /* supports_synchronization */)); |
+ |
+#endif // ENABLE_XPC_NOTIFICATIONS |
} |
// static |
@@ -505,6 +522,38 @@ bool NotificationPlatformBridgeMac::VerifyNotificationData( |
[[self serviceProxy] closeAllNotifications]; |
} |
+- (void) |
+getDisplayedAlertsForProfileId:(NSString*)profileId |
+ withNotificationCenter:(NSUserNotificationCenter*)notificationCenter |
+ callback:(DisplayedNotificationsCallback)callback { |
+ auto reply = ^(NSArray* alerts) { |
+ 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])); |
+ } |
+ } |
+ |
+ for (NSString* alert in alerts) { |
+ displayedNotifications->insert(base::SysNSStringToUTF8(alert)); |
+ } |
Peter Beverloo
2017/04/03 12:33:28
nit: no {}
Miguel Garcia
2017/04/04 12:21:26
Done.
|
+ |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, FROM_HERE, |
+ base::Bind(callback, base::Passed(&displayedNotifications), |
+ true /* supports_synchronization */)); |
+ }; |
+ |
+ [[self serviceProxy] getDisplayedAlertsForProfileId:profileId |
+ withReply:reply]; |
+} |
+ |
// NotificationReply: |
- (void)notificationClick:(NSDictionary*)notificationResponseData { |
NotificationPlatformBridgeMac::ProcessNotificationResponse( |