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

Unified Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 1619703002: Implement notificationclose event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed some logging statements Created 4 years, 11 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/notifications/platform_notification_service_impl.cc
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
index 4edd70ba27455560e8dd8e587cb83eec00304c9f..de9ab9a7859e12b1f81e542b5af11cf0e32923ff 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -74,6 +74,30 @@ void OnPersistentNotificationDataDeleted(bool success) {
success);
}
+// Callback called when the persistent notification close event has been handled
+// to remove the notification from the database.
+void OnDidSendPersistentNotificationCloseEvent(
+ BrowserContext* browser_context,
+ int64_t persistent_notification_id,
+ const GURL& origin,
+ content::PersistentNotificationStatus status) {
+
+ PlatformNotificationContext* context =
+ BrowserContext::GetStoragePartitionForSite(browser_context, origin)
+ ->GetPlatformNotificationContext();
+
+ // TODO(nsatragno): add Notifications.PersistentWebNotificationCloseResult
+ // metric.
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&PlatformNotificationContext::DeleteNotificationData,
+ context,
+ persistent_notification_id,
+ origin,
+ base::Bind(&OnPersistentNotificationDataDeleted)));
+}
+
// Persistent notifications fired through the delegate do not care about the
// lifetime of the Service Worker responsible for executing the event.
void OnEventDispatchComplete(content::PersistentNotificationStatus status) {
@@ -219,23 +243,20 @@ void PlatformNotificationServiceImpl::OnPersistentNotificationClose(
if (by_user) {
content::RecordAction(base::UserMetricsAction(
"Notifications.Persistent.ClosedByUser"));
+
+ content::NotificationEventDispatcher::GetInstance()
+ ->DispatchNotificationCloseEvent(
+ browser_context,
+ persistent_notification_id,
+ origin,
+ base::Bind(&OnDidSendPersistentNotificationCloseEvent,
+ browser_context,
+ persistent_notification_id,
+ origin));
} else {
content::RecordAction(base::UserMetricsAction(
"Notifications.Persistent.ClosedProgrammatically"));
}
-
- PlatformNotificationContext* context =
- BrowserContext::GetStoragePartitionForSite(browser_context, origin)
- ->GetPlatformNotificationContext();
-
- BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(&PlatformNotificationContext::DeleteNotificationData,
- context,
- persistent_notification_id,
- origin,
- base::Bind(&OnPersistentNotificationDataDeleted)));
}
blink::WebNotificationPermission

Powered by Google App Engine
This is Rietveld 408576698