Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
| 6 | 6 |
| 7 import org.chromium.base.VisibleForTesting; | 7 import org.chromium.base.VisibleForTesting; |
| 8 import org.chromium.base.metrics.RecordHistogram; | 8 import org.chromium.base.metrics.RecordHistogram; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 public static final int ABORT_REASON_INSTRUMENT_DETAILS_ERROR = 5; | 39 public static final int ABORT_REASON_INSTRUMENT_DETAILS_ERROR = 5; |
| 40 @VisibleForTesting | 40 @VisibleForTesting |
| 41 public static final int ABORT_REASON_NO_MATCHING_PAYMENT_METHOD = 6; | 41 public static final int ABORT_REASON_NO_MATCHING_PAYMENT_METHOD = 6; |
| 42 @VisibleForTesting | 42 @VisibleForTesting |
| 43 public static final int ABORT_REASON_NO_SUPPORTED_PAYMENT_METHOD = 7; | 43 public static final int ABORT_REASON_NO_SUPPORTED_PAYMENT_METHOD = 7; |
| 44 @VisibleForTesting | 44 @VisibleForTesting |
| 45 public static final int ABORT_REASON_OTHER = 8; | 45 public static final int ABORT_REASON_OTHER = 8; |
| 46 @VisibleForTesting | 46 @VisibleForTesting |
| 47 public static final int ABORT_REASON_MAX = 9; | 47 public static final int ABORT_REASON_MAX = 9; |
| 48 | 48 |
| 49 // PaymentRequestPaymentMethods defined in tools/metrics/histograms/histogra ms.xml. | |
| 50 @VisibleForTesting | |
| 51 public static final int SELECTED_METHOD_CREDIT_CARD = 0; | |
| 52 @VisibleForTesting | |
| 53 public static final int SELECTED_METHOD_ANDROID_PAY = 1; | |
| 54 @VisibleForTesting | |
| 55 public static final int SELECTED_METHOD_OTHER_PAYMENT_APP = 2; | |
| 56 @VisibleForTesting | |
| 57 public static final int SELECTED_METHOD_MAX = 3; | |
| 58 | |
| 59 // The method name associated with an Android Pay transaction. | |
| 60 private static String sAndroidPaymentMethodName = "https://android.com/pay"; | |
| 61 | |
| 49 // There should be no instance of PaymentRequestMetrics created. | 62 // There should be no instance of PaymentRequestMetrics created. |
| 50 private PaymentRequestMetrics() {} | 63 private PaymentRequestMetrics() {} |
| 51 | 64 |
| 65 /** | |
| 66 * Returns the method name corresponding to an Android Pay transaction in Pa yment Request. | |
| 67 * | |
| 68 * @return The method name corresponding to an Android Pay transaction. | |
| 69 */ | |
| 70 public static String getAndroidPayMethodName() { | |
| 71 return sAndroidPaymentMethodName; | |
| 72 } | |
| 73 | |
| 74 /** | |
| 75 * Sets the method name associated with an Android Pay transaction to the va lue used in tests. | |
| 76 */ | |
| 77 @VisibleForTesting | |
| 78 public static void setAndroidPayMethodNameForTest() { | |
| 79 sAndroidPaymentMethodName = "https://bobpay.com"; | |
| 80 } | |
|
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.
| |
| 81 | |
| 52 /* | 82 /* |
| 53 * Records the metric that keeps track of what user information are requeste d by merchants to | 83 * Records the metric that keeps track of what user information are requeste d by merchants to |
| 54 * complete a payment request. | 84 * complete a payment request. |
| 55 * | 85 * |
| 56 * @param requestEmail Whether the merchant requested an email address. | 86 * @param requestEmail Whether the merchant requested an email address. |
| 57 * @param requestPhone Whether the merchant requested a phone number. | 87 * @param requestPhone Whether the merchant requested a phone number. |
| 58 * @param requestShipping Whether the merchant requested a shipping address. | 88 * @param requestShipping Whether the merchant requested a shipping address. |
| 59 */ | 89 */ |
| 60 public static void recordRequestedInformationHistogram(boolean requestEmail, | 90 public static void recordRequestedInformationHistogram(boolean requestEmail, |
| 61 boolean requestPhone, boolean requestShipping) { | 91 boolean requestPhone, boolean requestShipping) { |
| 62 int requestInformation = | 92 int requestInformation = |
| 63 (requestEmail ? REQUESTED_INFORMATION_EMAIL : 0) | 93 (requestEmail ? REQUESTED_INFORMATION_EMAIL : 0) |
| 64 | (requestPhone ? REQUESTED_INFORMATION_PHONE : 0) | 94 | (requestPhone ? REQUESTED_INFORMATION_PHONE : 0) |
| 65 | (requestShipping ? REQUESTED_INFORMATION_SHIPPING : 0); | 95 | (requestShipping ? REQUESTED_INFORMATION_SHIPPING : 0); |
| 66 RecordHistogram.recordEnumeratedHistogram("PaymentRequest.RequestedInfor mation", | 96 RecordHistogram.recordEnumeratedHistogram("PaymentRequest.RequestedInfor mation", |
| 67 requestInformation, REQUESTED_INFORMATION_MAX); | 97 requestInformation, REQUESTED_INFORMATION_MAX); |
| 68 } | 98 } |
| 99 | |
| 100 /* | |
| 101 * Records the metric that keeps track of what payment method was used to co mplete a Payment | |
| 102 * Request transaction. | |
| 103 * | |
| 104 * @param paymentMethod The payment method that was used to complete the cur rent transaction. | |
| 105 */ | |
| 106 public static void recordSelectedPaymentMethodHistogram(int paymentMethod) { | |
| 107 assert paymentMethod < SELECTED_METHOD_MAX; | |
| 108 RecordHistogram.recordEnumeratedHistogram("PaymentRequest.SelectedPaymen tMethod", | |
| 109 paymentMethod, SELECTED_METHOD_MAX); | |
| 110 } | |
| 69 } | 111 } |
| OLD | NEW |