Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2244)

Unified Diff: chrome/browser/push_messaging/push_messaging_notification_manager.cc

Issue 1149243005: Automatically close the default push notification when a real one appears. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698