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

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
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..950078329ddd0a398b94f2d5b85b57fd968cd1ac 100644
--- a/chrome/browser/push_messaging/push_messaging_notification_manager.cc
+++ b/chrome/browser/push_messaging/push_messaging_notification_manager.cc
@@ -149,6 +149,30 @@ void PushMessagingNotificationManager::DidGetNotificationsFromDatabase(
}
#endif
+ // 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;
+ }
+ }
+
// Don't track push messages that didn't show a notification but were exempt
// from needing to do so.
if (notification_shown || notification_needed) {
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698