| 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 67c7e4f215a9690857478849654772026775ca39..ffaa99590f1f09d312a7b42e4b4e0775ebb3d9d5 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
|
| @@ -912,19 +912,22 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
|
| }
|
| mAddressEditor.edit(toEdit, new Callback<AutofillAddress>() {
|
| @Override
|
| - public void onResult(AutofillAddress completeAddress) {
|
| + public void onResult(AutofillAddress editedAddress) {
|
| if (mUI == null) return;
|
|
|
| - if (completeAddress == null) {
|
| - mShippingAddressesSection.setSelectedItemIndex(SectionInformation.NO_SELECTION);
|
| + // |editedAddress| could be null if something went wrong or user was adding a new
|
| + // address and cancelled out.
|
| + if (editedAddress == null) {
|
| providePaymentInformation();
|
| } else {
|
| // Set the shipping address label.
|
| - completeAddress.setShippingAddressLabelWithCountry();
|
| + editedAddress.setShippingAddressLabelWithCountry();
|
|
|
| - if (toEdit == null) mShippingAddressesSection.addAndSelectItem(completeAddress);
|
| - mCardEditor.updateBillingAddressIfComplete(completeAddress);
|
| - mClient.onShippingAddressChange(completeAddress.toPaymentAddress());
|
| + // We add a new item if the user was in the "add" flow and the result in
|
| + // |editedAddress| is non-null.
|
| + if (toEdit == null) mShippingAddressesSection.addAndSelectItem(editedAddress);
|
| + mCardEditor.updateBillingAddressIfComplete(editedAddress);
|
| + mClient.onShippingAddressChange(editedAddress.toPaymentAddress());
|
| }
|
| }
|
| });
|
| @@ -938,13 +941,15 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
|
| }
|
| mContactEditor.edit(toEdit, new Callback<AutofillContact>() {
|
| @Override
|
| - public void onResult(AutofillContact completeContact) {
|
| + public void onResult(AutofillContact editedContact) {
|
| if (mUI == null) return;
|
|
|
| - if (completeContact == null) {
|
| - mContactSection.setSelectedItemIndex(SectionInformation.NO_SELECTION);
|
| - } else if (toEdit == null) {
|
| - mContactSection.addAndSelectItem(completeContact);
|
| + // |editedContact| could be null if something went wrong or user was adding a
|
| + // contact and cancelled out of that flow. In the following block we add an item to
|
| + // the list if we were in the "add" flow, and the result in |editedContact| is
|
| + // non-null.
|
| + if (toEdit == null && editedContact != null) {
|
| + mContactSection.addAndSelectItem(editedContact);
|
| }
|
|
|
| mUI.updateSection(PaymentRequestUI.TYPE_CONTACT_DETAILS, mContactSection);
|
| @@ -960,13 +965,14 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
|
| }
|
| mCardEditor.edit(toEdit, new Callback<AutofillPaymentInstrument>() {
|
| @Override
|
| - public void onResult(AutofillPaymentInstrument completeCard) {
|
| + public void onResult(AutofillPaymentInstrument editedCard) {
|
| if (mUI == null) return;
|
|
|
| - if (completeCard == null) {
|
| - mPaymentMethodsSection.setSelectedItemIndex(SectionInformation.NO_SELECTION);
|
| - } else if (toEdit == null) {
|
| - mPaymentMethodsSection.addAndSelectItem(completeCard);
|
| + // |editedCard| could be null if something went wrong or user was adding a card
|
| + // and cancelled out of that flow. In the following block we add an item to the list
|
| + // if we were in the "add" flow and the result in |editedCard| is non-null.
|
| + if (toEdit == null && editedCard != null) {
|
| + mPaymentMethodsSection.addAndSelectItem(editedCard);
|
| }
|
|
|
| updateInstrumentModifiedTotals();
|
|
|