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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java

Issue 1220813010: Add UMA metrics to track the source of homescreen icons on launch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding missing SOURCE gets and puts Created 5 years, 6 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/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java b/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java
index a95aab54955c1c172841afbb0d80c41bef7d963f..e113f2607a43f68a677746d764439aac6a1cf1db 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java
@@ -15,23 +15,47 @@ import java.util.List;
*/
@JNINamespace("metrics")
public class LaunchMetrics {
- private static final List<String> sActivityUrls = new ArrayList<String>();
- private static final List<String> sTabUrls = new ArrayList<String>();
+ private static class UrlSourcePair {
+ // The source member stores the origin of the url, e.g. from the add to homescreen menu
+ // item, an app banner, or unknown. The mapping of int source values to their string names
+ // is found in the C++ ShortcutInfo struct.
+ private String mUrl;
+ private int mSource;
+
+ public UrlSourcePair(String url, int source) {
+ mUrl = url;
+ mSource = source;
+ }
+
+ public String getUrl() {
+ return mUrl;
+ }
+
+ public int getSource() {
+ return mSource;
+ }
+ }
+
+ private static final List<UrlSourcePair> sActivityUrls = new ArrayList<UrlSourcePair>();
+ private static final List<UrlSourcePair> sTabUrls = new ArrayList<UrlSourcePair>();
/**
- * Records the launch of a standalone Activity for a URL (i.e. a WebappActivity).
+ * Records the launch of a standalone Activity for a URL (i.e. a WebappActivity)
+ * added from a specific source.
* @param url URL that kicked off the Activity's creation.
+ * @param source integer id of the source from where the URL was added.
*/
- public static void recordHomeScreenLaunchIntoStandaloneActivity(String url) {
- sActivityUrls.add(url);
+ public static void recordHomeScreenLaunchIntoStandaloneActivity(String url, int source) {
+ sActivityUrls.add(new UrlSourcePair(url, source));
}
/**
* Records the launch of a Tab for a URL (i.e. a Home screen shortcut).
* @param url URL that kicked off the Tab's creation.
+ * @param source integer id of the source from where the URL was added.
*/
- public static void recordHomeScreenLaunchIntoTab(String url) {
- sTabUrls.add(url);
+ public static void recordHomeScreenLaunchIntoTab(String url, int source) {
+ sTabUrls.add(new UrlSourcePair(url, source));
}
/**
@@ -41,16 +65,16 @@ public class LaunchMetrics {
* @param webContents WebContents for the current Tab.
*/
public static void commitLaunchMetrics(WebContents webContents) {
- for (String url : sActivityUrls) {
- nativeRecordLaunch(true, url, webContents);
+ for (UrlSourcePair item : sActivityUrls) {
+ nativeRecordLaunch(true, item.getUrl(), item.getSource(), webContents);
}
- for (String url : sTabUrls) {
- nativeRecordLaunch(false, url, webContents);
+ for (UrlSourcePair item : sTabUrls) {
+ nativeRecordLaunch(false, item.getUrl(), item.getSource(), webContents);
}
sActivityUrls.clear();
sTabUrls.clear();
}
private static native void nativeRecordLaunch(
- boolean standalone, String url, WebContents webContents);
+ boolean standalone, String url, int source, WebContents webContents);
}

Powered by Google App Engine
This is Rietveld 408576698