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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java

Issue 1267213002: [Android] Add UMA histograms to measure context menu actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: renamed to ContextMenu.SelectedOption Created 5 years, 4 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/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
index 6d7e2d7b8da5fcdfbd0f87847c74cad86f52868c..092759f3e24118582438928039ed6c4bb6b89bb2 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
@@ -10,6 +10,7 @@ import android.text.TextUtils;
import android.view.ContextMenu;
import android.view.MenuInflater;
+import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.UrlUtilities;
import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
@@ -24,6 +25,48 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
private MenuInflater mMenuInflater;
private static final String BLANK_URL = "about:blank";
+ static class ContextMenuUma {
+ // Note: these values must match the ContextMenuOption enum in histograms.xml.
+ static final int ACTION_OPEN_IN_NEW_TAB = 0;
+ static final int ACTION_OPEN_IN_INCOGNITO_TAB = 1;
+ static final int ACTION_COPY_LINK_ADDRESS = 2;
+ static final int ACTION_COPY_EMAIL_ADDRESS = 3;
+ static final int ACTION_COPY_LINK_TEXT = 4;
+ static final int ACTION_SAVE_LINK = 5;
+ static final int ACTION_SAVE_IMAGE = 6;
+ static final int ACTION_OPEN_IMAGE = 7;
+ static final int ACTION_OPEN_IMAGE_IN_NEW_TAB = 8;
+ static final int ACTION_COPY_IMAGE = 9;
+ static final int ACTION_COPY_IMAGE_URL = 10;
+ static final int ACTION_SEARCH_BY_IMAGE = 11;
+ static final int ACTION_LOAD_IMAGES = 12;
+ static final int ACTION_LOAD_ORIGINAL_IMAGE = 13;
+ static final int ACTION_SAVE_VIDEO = 14;
+ static final int NUM_ACTIONS = 15;
+
+ /**
+ * Records a histogram entry when the user selects an item from a context menu.
+ * @param params The ContextMenuParams describing the current context menu.
+ * @param action The action that the user selected (e.g. ACTION_SAVE_IMAGE).
+ */
+ static void record(ContextMenuParams params, int action) {
+ assert action >= 0;
+ assert action < NUM_ACTIONS;
+ String histogramName;
+ if (params.isVideo()) {
+ histogramName = "ContextMenu.SelectedOption.Video";
+ } else if (params.isImage()) {
+ histogramName = params.isAnchor()
+ ? "ContextMenu.SelectedOption.ImageLink"
+ : "ContextMenu.SelectedOption.Image";
+ } else {
+ assert params.isAnchor();
+ histogramName = "ContextMenu.SelectedOption.Link";
+ }
+ RecordHistogram.recordEnumeratedHistogram(histogramName, action, NUM_ACTIONS);
+ }
+ }
+
/**
* Builds a {@link ChromeContextMenuPopulator}.
* @param delegate The {@link ChromeContextMenuItemDelegate} that will be notified with actions
@@ -136,19 +179,25 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
@Override
public boolean onItemSelected(ContextMenuHelper helper, ContextMenuParams params, int itemId) {
if (itemId == R.id.contextmenu_open_in_new_tab) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_OPEN_IN_NEW_TAB);
mDelegate.onOpenInNewTab(params.getLinkUrl(), params.getReferrer());
} else if (itemId == R.id.contextmenu_open_in_incognito_tab) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_OPEN_IN_INCOGNITO_TAB);
mDelegate.onOpenInNewIncognitoTab(params.getLinkUrl());
} else if (itemId == R.id.contextmenu_open_image) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_OPEN_IMAGE);
mDelegate.onOpenImageUrl(params.getSrcUrl(), params.getReferrer());
} else if (itemId == R.id.contextmenu_open_image_in_new_tab
|| itemId == R.id.contextmenu_open_original_image_in_new_tab) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_OPEN_IMAGE_IN_NEW_TAB);
mDelegate.onOpenImageInNewTab(params.getSrcUrl(), params.getReferrer());
} else if (itemId == R.id.contextmenu_load_images) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_LOAD_IMAGES);
DataReductionProxyUma.dataReductionProxyLoFiUIAction(
DataReductionProxyUma.ACTION_LOAD_IMAGES_CONTEXT_MENU_CLICKED);
mDelegate.onReloadIgnoringCache();
} else if (itemId == R.id.contextmenu_load_original_image) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_LOAD_ORIGINAL_IMAGE);
DataReductionProxyUma.dataReductionProxyLoFiUIAction(
DataReductionProxyUma.ACTION_LOAD_IMAGE_CONTEXT_MENU_CLICKED);
if (!DataReductionProxySettings.getInstance().wasLoFiLoadImageRequestedBefore()) {
@@ -158,32 +207,41 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
}
mDelegate.onLoadOriginalImage();
} else if (itemId == R.id.contextmenu_copy_link_address_text) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_COPY_LINK_ADDRESS);
mDelegate.onSaveToClipboard(params.getUnfilteredLinkUrl(),
ChromeContextMenuItemDelegate.CLIPBOARD_TYPE_LINK_URL);
} else if (itemId == R.id.contextmenu_copy_email_address) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_COPY_EMAIL_ADDRESS);
mDelegate.onSaveToClipboard(MailTo.parse(params.getLinkUrl()).getTo(),
ChromeContextMenuItemDelegate.CLIPBOARD_TYPE_LINK_URL);
} else if (itemId == R.id.contextmenu_copy_link_text) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_COPY_LINK_TEXT);
mDelegate.onSaveToClipboard(
params.getLinkText(), ChromeContextMenuItemDelegate.CLIPBOARD_TYPE_LINK_TEXT);
} else if (itemId == R.id.contextmenu_save_image) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_SAVE_IMAGE);
if (mDelegate.startDownload(params.getSrcUrl(), false)) {
helper.startContextMenuDownload(
false, mDelegate.isDataReductionProxyEnabledForURL(params.getSrcUrl()));
}
} else if (itemId == R.id.contextmenu_save_video) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_SAVE_VIDEO);
if (mDelegate.startDownload(params.getSrcUrl(), false)) {
helper.startContextMenuDownload(false, false);
}
} else if (itemId == R.id.contextmenu_save_link_as) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_SAVE_LINK);
if (mDelegate.startDownload(params.getUnfilteredLinkUrl(), true)) {
helper.startContextMenuDownload(true, false);
}
} else if (itemId == R.id.contextmenu_search_by_image) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_SEARCH_BY_IMAGE);
mDelegate.onSearchByImageInNewTab();
} else if (itemId == R.id.contextmenu_copy_image) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_COPY_IMAGE);
mDelegate.onSaveImageToClipboard(params.getSrcUrl());
} else if (itemId == R.id.contextmenu_copy_image_url) {
+ ContextMenuUma.record(params, ContextMenuUma.ACTION_COPY_IMAGE_URL);
mDelegate.onSaveToClipboard(
params.getSrcUrl(), ChromeContextMenuItemDelegate.CLIPBOARD_TYPE_IMAGE_URL);
} else {
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698