diff options
| -rw-r--r-- | chrome/browser/notifications/notification_ui_manager_mac.mm | 17 | ||||
| -rw-r--r-- | ui/message_center/notification.h | 3 |
2 files changed, 19 insertions, 1 deletions
diff --git a/chrome/browser/notifications/notification_ui_manager_mac.mm b/chrome/browser/notifications/notification_ui_manager_mac.mm index be72587..74023f7 100644 --- a/chrome/browser/notifications/notification_ui_manager_mac.mm +++ b/chrome/browser/notifications/notification_ui_manager_mac.mm @@ -167,6 +167,23 @@ void NotificationUIManagerMac::Add(const Notification& notification, !notification.tag().empty()) { [toast setValue:base::SysUTF8ToNSString(notification.tag()) forKey:@"identifier"]; + + // If renotify is needed, delete the notification with the same tag + // from the notification center before displaying this one. + if (notification.renotify()) { + NSUserNotificationCenter* notification_center = + [NSUserNotificationCenter defaultUserNotificationCenter]; + for (NSUserNotification* existing_notification in + [notification_center deliveredNotifications]) { + NSString* identifier = + [existing_notification valueForKey:@"identifier"]; + if ([identifier isEqual:base::SysUTF8ToNSString(notification.tag())]) { + [notification_center + removeDeliveredNotification:existing_notification]; + break; + } + } + } } int64_t persistent_notification_id = delegate->persistent_notification_id(); diff --git a/ui/message_center/notification.h b/ui/message_center/notification.h index 1214ee2..7bbcc8f 100644 --- a/ui/message_center/notification.h +++ b/ui/message_center/notification.h @@ -129,7 +129,8 @@ class MESSAGE_CENTER_EXPORT Notification { optional_fields_.vibration_pattern = vibration_pattern; } - // This property currently has no effect on non-Android platforms. + // This property currently only works in platforms that support native + // notifications. // It determines whether the sound and vibration effects should signal // if the notification is replacing another notification. bool renotify() const { return optional_fields_.renotify; } |
