| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/message_center_stats_collector.h" | 5 #include "chrome/browser/notifications/message_center_stats_collector.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "content/public/browser/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
| 13 #include "ui/message_center/message_center.h" | 13 #include "ui/message_center/message_center.h" |
| 14 | 14 |
| 15 MessageCenterStatsCollector::NotificationStats::NotificationStats() {} | 15 MessageCenterStatsCollector::NotificationStats::NotificationStats() {} |
| 16 | 16 |
| 17 MessageCenterStatsCollector::NotificationStats::NotificationStats( | 17 MessageCenterStatsCollector::NotificationStats::NotificationStats( |
| 18 const std::string& id) : id_(id) { | 18 const std::string& id) : id_(id) { |
| 19 for (size_t i = 0; i < NOTIFICATION_ACTION_COUNT; i++) { | 19 for (size_t i = 0; i < NOTIFICATION_ACTION_COUNT; i++) { |
| 20 actions_[i] = false; | 20 actions_[i] = false; |
| 21 } | 21 } |
| 22 } | 22 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 int button_index) { | 103 int button_index) { |
| 104 StatsCollection::iterator iter = stats_.find(notification_id); | 104 StatsCollection::iterator iter = stats_.find(notification_id); |
| 105 if (iter == stats_.end()) | 105 if (iter == stats_.end()) |
| 106 return; | 106 return; |
| 107 NotificationStats& notification_stat = iter->second; | 107 NotificationStats& notification_stat = iter->second; |
| 108 | 108 |
| 109 notification_stat.CollectAction(NOTIFICATION_ACTION_BUTTON_CLICK); | 109 notification_stat.CollectAction(NOTIFICATION_ACTION_BUTTON_CLICK); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void MessageCenterStatsCollector::OnNotificationSettingsClicked() { | 112 void MessageCenterStatsCollector::OnNotificationSettingsClicked() { |
| 113 content::RecordAction( | 113 base::RecordAction(base::UserMetricsAction("Notifications.ShowSiteSettings")); |
| 114 base::UserMetricsAction("Notifications.ShowSiteSettings")); | |
| 115 } | 114 } |
| 116 | 115 |
| 117 void MessageCenterStatsCollector::OnNotificationDisplayed( | 116 void MessageCenterStatsCollector::OnNotificationDisplayed( |
| 118 const std::string& notification_id, | 117 const std::string& notification_id, |
| 119 const message_center::DisplaySource source) { | 118 const message_center::DisplaySource source) { |
| 120 StatsCollection::iterator iter = stats_.find(notification_id); | 119 StatsCollection::iterator iter = stats_.find(notification_id); |
| 121 if (iter == stats_.end()) | 120 if (iter == stats_.end()) |
| 122 return; | 121 return; |
| 123 NotificationStats& notification_stat = iter->second; | 122 NotificationStats& notification_stat = iter->second; |
| 124 | 123 |
| 125 notification_stat.CollectAction(NOTIFICATION_ACTION_DISPLAY); | 124 notification_stat.CollectAction(NOTIFICATION_ACTION_DISPLAY); |
| 126 } | 125 } |
| 127 | 126 |
| 128 void MessageCenterStatsCollector::OnCenterVisibilityChanged( | 127 void MessageCenterStatsCollector::OnCenterVisibilityChanged( |
| 129 message_center::Visibility visibility) { | 128 message_center::Visibility visibility) { |
| 130 switch (visibility) { | 129 switch (visibility) { |
| 131 case message_center::VISIBILITY_TRANSIENT: | 130 case message_center::VISIBILITY_TRANSIENT: |
| 132 break; | 131 break; |
| 133 case message_center::VISIBILITY_MESSAGE_CENTER: | 132 case message_center::VISIBILITY_MESSAGE_CENTER: |
| 134 content::RecordAction( | 133 base::RecordAction( |
| 135 base::UserMetricsAction("Notifications.ShowMessageCenter")); | 134 base::UserMetricsAction("Notifications.ShowMessageCenter")); |
| 136 break; | 135 break; |
| 137 case message_center::VISIBILITY_SETTINGS: | 136 case message_center::VISIBILITY_SETTINGS: |
| 138 content::RecordAction( | 137 base::RecordAction(base::UserMetricsAction("Notifications.ShowSettings")); |
| 139 base::UserMetricsAction("Notifications.ShowSettings")); | |
| 140 break; | 138 break; |
| 141 } | 139 } |
| 142 } | 140 } |
| 143 | 141 |
| 144 void MessageCenterStatsCollector::OnQuietModeChanged(bool in_quiet_mode) { | 142 void MessageCenterStatsCollector::OnQuietModeChanged(bool in_quiet_mode) { |
| 145 if (in_quiet_mode) { | 143 if (in_quiet_mode) { |
| 146 content::RecordAction( | 144 base::RecordAction(base::UserMetricsAction("Notifications.Mute")); |
| 147 base::UserMetricsAction("Notifications.Mute")); | |
| 148 } else { | 145 } else { |
| 149 content::RecordAction( | 146 base::RecordAction(base::UserMetricsAction("Notifications.Unmute")); |
| 150 base::UserMetricsAction("Notifications.Unmute")); | |
| 151 } | 147 } |
| 152 } | 148 } |
| OLD | NEW |