Index: chrome/android/java/src/org/chromium/chrome/browser/snackbar/Snackbar.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/snackbar/Snackbar.java b/chrome/android/java/src/org/chromium/chrome/browser/snackbar/Snackbar.java |
index e67388e0996a6ac85e3de96e0d4e7c231c532050..2cb628253e0f3bd94705f1042ba906d548346cda 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/snackbar/Snackbar.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/snackbar/Snackbar.java |
@@ -15,7 +15,8 @@ import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; |
* |
* SnackbarManager.showSnackbar( |
* Snackbar.make("Closed example.com", controller) |
- * .setAction("undo", actionData)); |
+ * .setAction("undo", actionData) |
+ * .setPurpose(Snackbar.UMA_TAB_CLOSE_UNDO)); |
*/ |
public class Snackbar { |
/** |
@@ -31,6 +32,24 @@ public class Snackbar { |
*/ |
public static final int TYPE_NOTIFICATION = 1; |
+ /** |
+ * UMA Identifiers of the purpose of the snackbar. See SnackbarIdentifier enum in histograms. |
+ */ |
+ public static final int UMA_INVALID = -1; |
rkaplow
2016/05/16 21:52:09
i wonder if UMA_UNKNOWN is a better way of phrasin
Ian Wen
2016/05/17 01:07:55
Done.
|
+ public static final int UMA_BOOKMARK_ADDED = 0; |
+ public static final int UMA_BOOKMARK_DELETE_UNDO = 1; |
+ public static final int UMA_NTP_MOST_VISITED_DELETE_UNDO = 2; |
+ public static final int UMA_OFFLINE_PAGE_RELOAD = 3; |
+ public static final int UMA_AUTO_LOGIN = 4; |
+ public static final int UMA_OMNIBOX_GEOLOCATION = 5; |
+ public static final int UMA_LOFI = 6; |
+ public static final int UMA_DATA_USE_STARTED = 7; |
+ public static final int UMA_DATA_USE_ENDED = 8; |
+ public static final int UMA_DOWNLOAD_SUCCEEDED = 9; |
+ public static final int UMA_DOWNLOAD_FAILED = 10; |
+ public static final int UMA_TAB_CLOSE_UNDO = 11; |
+ public static final int UMA_TAB_CLOSE_ALL_UNDO = 12; |
+ |
private SnackbarController mController; |
private CharSequence mText; |
private String mTemplateText; |
@@ -41,12 +60,15 @@ public class Snackbar { |
private int mDurationMs; |
private Bitmap mProfileImage; |
private int mType; |
+ private int mPurpose = UMA_INVALID; |
// Prevent instantiation. |
private Snackbar() {} |
/** |
- * Creates and returns a snackbar to display the given text. |
+ * Creates and returns a snackbar to display the given text. If this is a snackbar for a new |
+ * feature shown to the user, please call {@link #setPurpose(int)} as well, and add feature to |
+ * SnackbarIdentifier in histograms.xml. |
* |
* @param text The text to show on the snackbar. |
* @param controller The SnackbarController to receive callbacks about the snackbar's state. |
@@ -83,6 +105,15 @@ public class Snackbar { |
} |
/** |
+ * Sets the purpose of this snackbar. This is for UMA and should be called on every snackbar |
+ * designed for a feature. |
+ */ |
+ public Snackbar setPurpose(int purpose) { |
+ mPurpose = purpose; |
+ return this; |
+ } |
+ |
+ /** |
* Sets the identity profile image that will be displayed at the beginning of the snackbar. |
* If null, there won't be a profile image. The ability to have an icon is exclusive to |
* identity snackbars. |
@@ -145,6 +176,10 @@ public class Snackbar { |
return mDurationMs; |
} |
+ int getPurpose() { |
+ return mPurpose; |
+ } |
+ |
/** |
* If method returns zero, then default color for snackbar will be used. |
*/ |