Index: chrome/browser/push_messaging/push_messaging_notification_manager.cc |
diff --git a/chrome/browser/push_messaging/push_messaging_notification_manager.cc b/chrome/browser/push_messaging/push_messaging_notification_manager.cc |
index e02d170a7bac38098bc833fd2607673ca3857dcc..d082993b7f7da97c8dd5e52ad4b485ff986d2ace 100644 |
--- a/chrome/browser/push_messaging/push_messaging_notification_manager.cc |
+++ b/chrome/browser/push_messaging/push_messaging_notification_manager.cc |
@@ -143,11 +143,31 @@ void PushMessagingNotificationManager::DidGetNotificationsFromDatabase( |
notification_needed = false; |
break; |
} |
-#if defined(OS_ANDROID) |
johnme
2015/06/02 13:43:52
Please don't remove this. The double closing brack
Peter Beverloo
2015/06/02 13:58:08
I'm having a very hard time accepting that reasoni
|
} |
-#else |
+ |
+ // If more than two notifications are showing for this Service Worker, close |
+ // the default notification if it happens to be part of this group. |
+ if (notification_count >= 2) { |
+ for (const auto& notification_database_data : data) { |
+ if (notification_database_data.notification_data.tag != |
+ kPushMessagingForcedNotificationTag) |
+ continue; |
+ |
+ PlatformNotificationServiceImpl* platform_notification_service = |
+ PlatformNotificationServiceImpl::GetInstance(); |
+ |
+ // First close the notification for the user's point of view, and then |
+ // manually tell the service that the notification has been closed in |
+ // order to avoid duplicating the thread-jump logic. |
+ platform_notification_service->ClosePersistentNotification( |
+ profile_, notification_database_data.notification_id); |
+ platform_notification_service->OnPersistentNotificationClose( |
+ profile_, notification_database_data.notification_id, |
+ notification_database_data.origin); |
+ |
+ break; |
+ } |
} |
-#endif |
// Don't track push messages that didn't show a notification but were exempt |
// from needing to do so. |