Commit ce4cb377 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Add user actions for the edit-url omnibox suggestion

This patch adds user actions for the icons in the edit-url suggestion
(copy, edit, and share) as well as actions for the omnibox long-press
menu.

Bug: 881292
Change-Id: I24db676134df34bb7cdf197bb2fc93c84dc86dcd
Reviewed-on: https://chromium-review.googlesource.com/c/1419339Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625815}
parent 0121b675
...@@ -35,6 +35,7 @@ import org.chromium.base.ApiCompatibilityUtils; ...@@ -35,6 +35,7 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.SysUtils; import org.chromium.base.SysUtils;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.metrics.CachedMetrics;
import org.chromium.chrome.browser.WindowDelegate; import org.chromium.chrome.browser.WindowDelegate;
import org.chromium.chrome.browser.toolbar.ToolbarManager; import org.chromium.chrome.browser.toolbar.ToolbarManager;
import org.chromium.ui.KeyboardVisibilityDelegate; import org.chromium.ui.KeyboardVisibilityDelegate;
...@@ -50,6 +51,13 @@ public class UrlBar extends AutocompleteEditText { ...@@ -50,6 +51,13 @@ public class UrlBar extends AutocompleteEditText {
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private static final CachedMetrics.ActionEvent ACTION_LONG_PRESS_COPY =
new CachedMetrics.ActionEvent("Omnibox.LongPress.Copy");
private static final CachedMetrics.ActionEvent ACTION_LONG_PRESS_CUT =
new CachedMetrics.ActionEvent("Omnibox.LongPress.Cut");
private static final CachedMetrics.ActionEvent ACTION_LONG_PRESS_SHARE =
new CachedMetrics.ActionEvent("Omnibox.LongPress.Share");
// TODO(tedchoc): Replace with EditorInfoCompat#IME_FLAG_NO_PERSONALIZED_LEARNING or // TODO(tedchoc): Replace with EditorInfoCompat#IME_FLAG_NO_PERSONALIZED_LEARNING or
// EditorInfo#IME_FLAG_NO_PERSONALIZED_LEARNING as soon as either is available in // EditorInfo#IME_FLAG_NO_PERSONALIZED_LEARNING as soon as either is available in
// all build config types. // all build config types.
...@@ -564,6 +572,11 @@ public class UrlBar extends AutocompleteEditText { ...@@ -564,6 +572,11 @@ public class UrlBar extends AutocompleteEditText {
if ((id == android.R.id.cut || id == android.R.id.copy) if ((id == android.R.id.cut || id == android.R.id.copy)
&& !mUrlBarDelegate.shouldCutCopyVerbatim()) { && !mUrlBarDelegate.shouldCutCopyVerbatim()) {
if (id == android.R.id.cut) {
ACTION_LONG_PRESS_CUT.record();
} else {
ACTION_LONG_PRESS_COPY.record();
}
String currentText = getText().toString(); String currentText = getText().toString();
String replacementCutCopyText = mTextContextMenuDelegate.getReplacementCutCopyText( String replacementCutCopyText = mTextContextMenuDelegate.getReplacementCutCopyText(
currentText, getSelectionStart(), getSelectionEnd()); currentText, getSelectionStart(), getSelectionEnd());
...@@ -589,6 +602,10 @@ public class UrlBar extends AutocompleteEditText { ...@@ -589,6 +602,10 @@ public class UrlBar extends AutocompleteEditText {
return retVal; return retVal;
} }
if (id == android.R.id.shareText) {
ACTION_LONG_PRESS_SHARE.record();
}
return super.onTextContextMenuItem(id); return super.onTextContextMenuItem(id);
} }
......
...@@ -12,6 +12,7 @@ import android.view.View; ...@@ -12,6 +12,7 @@ import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.chromium.base.metrics.CachedMetrics;
import org.chromium.base.metrics.CachedMetrics.EnumeratedHistogramSample; import org.chromium.base.metrics.CachedMetrics.EnumeratedHistogramSample;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.ActivityTabProvider;
...@@ -67,9 +68,18 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr ...@@ -67,9 +68,18 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr
int NUM_ENTRIES = 4; int NUM_ENTRIES = 4;
} }
/** Cached metrics in the event this code is triggered prior to native being initialized. */
private static final EnumeratedHistogramSample ENUMERATED_SUGGESTION_ACTION = private static final EnumeratedHistogramSample ENUMERATED_SUGGESTION_ACTION =
new EnumeratedHistogramSample( new EnumeratedHistogramSample(
"Omnibox.EditUrlSuggestionAction", SuggestionAction.NUM_ENTRIES); "Omnibox.EditUrlSuggestionAction", SuggestionAction.NUM_ENTRIES);
private static final CachedMetrics.ActionEvent ACTION_EDIT_URL_SUGGESTION_TAP =
new CachedMetrics.ActionEvent("Omnibox.EditUrlSuggestion.Tap");
private static final CachedMetrics.ActionEvent ACTION_EDIT_URL_SUGGESTION_COPY =
new CachedMetrics.ActionEvent("Omnibox.EditUrlSuggestion.Copy");
private static final CachedMetrics.ActionEvent ACTION_EDIT_URL_SUGGESTION_EDIT =
new CachedMetrics.ActionEvent("Omnibox.EditUrlSuggestion.Edit");
private static final CachedMetrics.ActionEvent ACTION_EDIT_URL_SUGGESTION_SHARE =
new CachedMetrics.ActionEvent("Omnibox.EditUrlSuggestion.Share");
/** The name of the parameter for getting the experiment variation. */ /** The name of the parameter for getting the experiment variation. */
private static final String FIELD_TRIAL_PARAM_NAME = "variation"; private static final String FIELD_TRIAL_PARAM_NAME = "variation";
...@@ -222,9 +232,11 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr ...@@ -222,9 +232,11 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr
if (R.id.url_copy_icon == view.getId()) { if (R.id.url_copy_icon == view.getId()) {
ENUMERATED_SUGGESTION_ACTION.record(SuggestionAction.COPY); ENUMERATED_SUGGESTION_ACTION.record(SuggestionAction.COPY);
ACTION_EDIT_URL_SUGGESTION_COPY.record();
Clipboard.getInstance().copyUrlToClipboard(mLastProcessedSuggestion.getUrl()); Clipboard.getInstance().copyUrlToClipboard(mLastProcessedSuggestion.getUrl());
} else if (R.id.url_share_icon == view.getId()) { } else if (R.id.url_share_icon == view.getId()) {
ENUMERATED_SUGGESTION_ACTION.record(SuggestionAction.SHARE); ENUMERATED_SUGGESTION_ACTION.record(SuggestionAction.SHARE);
ACTION_EDIT_URL_SUGGESTION_SHARE.record();
mLocationBarDelegate.clearOmniboxFocus(); mLocationBarDelegate.clearOmniboxFocus();
// TODO(mdjones): This should only share the displayed URL instead of the background // TODO(mdjones): This should only share the displayed URL instead of the background
// tab. // tab.
...@@ -232,9 +244,11 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr ...@@ -232,9 +244,11 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr
activityTab.getActivity(), activityTab, false, activityTab.isIncognito()); activityTab.getActivity(), activityTab, false, activityTab.isIncognito());
} else if (R.id.url_edit_icon == view.getId()) { } else if (R.id.url_edit_icon == view.getId()) {
ENUMERATED_SUGGESTION_ACTION.record(SuggestionAction.EDIT); ENUMERATED_SUGGESTION_ACTION.record(SuggestionAction.EDIT);
ACTION_EDIT_URL_SUGGESTION_EDIT.record();
mLocationBarDelegate.setOmniboxEditingText(mLastProcessedSuggestion.getUrl()); mLocationBarDelegate.setOmniboxEditingText(mLastProcessedSuggestion.getUrl());
} else { } else {
ENUMERATED_SUGGESTION_ACTION.record(SuggestionAction.TAP); ENUMERATED_SUGGESTION_ACTION.record(SuggestionAction.TAP);
ACTION_EDIT_URL_SUGGESTION_TAP.record();
// If the event wasn't on any of the buttons, treat is as a tap on the general // If the event wasn't on any of the buttons, treat is as a tap on the general
// suggestion. // suggestion.
if (mSelectionHandler != null) { if (mSelectionHandler != null) {
......
...@@ -13244,6 +13244,64 @@ should be able to be added at any place in this file. ...@@ -13244,6 +13244,64 @@ should be able to be added at any place in this file.
</description> </description>
</action> </action>
<action name="Omnibox.EditUrlSuggestion.Copy">
<owner>mdjones@chromium.org</owner>
<owner>lzbylut@google.com</owner>
<description>
User tapped on the copy icon in the edit-URL omnibox suggestion on Android.
</description>
</action>
<action name="Omnibox.EditUrlSuggestion.Edit">
<owner>mdjones@chromium.org</owner>
<owner>lzbylut@google.com</owner>
<description>
User tapped on the edit icon in the edit-URL omnibox suggestion on Android.
</description>
</action>
<action name="Omnibox.EditUrlSuggestion.Share">
<owner>mdjones@chromium.org</owner>
<owner>lzbylut@google.com</owner>
<description>
User tapped on the share icon in the edit-URL omnibox suggestion on Android.
</description>
</action>
<action name="Omnibox.EditUrlSuggestion.Tap">
<owner>mdjones@chromium.org</owner>
<owner>lzbylut@google.com</owner>
<description>
User tapped on the edit-URL omnibox suggestion on Android.
</description>
</action>
<action name="Omnibox.LongPress.Copy">
<owner>mdjones@chromium.org</owner>
<owner>lzbylut@google.com</owner>
<description>
User tapped on the copy button after long-pressing on the omnibox on
Android.
</description>
</action>
<action name="Omnibox.LongPress.Cut">
<owner>mdjones@chromium.org</owner>
<owner>lzbylut@google.com</owner>
<description>
User tapped on the cut button after long-pressing on the omnibox on Android.
</description>
</action>
<action name="Omnibox.LongPress.Share">
<owner>mdjones@chromium.org</owner>
<owner>lzbylut@google.com</owner>
<description>
User tapped on the share button after long-pressing on the omnibox on
Android.
</description>
</action>
<action name="Omnibox.ServerSuggestDelete.Failure"> <action name="Omnibox.ServerSuggestDelete.Failure">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner> <owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description> <description>Please enter the description of this user action.</description>
......
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