| 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 f708a0bd47c32a8e8c116a12a92cf636e17bcc11..59fb6f413a5f1682b13508bbeb67602b2c2fe1e9 100644
|
| --- a/chrome/browser/notifications/notification_platform_bridge_mac.mm
|
| +++ b/chrome/browser/notifications/notification_platform_bridge_mac.mm
|
| @@ -120,6 +120,14 @@ void DoProcessNotificationResponse(NotificationCommon::Operation operation,
|
| // Close all notifications.
|
| - (void)closeAllNotifications;
|
|
|
| +// Get displayed alerts for |profileId| merge them with |localNotifications|
|
| +// and post |callback| to the IO thread.
|
| +- (void)
|
| +getDisplayedAlertsForProfileId:(NSString*)profileId
|
| + withLocalNotifications:(NSArray*)localNotifications
|
| + callback:(NotificationCommon::NotificationResultCallback)
|
| + callback;
|
| +
|
| @end
|
|
|
| // /////////////////////////////////////////////////////////////////////////////
|
| @@ -289,9 +297,24 @@ bool NotificationPlatformBridgeMac::GetDisplayed(
|
| objectForKey:notification_constants::kNotificationId]));
|
| }
|
| }
|
| +
|
| return true;
|
| }
|
|
|
| +void NotificationPlatformBridgeMac::GetDisplayedAsync(
|
| + const std::string& profile_id,
|
| + bool incognito,
|
| + const NotificationCommon::NotificationResultCallback& callback) const {
|
| +#if BUILDFLAG(ENABLE_XPC_NOTIFICATIONS)
|
| + [alert_dispatcher_
|
| + getDisplayedAlertsForProfileId:base::SysUTF8ToNSString(profile_id)
|
| + withLocalNotifications:[notification_center_
|
| + deliveredNotifications]
|
| + callback:callback];
|
| +
|
| +#endif // ENABLE_XPC_NOTIFICATIONS
|
| +}
|
| +
|
| // static
|
| void NotificationPlatformBridgeMac::ProcessNotificationResponse(
|
| NSDictionary* response) {
|
| @@ -476,6 +499,38 @@ bool NotificationPlatformBridgeMac::VerifyNotificationData(
|
| [[xpcConnection_ remoteObjectProxy] closeAllNotifications];
|
| }
|
|
|
| +- (void)
|
| +getDisplayedAlertsForProfileId:(NSString*)profileId
|
| + withLocalNotifications:(NSArray*)localNotifications
|
| + callback:(NotificationCommon::NotificationResultCallback)
|
| + callback {
|
| + auto reply = ^(NSArray* alerts) {
|
| + std::unique_ptr<std::set<std::string>> displayedNotifications =
|
| + base::MakeUnique<std::set<std::string>>();
|
| +
|
| + for (NSUserNotification* toast in localNotifications) {
|
| + 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));
|
| + }
|
| +
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO, FROM_HERE,
|
| + base::Bind(callback, base::Passed(&displayedNotifications),
|
| + true /* supports sync */));
|
| + };
|
| +
|
| + [[xpcConnection_ remoteObjectProxy] getDisplayedAlertsForProfileId:profileId
|
| + withReply:reply];
|
| +}
|
| +
|
| // NotificationReply implementation
|
| - (void)notificationClick:(NSDictionary*)notificationResponseData {
|
| NotificationPlatformBridgeMac::ProcessNotificationResponse(
|
|
|