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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java

Issue 1965013004: Record user actions for long-press follow-on actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed MobileSelectionChanged to SelectionChanged. Created 4 years, 7 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 | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java » ('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/contextualsearch/ContextualSearchManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java
index 38e3ab719b52a8ef0a48dc60c49ec6ade424f85c..b61d2f020111ad407f585285e66e7a597060e5e4 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java
@@ -14,6 +14,7 @@ import org.chromium.base.ObserverList;
import org.chromium.base.SysUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate;
@@ -50,6 +51,7 @@ import org.chromium.ui.base.WindowAndroid;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.regex.Pattern;
import javax.annotation.Nullable;
@@ -78,6 +80,8 @@ public class ContextualSearchManager implements ContextualSearchManagementDelega
// We blacklist this URL because malformed URLs may bring up this page.
private static final String BLACKLISTED_URL = "about:blank";
+ private static final Pattern CONTAINS_WHITESPACE_PATTERN = Pattern.compile("\\s");
+
private final ObserverList<ContextualSearchObserver> mObservers =
new ObserverList<ContextualSearchObserver>();
@@ -424,6 +428,18 @@ public class ContextualSearchManager implements ContextualSearchManagementDelega
mDidStartLoadingResolvedSearchRequest = false;
mSearchPanel.setSearchTerm(mSelectionController.getSelectedText());
if (shouldPrefetch) loadSearchUrl();
+
+ // Record metrics for manual refinement of the search term from long-press.
+ // TODO(donnd): remove this section once metrics have been analyzed.
+ if (mSelectionController.getSelectionType() == SelectionType.LONG_PRESS
+ && mSearchPanel.isPeeking()) {
+ boolean isSingleWord =
+ !CONTAINS_WHITESPACE_PATTERN
+ .matcher(mSelectionController.getSelectedText().trim())
+ .find();
+ RecordUserAction.record(isSingleWord ? "ContextualSearch.ManualRefineSingleWord"
rkaplow 2016/05/12 22:01:51 would this make more sense as a histogram? Do you
Donn Denman 2016/05/12 22:12:58 Yes, we do want the timing information because we'
+ : "ContextualSearch.ManualRefineMultiWord");
+ }
}
if (!didRequestSurroundings) {
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698