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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/NewTabPageUma.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 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
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/NewTabPageUma.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/NewTabPageUma.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/NewTabPageUma.java
new file mode 100644
index 0000000000000000000000000000000000000000..dfe117ea44b29099b954f50c019877c88a9d3f78
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/NewTabPageUma.java
@@ -0,0 +1,78 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.ntp;
+
+import org.chromium.base.metrics.RecordHistogram;
+import org.chromium.base.metrics.RecordUserAction;
+import org.chromium.chrome.browser.UrlUtilities;
+import org.chromium.ui.base.PageTransition;
+
+/**
+ * Records UMA stats for which actions the user takes on the NTP in the
+ * "NewTabPage.ActionAndroid" histogram.
+ */
+public class NewTabPageUma {
+ // Possible actions taken by the user on the NTP. These values are also defined in
+ // histograms.xml. WARNING: these values must stay in sync with histograms.xml.
+
+ // User performed a search using the omnibox
+ private static final int ACTION_SEARCHED_USING_OMNIBOX = 0;
+ // User navigated to Google search homepage using the omnibox
+ private static final int ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE = 1;
+ // User navigated to any other page using the omnibox
+ private static final int ACTION_NAVIGATED_USING_OMNIBOX = 2;
+ // User opened a most visited page
+ public static final int ACTION_OPENED_MOST_VISITED_ENTRY = 3;
+ // User opened a recently closed tab
+ public static final int ACTION_OPENED_RECENTLY_CLOSED_ENTRY = 4;
+ // User opened a bookmark
+ public static final int ACTION_OPENED_BOOKMARK = 5;
+ // User opened a foreign session (from recent tabs section)
+ public static final int ACTION_OPENED_FOREIGN_SESSION = 6;
+ // The number of possible actions
+ private static final int NUM_ACTIONS = 7;
+
+ /**
+ * Records an action taken by the user on the NTP.
+ * @param action One of the ACTION_* values defined in this class.
+ */
+ public static void recordAction(int action) {
+ assert action >= 0;
+ assert action < NUM_ACTIONS;
+ switch (action) {
+ case ACTION_OPENED_MOST_VISITED_ENTRY:
+ RecordUserAction.record("MobileNTPMostVisited");
+ break;
+ case ACTION_OPENED_RECENTLY_CLOSED_ENTRY:
+ RecordUserAction.record("MobileNTPRecentlyClosed");
+ break;
+ case ACTION_OPENED_BOOKMARK:
+ RecordUserAction.record("MobileNTPBookmark");
+ break;
+ case ACTION_OPENED_FOREIGN_SESSION:
+ RecordUserAction.record("MobileNTPForeignSession");
+ break;
+ default:
+ // No UMA action associated with this type.
+ break;
+ }
+ RecordHistogram.recordEnumeratedHistogram("NewTabPage.ActionAndroid", action, NUM_ACTIONS);
+ }
+
+ /**
+ * Record that the user has navigated away from the NTP using the omnibox.
+ * @param destinationUrl The URL to which the user navigated.
+ * @param transitionType The transition type of the navigation, from PageTransition.java.
+ */
+ public static void recordOmniboxNavigation(String destinationUrl, int transitionType) {
+ if ((transitionType & PageTransition.CORE_MASK) == PageTransition.GENERATED) {
+ recordAction(ACTION_SEARCHED_USING_OMNIBOX);
+ } else if (UrlUtilities.nativeIsGoogleHomePageUrl(destinationUrl)) {
+ recordAction(ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE);
+ } else {
+ recordAction(ACTION_NAVIGATED_USING_OMNIBOX);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698