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 56908d85b8691880bd8035162cc15555a6b986cf..a60403bfc2d8a016fe3ffbed9b544adbf5ebed3b 100644 |
| --- a/chrome/browser/notifications/platform_notification_service_impl.cc |
| +++ b/chrome/browser/notifications/platform_notification_service_impl.cc |
| @@ -21,6 +21,7 @@ |
| #include "content/public/browser/notification_event_dispatcher.h" |
| #include "content/public/browser/platform_notification_context.h" |
| #include "content/public/browser/storage_partition.h" |
| +#include "content/public/browser/user_metrics.h" |
| #include "content/public/common/platform_notification_data.h" |
| #include "net/base/net_util.h" |
| #include "ui/message_center/notifier_settings.h" |
| @@ -38,9 +39,7 @@ |
| #include "extensions/common/permissions/permissions_data.h" |
| #endif |
| -#if defined(OS_ANDROID) |
| #include "base/strings/string_number_conversions.h" |
| -#endif |
| using content::BrowserContext; |
| using content::BrowserThread; |
| @@ -52,15 +51,15 @@ namespace { |
| // Callback to provide when deleting the data associated with persistent Web |
| // Notifications from the notification database. |
| void OnPersistentNotificationDataDeleted(bool success) { |
| - // TODO(peter): Record UMA for notification deletion requests created by the |
| - // PlatformNotificationService. |
| + content::RecordAction( |
|
Peter Beverloo
2015/05/21 11:33:10
I was thinking of using a UMA_HISTOGRAM_BOOLEAN()
Deepak
2015/05/21 14:37:02
Done.
|
| + base::UserMetricsAction("PersistentNotificationDataDeleted")); |
| } |
| // 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) { |
| - // TODO(peter): Record UMA statistics about the result status of running |
| - // events for persistent Web Notifications. |
| + content::RecordAction( |
| + base::UserMetricsAction("PersistentWebNotificationComplete")); |
| } |
| void CancelNotification(const std::string& id, ProfileID profile_id) { |
| @@ -316,10 +315,19 @@ bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( |
| if (!profile || profile->AsTestingProfile()) |
| return false; // Tests will not have a message center. |
| - // TODO(peter): Filter for persistent notifications only. |
| - *displayed_notifications = |
| + std::set<std::string> persistent_notifications; |
|
Peter Beverloo
2015/05/21 11:33:10
Please let this TODO be for now, I'm working on a
|
| + std::set<std::string> all_notifications = |
| GetNotificationUIManager()->GetAllIdsByProfile(profile); |
| - |
| + for (std::set<std::string>::iterator itr_notification = |
| + all_notifications.begin(); |
| + itr_notification != all_notifications.end(); itr_notification++) { |
| + int64_t id; |
| + if (base::StringToInt64(*itr_notification, &id) && |
| + persistent_notifications_.find(id) != persistent_notifications_.end()) { |
| + persistent_notifications.insert(*itr_notification); |
| + } |
| + } |
| + *displayed_notifications = persistent_notifications; |
| return true; |
| #else |
| // Android cannot reliably return the notifications that are currently being |