diff options
| author | miguelg <miguelg@chromium.org> | 2016-03-14 11:59:04 -0700 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-03-14 19:00:41 +0000 |
| commit | fb68c9c0e6016d74d8f3ba9b539baca76c632931 (patch) | |
| tree | b7407b0cd2d04045e493b616ca7da4a86e40a915 | |
| parent | f65e5d3d046f168889338ffba2cba5df140e9fb7 (diff) | |
| download | chromium_src-fb68c9c0e6016d74d8f3ba9b539baca76c632931.zip chromium_src-fb68c9c0e6016d74d8f3ba9b539baca76c632931.tar.gz chromium_src-fb68c9c0e6016d74d8f3ba9b539baca76c632931.tar.bz2 | |
Implement renotify in mac native notifications.
BUG=571056
Review URL: https://codereview.chromium.org/1763023003
Cr-Commit-Position: refs/heads/master@{#381028}
| -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; } |
