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

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: Addressed comments 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..0391ea92be4c05c1a8e07bc2dbad5a6973719e9d 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -67,22 +67,22 @@ namespace {
// permission without having an associated renderer process yet.
const int kInvalidRenderProcessId = -1;
-// Callback to provide when deleting the data associated with persistent Web
-// Notifications from the notification database.
-void OnPersistentNotificationDataDeleted(bool success) {
- UMA_HISTOGRAM_BOOLEAN("Notifications.PersistentNotificationDataDeleted",
- success);
-}
-
// 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) {
+void OnClickEventDispatchComplete(
+ content::PersistentNotificationStatus status) {
UMA_HISTOGRAM_ENUMERATION(
"Notifications.PersistentWebNotificationClickResult", status,
content::PersistentNotificationStatus::
PERSISTENT_NOTIFICATION_STATUS_MAX);
}
+void OnCloseEventDispatchComplete(
+ content::PersistentNotificationStatus status) {
+ // TODO(nsatragno): add Notifications.PersistentWebNotificationCloseResult
+ // metric.
+}
+
void CancelNotification(const std::string& id, ProfileID profile_id) {
PlatformNotificationServiceImpl::GetInstance()
->GetNotificationUIManager()->CancelById(id, profile_id);
@@ -203,11 +203,8 @@ void PlatformNotificationServiceImpl::OnPersistentNotificationClick(
content::NotificationEventDispatcher::GetInstance()
->DispatchNotificationClickEvent(
- browser_context,
- persistent_notification_id,
- origin,
- action_index,
- base::Bind(&OnEventDispatchComplete));
+ browser_context, persistent_notification_id, origin, action_index,
+ base::Bind(&OnClickEventDispatchComplete));
}
void PlatformNotificationServiceImpl::OnPersistentNotificationClose(
@@ -219,23 +216,15 @@ 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(&OnCloseEventDispatchComplete));
} else {
content::RecordAction(base::UserMetricsAction(
Peter Beverloo 2016/01/26 16:13:45 Even when a notification was clicked by the user,
Nina 2016/01/27 18:48:58 Good catch - I think this became an issue when I m
"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