Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java |
index 06c9313bca9f80a42c04448c8d32cd2e98f28f86..4b6fec5f2448f4b09d09e6f66a434bfcbefcaaa4 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java |
@@ -175,7 +175,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
private Map<String, JSONObject> mMethodData; |
private SectionInformation mShippingAddressesSection; |
- private SectionInformation mContactSection; |
+ private SectionInformation mPayerInfoSection; |
private List<PaymentApp> mPendingApps; |
private List<PaymentInstrument> mPendingInstruments; |
private List<PaymentInstrument> mPendingAutofillInstruments; |
@@ -184,7 +184,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
private Callback<PaymentInformation> mPaymentInformationCallback; |
private boolean mPaymentAppRunning; |
private boolean mMerchantSupportsAutofillPaymentInstruments; |
- private ContactEditor mContactEditor; |
+ private PayerInfoEditor mPayerInfoEditor; |
private boolean mHasRecordedAbortReason; |
/** True if any of the requested payment methods are supported. */ |
@@ -325,9 +325,9 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
} |
if (requestPayerPhone || requestPayerEmail) { |
- Set<String> uniqueContactInfos = new HashSet<>(); |
- mContactEditor = new ContactEditor(requestPayerPhone, requestPayerEmail); |
- List<AutofillContact> contacts = new ArrayList<>(); |
+ Set<String> uniquePayerInfos = new HashSet<>(); |
+ mPayerInfoEditor = new PayerInfoEditor(requestPayerPhone, requestPayerEmail); |
+ List<AutofillPayerInfo> payerInfos = new ArrayList<>(); |
for (int i = 0; i < profiles.size(); i++) { |
AutofillProfile profile = profiles.get(i); |
@@ -335,41 +335,41 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
? profile.getPhoneNumber() : null; |
String email = requestPayerEmail && !TextUtils.isEmpty(profile.getEmailAddress()) |
? profile.getEmailAddress() : null; |
- mContactEditor.addPhoneNumberIfValid(phone); |
- mContactEditor.addEmailAddressIfValid(email); |
+ mPayerInfoEditor.addPhoneNumberIfValid(phone); |
+ mPayerInfoEditor.addEmailAddressIfValid(email); |
if (phone != null || email != null) { |
- // Different profiles can have identical contact info. Do not add the same |
- // contact info to the list twice. |
- String uniqueContactInfo = phone + email; |
- if (!uniqueContactInfos.contains(uniqueContactInfo)) { |
- uniqueContactInfos.add(uniqueContactInfo); |
+ // Different profiles can have identical payer info. Do not add the same |
+ // payer info to the list twice. |
+ String uniquePayerInfo = phone + email; |
+ if (!uniquePayerInfos.contains(uniquePayerInfo)) { |
+ uniquePayerInfos.add(uniquePayerInfo); |
boolean isComplete = |
- mContactEditor.isContactInformationComplete(phone, email); |
- contacts.add(new AutofillContact(profile, phone, email, isComplete)); |
+ mPayerInfoEditor.isPayerInformationComplete(phone, email); |
+ payerInfos.add(new AutofillPayerInfo(profile, phone, email, isComplete)); |
} |
} |
} |
- // Suggest complete contact infos first. |
- Collections.sort(contacts, COMPLETENESS_COMPARATOR); |
+ // Suggest complete payer infos first. |
+ Collections.sort(payerInfos, COMPLETENESS_COMPARATOR); |
// Limit the number of suggestions. |
- contacts = contacts.subList(0, Math.min(contacts.size(), SUGGESTIONS_LIMIT)); |
+ payerInfos = payerInfos.subList(0, Math.min(payerInfos.size(), SUGGESTIONS_LIMIT)); |
- // Log the number of suggested contact infos. |
+ // Log the number of suggested payer infos. |
mJourneyLogger.setNumberOfSuggestionsShown( |
- PaymentRequestJourneyLogger.SECTION_CONTACT_INFO, contacts.size()); |
+ PaymentRequestJourneyLogger.SECTION_PAYER_INFO_INFO, payerInfos.size()); |
// Automatically select the first address if it is complete. |
- int firstCompleteContactIndex = SectionInformation.NO_SELECTION; |
- if (!contacts.isEmpty() && contacts.get(0).isComplete()) { |
- firstCompleteContactIndex = 0; |
+ int firstCompletePayerInfoIndex = SectionInformation.NO_SELECTION; |
+ if (!payerInfos.isEmpty() && payerInfos.get(0).isComplete()) { |
+ firstCompletePayerInfoIndex = 0; |
} |
- mContactSection = new SectionInformation( |
- PaymentRequestUI.TYPE_CONTACT_DETAILS, firstCompleteContactIndex, contacts); |
+ mPayerInfoSection = new SectionInformation(PaymentRequestUI.TYPE_PAYER_INFO_DETAILS, |
+ firstCompletePayerInfoIndex, payerInfos); |
} |
mUI = new PaymentRequestUI(mContext, this, requestShipping, |
@@ -381,7 +381,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
mAddressEditor.setEditorView(mUI.getEditorView()); |
mCardEditor.setEditorView(mUI.getCardEditorView()); |
- if (mContactEditor != null) mContactEditor.setEditorView(mUI.getEditorView()); |
+ if (mPayerInfoEditor != null) mPayerInfoEditor.setEditorView(mUI.getEditorView()); |
PaymentRequestMetrics.recordRequestedInformationHistogram(requestPayerEmail, |
requestPayerPhone, requestShipping); |
@@ -682,7 +682,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
private void providePaymentInformation() { |
mPaymentInformationCallback.onResult( |
new PaymentInformation(mUiShoppingCart, mShippingAddressesSection, |
- mUiShippingOptions, mContactSection, mPaymentMethodsSection)); |
+ mUiShippingOptions, mPayerInfoSection, mPaymentMethodsSection)); |
mPaymentInformationCallback = null; |
} |
@@ -706,8 +706,8 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
callback.onResult(mShippingAddressesSection); |
} else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS) { |
callback.onResult(mUiShippingOptions); |
- } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { |
- callback.onResult(mContactSection); |
+ } else if (optionType == PaymentRequestUI.TYPE_PAYER_INFO_DETAILS) { |
+ callback.onResult(mPayerInfoSection); |
} else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { |
assert mPaymentMethodsSection != null; |
callback.onResult(mPaymentMethodsSection); |
@@ -741,17 +741,17 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
mClient.onShippingOptionChange(option.getIdentifier()); |
mPaymentInformationCallback = callback; |
return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION; |
- } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { |
- assert option instanceof AutofillContact; |
- // Log the change of contact info. |
+ } else if (optionType == PaymentRequestUI.TYPE_PAYER_INFO_DETAILS) { |
+ assert option instanceof AutofillPayerInfo; |
+ // Log the change of payer info. |
mJourneyLogger.incrementSelectionChanges( |
- PaymentRequestJourneyLogger.SECTION_CONTACT_INFO); |
- AutofillContact contact = (AutofillContact) option; |
+ PaymentRequestJourneyLogger.SECTION_PAYER_INFO_INFO); |
+ AutofillPayerInfo payerInfo = (AutofillPayerInfo) option; |
- if (contact.isComplete()) { |
- mContactSection.setSelectedItem(option); |
+ if (payerInfo.isComplete()) { |
+ mPayerInfoSection.setSelectedItem(option); |
} else { |
- editContact(contact); |
+ editPayerInfo(payerInfo); |
return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; |
} |
} else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { |
@@ -784,10 +784,11 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
mJourneyLogger.incrementSelectionAdds( |
PaymentRequestJourneyLogger.SECTION_SHIPPING_ADDRESS); |
return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION; |
- } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { |
- editContact(null); |
- // Log the add of contact info. |
- mJourneyLogger.incrementSelectionAdds(PaymentRequestJourneyLogger.SECTION_CONTACT_INFO); |
+ } else if (optionType == PaymentRequestUI.TYPE_PAYER_INFO_DETAILS) { |
+ editPayerInfo(null); |
+ // Log the add of payer info. |
+ mJourneyLogger.incrementSelectionAdds( |
+ PaymentRequestJourneyLogger.SECTION_PAYER_INFO_INFO); |
return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; |
} else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { |
editCard(null); |
@@ -822,24 +823,24 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
}); |
} |
- private void editContact(final AutofillContact toEdit) { |
+ private void editPayerInfo(final AutofillPayerInfo toEdit) { |
if (toEdit != null) { |
- // Log the edit of a contact info. |
+ // Log the edit of a payer info. |
mJourneyLogger.incrementSelectionEdits( |
- PaymentRequestJourneyLogger.SECTION_CONTACT_INFO); |
+ PaymentRequestJourneyLogger.SECTION_PAYER_INFO_INFO); |
} |
- mContactEditor.edit(toEdit, new Callback<AutofillContact>() { |
+ mPayerInfoEditor.edit(toEdit, new Callback<AutofillPayerInfo>() { |
@Override |
- public void onResult(AutofillContact completeContact) { |
+ public void onResult(AutofillPayerInfo completePayerInfo) { |
if (mUI == null) return; |
- if (completeContact == null) { |
- mContactSection.setSelectedItemIndex(SectionInformation.NO_SELECTION); |
+ if (completePayerInfo == null) { |
+ mPayerInfoSection.setSelectedItemIndex(SectionInformation.NO_SELECTION); |
} else if (toEdit == null) { |
- mContactSection.addAndSelectItem(completeContact); |
+ mPayerInfoSection.addAndSelectItem(completePayerInfo); |
} |
- mUI.updateSection(PaymentRequestUI.TYPE_CONTACT_DETAILS, mContactSection); |
+ mUI.updateSection(PaymentRequestUI.TYPE_PAYER_INFO_DETAILS, mPayerInfoSection); |
} |
}); |
} |
@@ -1065,13 +1066,14 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
response.methodName = methodName; |
response.stringifiedDetails = stringifiedDetails; |
- if (mContactSection != null) { |
- PaymentOption selectedContact = mContactSection.getSelectedItem(); |
- if (selectedContact != null) { |
- // Contacts are created in show(). These should all be instances of AutofillContact. |
- assert selectedContact instanceof AutofillContact; |
- response.payerPhone = ((AutofillContact) selectedContact).getPayerPhone(); |
- response.payerEmail = ((AutofillContact) selectedContact).getPayerEmail(); |
+ if (mPayerInfoSection != null) { |
+ PaymentOption selectedPayerInfo = mPayerInfoSection.getSelectedItem(); |
+ if (selectedPayerInfo != null) { |
+ // Payer informations are created in show(). These should all be instances of |
+ // AutofillPayerInfo. |
+ assert selectedPayerInfo instanceof AutofillPayerInfo; |
+ response.payerPhone = ((AutofillPayerInfo) selectedPayerInfo).getPayerPhone(); |
+ response.payerEmail = ((AutofillPayerInfo) selectedPayerInfo).getPayerEmail(); |
} |
} |