Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2879)

Unified Diff: chrome/browser/download/notification/download_item_notification.cc

Issue 1333323002: Add UMA metrics for the frequency of closing dangerous download notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/notification/download_item_notification.cc
diff --git a/chrome/browser/download/notification/download_item_notification.cc b/chrome/browser/download/notification/download_item_notification.cc
index cdd22caae5c5ce7a38dad1f6b7d740e97e22ceac..11b8a8c04437dface9f86c451391774cd12b287d 100644
--- a/chrome/browser/download/notification/download_item_notification.cc
+++ b/chrome/browser/download/notification/download_item_notification.cc
@@ -154,6 +154,24 @@ void RecordButtonClickAction(DownloadCommands::Command command) {
}
}
+struct DownloadItemNotificationCommandEntry {
+ DownloadCommands::Command command;
+ int id;
+};
+
+DownloadItemNotificationCommandEntry kDownloadNotificationCommand[] = {
+ {DownloadCommands::OPEN_WHEN_COMPLETE,
asanka 2015/09/16 14:07:35 DownloadsCommands is a dense enum. Why not just us
Deepak 2015/09/17 13:44:36 oops!! Good catch.
+ IDS_DOWNLOAD_STATUS_OPEN_WHEN_COMPLETE},
+ {DownloadCommands::PAUSE, IDS_DOWNLOAD_LINK_PAUSE},
+ {DownloadCommands::RESUME, IDS_DOWNLOAD_LINK_RESUME},
+ {DownloadCommands::SHOW_IN_FOLDER, IDS_DOWNLOAD_LINK_SHOW},
+ {DownloadCommands::DISCARD, IDS_DISCARD_DOWNLOAD},
+ {DownloadCommands::KEEP, IDS_CONFIRM_DOWNLOAD},
+ {DownloadCommands::CANCEL, IDS_DOWNLOAD_LINK_CANCEL},
+ {DownloadCommands::LEARN_MORE_SCANNING,
+ IDS_DOWNLOAD_LINK_LEARN_MORE_SCANNING},
+};
+
} // anonymous namespace
DownloadItemNotification::DownloadItemNotification(
@@ -199,7 +217,8 @@ void DownloadItemNotification::OnNotificationClose() {
visible_ = false;
if (item_ && item_->IsDangerous() && !item_->IsDone()) {
- // TODO(yoshiki): Add metrics.
+ content::RecordAction(
+ UserMetricsAction("DownloadNotification.Close_Dangerous"));
item_->Cancel(true /* by_user */);
return;
}
@@ -643,46 +662,14 @@ base::string16 DownloadItemNotification::GetTitle() const {
base::string16 DownloadItemNotification::GetCommandLabel(
DownloadCommands::Command command) const {
- int id = -1;
- switch (command) {
- case DownloadCommands::OPEN_WHEN_COMPLETE:
- if (item_ && !item_->IsDone())
- id = IDS_DOWNLOAD_STATUS_OPEN_WHEN_COMPLETE;
- else
- id = IDS_DOWNLOAD_STATUS_OPEN_WHEN_COMPLETE;
- break;
- case DownloadCommands::PAUSE:
- // Only for non menu.
- id = IDS_DOWNLOAD_LINK_PAUSE;
- break;
- case DownloadCommands::RESUME:
- // Only for non menu.
- id = IDS_DOWNLOAD_LINK_RESUME;
- break;
- case DownloadCommands::SHOW_IN_FOLDER:
- id = IDS_DOWNLOAD_LINK_SHOW;
- break;
- case DownloadCommands::DISCARD:
- id = IDS_DISCARD_DOWNLOAD;
- break;
- case DownloadCommands::KEEP:
- id = IDS_CONFIRM_DOWNLOAD;
- break;
- case DownloadCommands::CANCEL:
- id = IDS_DOWNLOAD_LINK_CANCEL;
- break;
- case DownloadCommands::LEARN_MORE_SCANNING:
- id = IDS_DOWNLOAD_LINK_LEARN_MORE_SCANNING;
- break;
- case DownloadCommands::ALWAYS_OPEN_TYPE:
- case DownloadCommands::PLATFORM_OPEN:
- case DownloadCommands::LEARN_MORE_INTERRUPTED:
- // Only for menu.
- NOTREACHED();
- return base::string16();
+ for (const DownloadItemNotificationCommandEntry& entry :
+ kDownloadNotificationCommand) {
+ if (entry.command == command) {
+ return l10n_util::GetStringUTF16(entry.id);
+ }
}
- CHECK(id != -1);
- return l10n_util::GetStringUTF16(id);
+ NOTREACHED();
+ return base::string16();
}
base::string16 DownloadItemNotification::GetWarningStatusString() const {
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698