Chromium Code Reviews| 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( |
|
Peter Beverloo
2016/01/21 14:17:37
Since we're already calling into content per Dispa
Nina
2016/01/25 14:54:55
Refactored code to avoid this ping - pong between
Peter Beverloo
2016/01/26 16:13:45
Note that it's between //chrome and //content - bo
Nina
2016/01/27 18:48:57
Acknowledged.
|
| + 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 |