summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications/notification_ui_manager_mac.mm
diff options
context:
space:
mode:
authormiguelg <miguelg@chromium.org>2016-03-14 11:59:04 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-14 19:00:41 +0000
commitfb68c9c0e6016d74d8f3ba9b539baca76c632931 (patch)
treeb7407b0cd2d04045e493b616ca7da4a86e40a915 /chrome/browser/notifications/notification_ui_manager_mac.mm
parentf65e5d3d046f168889338ffba2cba5df140e9fb7 (diff)
downloadchromium_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}
Diffstat (limited to 'chrome/browser/notifications/notification_ui_manager_mac.mm')
-rw-r--r--chrome/browser/notifications/notification_ui_manager_mac.mm17
1 files changed, 17 insertions, 0 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();