Skip to content

Commit

Permalink
Ash Tray: Add Notifications.Cros.Actions.Tray.ExpireToTray histogram.
Browse files Browse the repository at this point in the history
This metric is logged whenever a notification popup times out and exipres to the
tray. This CL also implements a new observer function for this event.

BUG=1050809

Change-Id: Id45954d668637222a59062f8c022ba343fb8d1b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040919
Reviewed-by: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Steven Holte <holte@chromium.org>
Commit-Queue: Tim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741321}
  • Loading branch information
Tim Song authored and Commit Bot committed Feb 14, 2020
1 parent d0a2a4d commit 5188e74
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ash/system/message_center/message_center_ui_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ void MessageCenterUiController::OnBlockingStateChanged(
OnMessageCenterChanged();
}

void MessageCenterUiController::OnNotificationPopupShown(
const std::string& notification_id,
bool mark_notification_as_read) {
// Timed out popup notifications are not marked as read.
if (!mark_notification_as_read)
metrics_utils::LogPopupExpiredToTray(notification_id);
}

void MessageCenterUiController::OnMessageCenterChanged() {
if (hide_on_last_notification_ && message_center_visible_ &&
message_center_->NotificationCount() == 0) {
Expand Down
2 changes: 2 additions & 0 deletions ash/system/message_center/message_center_ui_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class ASH_EXPORT MessageCenterUiController
void OnQuietModeChanged(bool in_quiet_mode) override;
void OnBlockingStateChanged(
message_center::NotificationBlocker* blocker) override;
void OnNotificationPopupShown(const std::string& notification_id,
bool mark_notification_as_read) override;

private:
void OnMessageCenterChanged();
Expand Down
9 changes: 9 additions & 0 deletions ash/system/message_center/metrics_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,14 @@ void LogClickedActionButton(const std::string& notification_id, bool is_popup) {
}
}

void LogPopupExpiredToTray(const std::string& notification_id) {
auto type = GetNotificationType(notification_id);
if (!type.has_value())
return;

UMA_HISTOGRAM_ENUMERATION("Notifications.Cros.Actions.Popup.ExpireToTray",
type.value());
}

} // namespace metrics_utils
} // namespace ash
3 changes: 3 additions & 0 deletions ash/system/message_center/metrics_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ void LogClickedBody(const std::string& notification_id, bool is_popup);
// Logs a ClickedActionButton event.
void LogClickedActionButton(const std::string& notification_id, bool is_popup);

// Logs a ExpireToTray event for a pop-up notification.
void LogPopupExpiredToTray(const std::string& notification_id);

} // namespace metrics_utils

} // namespace ash
Expand Down
1 change: 1 addition & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182029,6 +182029,7 @@ regressions. -->
<owner>gzadina@google.com</owner>
<suffix name="Popup.ClickedActionButton" label=""/>
<suffix name="Popup.ClickedBody" label=""/>
<suffix name="Popup.ExpireToTray" label=""/>
<suffix name="Tray.ClickedActionButton" label=""/>
<suffix name="Tray.ClickedBody" label=""/>
<affected-histogram name="Notifications.Cros.Actions"/>
Expand Down
4 changes: 3 additions & 1 deletion ui/message_center/message_center_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,10 @@ void MessageCenterImpl::MarkSinglePopupAsShown(const std::string& id,

if (HasMessageCenterView()) {
notification_list_->MarkSinglePopupAsShown(id, mark_notification_as_read);
for (auto& observer : observer_list_)
for (auto& observer : observer_list_) {
observer.OnNotificationUpdated(id);
observer.OnNotificationPopupShown(id, mark_notification_as_read);
}
} else {
RemoveNotification(id, false);
}
Expand Down
5 changes: 5 additions & 0 deletions ui/message_center/message_center_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class MESSAGE_CENTER_EXPORT MessageCenterObserver {

// Called when the blocking state of |blocker| is changed.
virtual void OnBlockingStateChanged(NotificationBlocker* blocker) {}

// Called after a visible notification popup closes, indicating it has been
// shown to the user, and whether the notification is marked as read.
virtual void OnNotificationPopupShown(const std::string& notification_id,
bool mark_notification_as_read) {}
};

} // namespace message_center
Expand Down

0 comments on commit 5188e74

Please sign in to comment.