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 <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "base/metrics/user_metrics_action.h" | 11 #include "base/metrics/user_metrics_action.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 16 #include "chrome/browser/engagement/site_engagement_metrics.h" |
| 17 #include "chrome/browser/engagement/site_engagement_score.h" |
| 18 #include "chrome/browser/engagement/site_engagement_service.h" |
16 #include "chrome/browser/notifications/notification_display_service_factory.h" | 19 #include "chrome/browser/notifications/notification_display_service_factory.h" |
17 #include "chrome/browser/notifications/notification_object_proxy.h" | 20 #include "chrome/browser/notifications/notification_object_proxy.h" |
18 #include "chrome/browser/notifications/persistent_notification_delegate.h" | 21 #include "chrome/browser/notifications/persistent_notification_delegate.h" |
19 #include "chrome/browser/permissions/permission_manager.h" | 22 #include "chrome/browser/permissions/permission_manager.h" |
20 #include "chrome/browser/permissions/permission_result.h" | 23 #include "chrome/browser/permissions/permission_result.h" |
21 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/profiles/profile_attributes_storage.h" | 25 #include "chrome/browser/profiles/profile_attributes_storage.h" |
23 #include "chrome/browser/profiles/profile_io_data.h" | 26 #include "chrome/browser/profiles/profile_io_data.h" |
24 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
25 #include "chrome/browser/safe_browsing/ping_manager.h" | 28 #include "chrome/browser/safe_browsing/ping_manager.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 151 |
149 #if BUILDFLAG(ENABLE_BACKGROUND) | 152 #if BUILDFLAG(ENABLE_BACKGROUND) |
150 // Ensure the browser stays alive while the event is processed. | 153 // Ensure the browser stays alive while the event is processed. |
151 if (pending_click_dispatch_events_++ == 0) { | 154 if (pending_click_dispatch_events_++ == 0) { |
152 click_dispatch_keep_alive_.reset( | 155 click_dispatch_keep_alive_.reset( |
153 new ScopedKeepAlive(KeepAliveOrigin::PENDING_NOTIFICATION_CLICK_EVENT, | 156 new ScopedKeepAlive(KeepAliveOrigin::PENDING_NOTIFICATION_CLICK_EVENT, |
154 KeepAliveRestartOption::DISABLED)); | 157 KeepAliveRestartOption::DISABLED)); |
155 } | 158 } |
156 #endif | 159 #endif |
157 | 160 |
| 161 RecordSiteEngagement(browser_context, origin); |
158 content::NotificationEventDispatcher::GetInstance() | 162 content::NotificationEventDispatcher::GetInstance() |
159 ->DispatchNotificationClickEvent( | 163 ->DispatchNotificationClickEvent( |
160 browser_context, notification_id, origin, action_index, reply, | 164 browser_context, notification_id, origin, action_index, reply, |
161 base::Bind( | 165 base::Bind( |
162 &PlatformNotificationServiceImpl::OnClickEventDispatchComplete, | 166 &PlatformNotificationServiceImpl::OnClickEventDispatchComplete, |
163 base::Unretained(this))); | 167 base::Unretained(this))); |
164 } | 168 } |
165 | 169 |
166 void PlatformNotificationServiceImpl::OnPersistentNotificationClose( | 170 void PlatformNotificationServiceImpl::OnPersistentNotificationClose( |
167 BrowserContext* browser_context, | 171 BrowserContext* browser_context, |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 } | 526 } |
523 #endif | 527 #endif |
524 | 528 |
525 return base::string16(); | 529 return base::string16(); |
526 } | 530 } |
527 | 531 |
528 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( | 532 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( |
529 NotificationDisplayService* display_service) { | 533 NotificationDisplayService* display_service) { |
530 test_display_service_ = display_service; | 534 test_display_service_ = display_service; |
531 } | 535 } |
| 536 |
| 537 void PlatformNotificationServiceImpl::RecordSiteEngagement( |
| 538 BrowserContext* browser_context, |
| 539 const GURL& origin) { |
| 540 // TODO(dominickn, peter): This would be better if the site engagement service |
| 541 // could directly observe each notification. |
| 542 SiteEngagementService* engagement_service = |
| 543 SiteEngagementService::Get(Profile::FromBrowserContext(browser_context)); |
| 544 engagement_service->HandleNotificationInteraction(origin); |
| 545 } |
OLD | NEW |