OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 5 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/metrics/user_metrics_action.h" | 9 #include "base/metrics/user_metrics_action.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 : notification_ui_manager_for_tests_(nullptr) {} | 94 : notification_ui_manager_for_tests_(nullptr) {} |
95 | 95 |
96 PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {} | 96 PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {} |
97 | 97 |
98 void PlatformNotificationServiceImpl::OnPersistentNotificationClick( | 98 void PlatformNotificationServiceImpl::OnPersistentNotificationClick( |
99 BrowserContext* browser_context, | 99 BrowserContext* browser_context, |
100 int64_t persistent_notification_id, | 100 int64_t persistent_notification_id, |
101 const GURL& origin, | 101 const GURL& origin, |
102 int action_index) const { | 102 int action_index) const { |
103 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 103 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
104 content::RecordAction( | 104 if (action_index == -1) { |
Peter Beverloo
2015/10/28 16:27:07
Please don't forget about https://codereview.chrom
johnme
2015/10/28 18:43:48
Acknowledged. I already rebased my local 142267300
| |
105 base::UserMetricsAction("Notifications.Persistent.Clicked")); | 105 content::RecordAction(base::UserMetricsAction( |
106 "Notifications.Persistent.Clicked")); | |
107 } else { | |
108 content::RecordAction(base::UserMetricsAction( | |
109 "Notifications.Persistent.ClickedActionButton")); | |
110 } | |
106 | 111 |
107 content::NotificationEventDispatcher::GetInstance() | 112 content::NotificationEventDispatcher::GetInstance() |
108 ->DispatchNotificationClickEvent( | 113 ->DispatchNotificationClickEvent( |
109 browser_context, | 114 browser_context, |
110 persistent_notification_id, | 115 persistent_notification_id, |
111 origin, | 116 origin, |
112 action_index, | 117 action_index, |
113 base::Bind(&OnEventDispatchComplete)); | 118 base::Bind(&OnEventDispatchComplete)); |
114 } | 119 } |
115 | 120 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 Notification notification = CreateNotificationFromData( | 293 Notification notification = CreateNotificationFromData( |
289 profile, origin, icon, notification_data, delegate); | 294 profile, origin, icon, notification_data, delegate); |
290 | 295 |
291 // TODO(peter): Remove this mapping when we have reliable id generation for | 296 // TODO(peter): Remove this mapping when we have reliable id generation for |
292 // the message_center::Notification objects. | 297 // the message_center::Notification objects. |
293 persistent_notifications_[persistent_notification_id] = notification.id(); | 298 persistent_notifications_[persistent_notification_id] = notification.id(); |
294 | 299 |
295 GetNotificationUIManager()->Add(notification, profile); | 300 GetNotificationUIManager()->Add(notification, profile); |
296 content::RecordAction( | 301 content::RecordAction( |
297 base::UserMetricsAction("Notifications.Persistent.Shown")); | 302 base::UserMetricsAction("Notifications.Persistent.Shown")); |
303 UMA_HISTOGRAM_CUSTOM_COUNTS("Notifications.PersistentNotificationActionCount", | |
304 notification_data.actions.size(), | |
305 0, 10, 12 /* one extra bucket for > 10 */); | |
Peter Beverloo
2015/10/28 16:27:07
I don't understand, |notification_data.actions.siz
johnme
2015/10/28 18:43:48
No, but that's a good idea. Done.
| |
298 | 306 |
299 HostContentSettingsMapFactory::GetForProfile(profile)->UpdateLastUsage( | 307 HostContentSettingsMapFactory::GetForProfile(profile)->UpdateLastUsage( |
300 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 308 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
301 } | 309 } |
302 | 310 |
303 void PlatformNotificationServiceImpl::ClosePersistentNotification( | 311 void PlatformNotificationServiceImpl::ClosePersistentNotification( |
304 BrowserContext* browser_context, | 312 BrowserContext* browser_context, |
305 int64_t persistent_notification_id) { | 313 int64_t persistent_notification_id) { |
306 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 314 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
307 | 315 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | 442 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
435 origin.host(), extensions::ExtensionRegistry::EVERYTHING); | 443 origin.host(), extensions::ExtensionRegistry::EVERYTHING); |
436 DCHECK(extension); | 444 DCHECK(extension); |
437 | 445 |
438 return base::UTF8ToUTF16(extension->name()); | 446 return base::UTF8ToUTF16(extension->name()); |
439 } | 447 } |
440 #endif | 448 #endif |
441 | 449 |
442 return base::string16(); | 450 return base::string16(); |
443 } | 451 } |
OLD | NEW |