Commit 95d986bc authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Download: Fix an issue for open url metric in context menu.

This CL fixed an issue that copy link option in the context menu also
records an open url metric.

Bug: 967941
Change-Id: I943f610b4082a9f913e1dd7ed24036747dd94f8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1633971Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664452}
parent 4b74727b
...@@ -439,6 +439,15 @@ int FindUMAEnumValueForCommand(int id, UmaEnumIdLookupType type) { ...@@ -439,6 +439,15 @@ int FindUMAEnumValueForCommand(int id, UmaEnumIdLookupType type) {
return it->second; return it->second;
} }
// Returns true if the command id is for opening a link.
bool IsCommandForOpenLink(int id) {
return id == IDC_CONTENT_CONTEXT_OPENLINKNEWTAB ||
id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW ||
id == IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD ||
(id >= IDC_OPEN_LINK_IN_PROFILE_FIRST &&
id <= IDC_OPEN_LINK_IN_PROFILE_LAST);
}
// Usually a new tab is expected where this function is used, // Usually a new tab is expected where this function is used,
// however users should be able to open a tab in background // however users should be able to open a tab in background
// or in a new window. // or in a new window.
...@@ -959,6 +968,7 @@ void RenderViewContextMenu::RecordUsedItem(int id) { ...@@ -959,6 +968,7 @@ void RenderViewContextMenu::RecordUsedItem(int id) {
// chrome://downloads link context. // chrome://downloads link context.
if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK) && if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK) &&
IsCommandForOpenLink(id) &&
GetDocumentURL(params_) == GURL("chrome://downloads")) { GetDocumentURL(params_) == GURL("chrome://downloads")) {
base::RecordAction(base::UserMetricsAction( base::RecordAction(base::UserMetricsAction(
"Downloads_OpenUrlOfDownloadedItemFromContextMenu")); "Downloads_OpenUrlOfDownloadedItemFromContextMenu"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment