Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java |
| index 6aa7e3f88dd99a52ed7e60d6df12e26967ac814f..8a1ed847ca96eb5e736cb65dcc0849a6ad69d0cb 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java |
| @@ -46,9 +46,39 @@ public final class PaymentRequestMetrics { |
| @VisibleForTesting |
| public static final int ABORT_REASON_MAX = 9; |
| + // PaymentRequestPaymentMethods defined in tools/metrics/histograms/histograms.xml. |
| + @VisibleForTesting |
| + public static final int SELECTED_METHOD_CREDIT_CARD = 0; |
| + @VisibleForTesting |
| + public static final int SELECTED_METHOD_ANDROID_PAY = 1; |
| + @VisibleForTesting |
| + public static final int SELECTED_METHOD_OTHER_PAYMENT_APP = 2; |
| + @VisibleForTesting |
| + public static final int SELECTED_METHOD_MAX = 3; |
| + |
| + // The method name associated with an Android Pay transaction. |
| + private static String sAndroidPaymentMethodName = "https://android.com/pay"; |
| + |
| // There should be no instance of PaymentRequestMetrics created. |
| private PaymentRequestMetrics() {} |
| + /** |
| + * Returns the method name corresponding to an Android Pay transaction in Payment Request. |
| + * |
| + * @return The method name corresponding to an Android Pay transaction. |
| + */ |
| + public static String getAndroidPayMethodName() { |
| + return sAndroidPaymentMethodName; |
| + } |
| + |
| + /** |
| + * Sets the method name associated with an Android Pay transaction to the value used in tests. |
| + */ |
| + @VisibleForTesting |
| + public static void setAndroidPayMethodNameForTest() { |
| + sAndroidPaymentMethodName = "https://bobpay.com"; |
| + } |
|
please use gerrit instead
2016/08/05 22:08:26
I'm not a fan of global modifiable state, if I can
sebsg
2016/08/08 16:16:50
Done.
|
| + |
| /* |
| * Records the metric that keeps track of what user information are requested by merchants to |
| * complete a payment request. |
| @@ -66,4 +96,16 @@ public final class PaymentRequestMetrics { |
| RecordHistogram.recordEnumeratedHistogram("PaymentRequest.RequestedInformation", |
| requestInformation, REQUESTED_INFORMATION_MAX); |
| } |
| + |
| + /* |
| + * Records the metric that keeps track of what payment method was used to complete a Payment |
| + * Request transaction. |
| + * |
| + * @param paymentMethod The payment method that was used to complete the current transaction. |
| + */ |
| + public static void recordSelectedPaymentMethodHistogram(int paymentMethod) { |
| + assert paymentMethod < SELECTED_METHOD_MAX; |
| + RecordHistogram.recordEnumeratedHistogram("PaymentRequest.SelectedPaymentMethod", |
| + paymentMethod, SELECTED_METHOD_MAX); |
| + } |
| } |