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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/CardEditor.java

Issue 2844463004: Rename card 'type' into 'issuer network.' (Closed)
Patch Set: read -> use Created 3 years, 8 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/payments/CardEditor.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/CardEditor.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/CardEditor.java
index 32db6c33c52b65ee520cf1ff778f6f1aa96b9b24..b47e7a2fb72eac50c9f0edc1ddb771840ee17bb6 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/CardEditor.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/CardEditor.java
@@ -51,8 +51,11 @@ import javax.annotation.Nullable;
public class CardEditor extends EditorBase<AutofillPaymentInstrument>
implements CreditCardScanner.Delegate {
/** Description of a card type. */
- private static class CardTypeInfo {
- /** The identifier for the drawable resource of the card type, e.g., R.drawable.pr_visa. */
+ private static class CardIssuerNetwork {
+ /**
+ * The identifier for the drawable resource of the card issuer network, e.g.,
+ * R.drawable.pr_visa.
+ */
public final int icon;
/**
@@ -62,12 +65,12 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
public final int description;
/**
- * Builds a description of a card type.
+ * Builds a description of a card issuer network.
*
- * @param icon The identifier for the drawable resource of the card type.
+ * @param icon The identifier for the drawable resource of the card issuer network.
* @param description The identifier for the localized description string for accessibility.
*/
- public CardTypeInfo(int icon, int description) {
+ public CardIssuerNetwork(int icon, int description) {
this.icon = icon;
this.description = description;
}
@@ -109,30 +112,31 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
@Nullable private final PaymentRequestServiceObserverForTest mObserverForTest;
/**
- * A mapping from all card types recognized in Chrome to information about these card types. The
- * card types (e.g., "visa") are defined in:
+ * A mapping from all card issuer networks recognized in Chrome to information about these
+ * networks. The networks (e.g., "visa") are defined in:
* https://w3c.github.io/webpayments-methods-card/#method-id
*/
- private final Map<String, CardTypeInfo> mCardTypes;
+ private final Map<String, CardIssuerNetwork> mCardIssuerNetworks;
/**
- * The card types accepted by the merchant website. This is a subset of recognized cards. Used
- * in the validator.
+ * The issuer networks accepted by the merchant website. This is a subset of recognized cards.
+ * Used in the validator.
*/
- private final Set<String> mAcceptedCardTypes;
+ private final Set<String> mAcceptedIssuerNetworks;
/**
- * The card types accepted by the merchant website that should have "basic-card" as the payment
- * method. This is a subset of the accepted card types. Used when creating the complete payment
- * instrument.
+ * The issuer networks accepted by the merchant website that should have "basic-card" as the
+ * payment method. This is a subset of the accepted issuer networks. Used when creating the
+ * complete payment instrument.
*/
- private final Set<String> mAcceptedBasicCardTypes;
+ private final Set<String> mAcceptedBasicCardIssuerNetworks;
/**
- * The information about the accepted card types. Used in the editor as a hint to the user about
- * the valid card types. This is important to keep in a list, because the display order matters.
+ * The information about the accepted card issuer networks. Used in the editor as a hint to the
+ * user about the valid card issuer networks. This is important to keep in a list, because the
+ * display order matters.
*/
- private final List<CardTypeInfo> mAcceptedCardTypeInfos;
+ private final List<CardIssuerNetwork> mAcceptedCardIssuerNetworks;
private final Handler mHandler;
private final EditorFieldValidator mCardNumberValidator;
@@ -205,31 +209,35 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
}
});
- mCardTypes = new HashMap<>();
- mCardTypes.put(AMEX, new CardTypeInfo(R.drawable.pr_amex, R.string.autofill_cc_amex));
- mCardTypes.put(
- DINERS, new CardTypeInfo(R.drawable.pr_dinersclub, R.string.autofill_cc_diners));
- mCardTypes.put(
- DISCOVER, new CardTypeInfo(R.drawable.pr_discover, R.string.autofill_cc_discover));
- mCardTypes.put(JCB, new CardTypeInfo(R.drawable.pr_jcb, R.string.autofill_cc_jcb));
- mCardTypes.put(
- MASTERCARD, new CardTypeInfo(R.drawable.pr_mc, R.string.autofill_cc_mastercard));
- mCardTypes.put(MIR, new CardTypeInfo(R.drawable.pr_mir, R.string.autofill_cc_mir));
- mCardTypes.put(
- UNIONPAY, new CardTypeInfo(R.drawable.pr_unionpay, R.string.autofill_cc_union_pay));
- mCardTypes.put(VISA, new CardTypeInfo(R.drawable.pr_visa, R.string.autofill_cc_visa));
-
- mAcceptedCardTypes = new HashSet<>();
- mAcceptedBasicCardTypes = new HashSet<>();
- mAcceptedCardTypeInfos = new ArrayList<>();
+ mCardIssuerNetworks = new HashMap<>();
+ mCardIssuerNetworks.put(
+ AMEX, new CardIssuerNetwork(R.drawable.pr_amex, R.string.autofill_cc_amex));
+ mCardIssuerNetworks.put(DINERS,
+ new CardIssuerNetwork(R.drawable.pr_dinersclub, R.string.autofill_cc_diners));
+ mCardIssuerNetworks.put(DISCOVER,
+ new CardIssuerNetwork(R.drawable.pr_discover, R.string.autofill_cc_discover));
+ mCardIssuerNetworks.put(
+ JCB, new CardIssuerNetwork(R.drawable.pr_jcb, R.string.autofill_cc_jcb));
+ mCardIssuerNetworks.put(MASTERCARD,
+ new CardIssuerNetwork(R.drawable.pr_mc, R.string.autofill_cc_mastercard));
+ mCardIssuerNetworks.put(
+ MIR, new CardIssuerNetwork(R.drawable.pr_mir, R.string.autofill_cc_mir));
+ mCardIssuerNetworks.put(UNIONPAY,
+ new CardIssuerNetwork(R.drawable.pr_unionpay, R.string.autofill_cc_union_pay));
+ mCardIssuerNetworks.put(
+ VISA, new CardIssuerNetwork(R.drawable.pr_visa, R.string.autofill_cc_visa));
+
+ mAcceptedIssuerNetworks = new HashSet<>();
+ mAcceptedBasicCardIssuerNetworks = new HashSet<>();
+ mAcceptedCardIssuerNetworks = new ArrayList<>();
mHandler = new Handler();
mCardNumberValidator = new EditorFieldValidator() {
@Override
public boolean isValid(@Nullable CharSequence value) {
return value != null
- && mAcceptedCardTypes.contains(
- PersonalDataManager.getInstance().getBasicCardPaymentType(
+ && mAcceptedIssuerNetworks.contains(
+ PersonalDataManager.getInstance().getBasicCardIssuerNetwork(
value.toString(), true));
}
@@ -243,8 +251,8 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
@Override
public int getIconResourceId(@Nullable CharSequence value) {
if (value == null) return 0;
- CardTypeInfo cardTypeInfo =
- mCardTypes.get(PersonalDataManager.getInstance().getBasicCardPaymentType(
+ CardIssuerNetwork cardTypeInfo = mCardIssuerNetworks.get(
+ PersonalDataManager.getInstance().getBasicCardIssuerNetwork(
value.toString(), false));
if (cardTypeInfo == null) return 0;
return cardTypeInfo.icon;
@@ -262,8 +270,8 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
private boolean isCardNumberLengthMaximum(@Nullable CharSequence value) {
if (TextUtils.isEmpty(value)) return false;
- String cardType =
- PersonalDataManager.getInstance().getBasicCardPaymentType(value.toString(), false);
+ String cardType = PersonalDataManager.getInstance().getBasicCardIssuerNetwork(
+ value.toString(), false);
if (TextUtils.isEmpty(cardType)) return false;
// Below maximum values are consistent with the values used to check the validity of the
@@ -295,12 +303,12 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
assert data != null;
for (int i = 0; i < data.supportedMethods.length; i++) {
String method = data.supportedMethods[i];
- if (mCardTypes.containsKey(method)) {
+ if (mCardIssuerNetworks.containsKey(method)) {
addAcceptedNetwork(method);
} else if (AutofillPaymentApp.BASIC_CARD_METHOD_NAME.equals(method)) {
Set<String> basicCardNetworks = AutofillPaymentApp.convertBasicCardToNetworks(data);
if (basicCardNetworks != null) {
- mAcceptedBasicCardTypes.addAll(basicCardNetworks);
+ mAcceptedBasicCardIssuerNetworks.addAll(basicCardNetworks);
for (String network : basicCardNetworks) {
addAcceptedNetwork(network);
}
@@ -316,9 +324,9 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
* times this method is called.
*/
private void addAcceptedNetwork(String network) {
- if (!mAcceptedCardTypes.contains(network)) {
- mAcceptedCardTypes.add(network);
- mAcceptedCardTypeInfos.add(mCardTypes.get(network));
+ if (!mAcceptedIssuerNetworks.contains(network)) {
+ mAcceptedIssuerNetworks.add(network);
+ mAcceptedCardIssuerNetworks.add(mCardIssuerNetworks.get(network));
}
}
@@ -402,8 +410,8 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
public void run() {
commitChanges(card, isNewCard);
- String methodName = card.getBasicCardPaymentType();
- if (mAcceptedBasicCardTypes.contains(methodName)) {
+ String methodName = card.getBasicCardIssuerNetwork();
+ if (mAcceptedBasicCardIssuerNetworks.contains(methodName)) {
methodName = AutofillPaymentApp.BASIC_CARD_METHOD_NAME;
}
assert methodName != null;
@@ -457,9 +465,9 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
if (mIconHint == null) {
List<Integer> icons = new ArrayList<>();
List<Integer> descriptions = new ArrayList<>();
- for (int i = 0; i < mAcceptedCardTypeInfos.size(); i++) {
- icons.add(mAcceptedCardTypeInfos.get(i).icon);
- descriptions.add(mAcceptedCardTypeInfos.get(i).description);
+ for (int i = 0; i < mAcceptedCardIssuerNetworks.size(); i++) {
+ icons.add(mAcceptedCardIssuerNetworks.get(i).icon);
+ descriptions.add(mAcceptedCardIssuerNetworks.get(i).description);
}
mIconHint = EditorFieldModel.createIconList(
mContext.getString(R.string.payments_accepted_cards_label), icons,
@@ -788,11 +796,11 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
card.setMonth(mMonthField.getValue().toString());
card.setYear(mYearField.getValue().toString());
- // Calculate the basic card payment type, obfuscated number, and the icon for this card.
- // All of these depend on the card number. The type is sent to the merchant website. The
- // obfuscated number and the icon are displayed in the user interface.
+ // Calculate the basic card issuer network, obfuscated number, and the icon for this card.
+ // All of these depend on the card number. The issuer network is sent to the merchant
+ // website. The obfuscated number and the icon are displayed in the user interface.
CreditCard displayableCard = pdm.getCreditCardForNumber(card.getNumber());
- card.setBasicCardPaymentType(displayableCard.getBasicCardPaymentType());
+ card.setBasicCardIssuerNetwork(displayableCard.getBasicCardIssuerNetwork());
card.setObfuscatedNumber(displayableCard.getObfuscatedNumber());
card.setIssuerIconDrawableId(displayableCard.getIssuerIconDrawableId());

Powered by Google App Engine
This is Rietveld 408576698