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/google_now_notification_stats_collector.h
" | 5 #include "chrome/browser/notifications/google_now_notification_stats_collector.h
" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/notifications/extension_welcome_notification.h" |
11 #include "chrome/browser/notifications/notification.h" | 12 #include "chrome/browser/notifications/notification.h" |
12 #include "chrome/browser/notifications/notification_ui_manager.h" | 13 #include "chrome/browser/notifications/notification_ui_manager.h" |
13 #include "content/public/browser/user_metrics.h" | 14 #include "content/public/browser/user_metrics.h" |
14 #include "ui/message_center/notification.h" | 15 #include "ui/message_center/notification.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 const char kChromeNowExtensionID[] = "pafkbggdmjlpgkdkcbjmhmfcdpncadgh"; | |
18 const int kNotificationsMaxCount = 20; | 18 const int kNotificationsMaxCount = 20; |
19 } | 19 } |
20 | 20 |
21 GoogleNowNotificationStatsCollector::GoogleNowNotificationStatsCollector( | 21 GoogleNowNotificationStatsCollector::GoogleNowNotificationStatsCollector( |
22 message_center::MessageCenter* message_center) | 22 message_center::MessageCenter* message_center) |
23 : message_center_(message_center) { | 23 : message_center_(message_center) { |
24 message_center_->AddObserver(this); | 24 message_center_->AddObserver(this); |
25 } | 25 } |
26 | 26 |
27 GoogleNowNotificationStatsCollector::~GoogleNowNotificationStatsCollector() { | 27 GoogleNowNotificationStatsCollector::~GoogleNowNotificationStatsCollector() { |
(...skipping 22 matching lines...) Expand all Loading... |
50 | 50 |
51 bool GoogleNowNotificationStatsCollector::IsNotificationIdForGoogleNow( | 51 bool GoogleNowNotificationStatsCollector::IsNotificationIdForGoogleNow( |
52 const std::string& notification_id) { | 52 const std::string& notification_id) { |
53 bool isGoogleNowNotification = false; | 53 bool isGoogleNowNotification = false; |
54 const Notification* const notification = | 54 const Notification* const notification = |
55 g_browser_process->notification_ui_manager()->FindById(notification_id); | 55 g_browser_process->notification_ui_manager()->FindById(notification_id); |
56 if (notification) { | 56 if (notification) { |
57 isGoogleNowNotification = | 57 isGoogleNowNotification = |
58 ((notification->notifier_id().type == | 58 ((notification->notifier_id().type == |
59 message_center::NotifierId::APPLICATION) && | 59 message_center::NotifierId::APPLICATION) && |
60 (notification->notifier_id().id == kChromeNowExtensionID)); | 60 (notification->notifier_id().id == |
| 61 ExtensionWelcomeNotification::kChromeNowExtensionID)); |
61 } | 62 } |
62 return isGoogleNowNotification; | 63 return isGoogleNowNotification; |
63 } | 64 } |
64 | 65 |
65 int GoogleNowNotificationStatsCollector::CountVisibleGoogleNowNotifications() { | 66 int GoogleNowNotificationStatsCollector::CountVisibleGoogleNowNotifications() { |
66 typedef message_center::NotificationList::Notifications Notifications; | 67 typedef message_center::NotificationList::Notifications Notifications; |
67 const Notifications visible_notifications = | 68 const Notifications visible_notifications = |
68 message_center_->GetVisibleNotifications(); | 69 message_center_->GetVisibleNotifications(); |
69 int google_now_notification_count = 0; | 70 int google_now_notification_count = 0; |
70 for (Notifications::iterator iter = visible_notifications.begin(); | 71 for (Notifications::iterator iter = visible_notifications.begin(); |
71 iter != visible_notifications.end(); | 72 iter != visible_notifications.end(); |
72 ++iter) { | 73 ++iter) { |
73 if ((*iter)->notifier_id().id == kChromeNowExtensionID) | 74 if ((*iter)->notifier_id().id == |
| 75 ExtensionWelcomeNotification::kChromeNowExtensionID) |
74 google_now_notification_count++; | 76 google_now_notification_count++; |
75 } | 77 } |
76 return google_now_notification_count; | 78 return google_now_notification_count; |
77 } | 79 } |
OLD | NEW |