Chromium Code Reviews| 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 97a39cd707fbb42c314d10026490e71acfc4c444..9a89c936172762fd5780b300feac9aa99edebbd0 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 |
| @@ -67,7 +67,8 @@ import java.util.Set; |
| */ |
| public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Client, |
| PaymentApp.InstrumentsCallback, PaymentInstrument.InstrumentDetailsCallback, |
| - PaymentResponseHelper.PaymentResponseRequesterDelegate { |
| + PaymentResponseHelper.PaymentResponseRequesterDelegate, |
| + PaymentOption.OptionSectionFocusChangedDelegate { |
| /** |
| * A test-only observer for the PaymentRequest service implementation. |
| */ |
| @@ -373,6 +374,10 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
| if (mUiShippingOptions.getSelectedItem() != null && !addresses.isEmpty() |
| && addresses.get(0).isComplete()) { |
| firstCompleteAddressIndex = 0; |
| + |
| + // The initial label for the selected shipping address should not include the |
| + // country. |
| + addresses.get(firstCompleteAddressIndex).setShippingAddressLabelWithoutCountry(); |
| } |
| mShippingAddressesSection = |
| @@ -438,6 +443,9 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
| new ShippingStrings( |
| options == null ? PaymentShippingType.SHIPPING : options.shippingType)); |
| + // Add the callback to change the label of shipping addresses depending on the focus. |
| + if (requestShipping) mUI.setShippingAddressSectionFocusChangedDelegate(this); |
| + |
| if (mFavicon != null) mUI.setTitleBitmap(mFavicon); |
| mFavicon = null; |
| @@ -852,7 +860,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
| providePaymentInformation(); |
| } else { |
| // Set the shipping address label. |
| - completeAddress.setShippingAddressLabel(); |
| + completeAddress.setShippingAddressLabelWithCountry(); |
| if (toEdit == null) mShippingAddressesSection.addAndSelectItem(completeAddress); |
| mCardEditor.updateBillingAddressIfComplete(completeAddress); |
| @@ -1214,6 +1222,24 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie |
| mPaymentAppRunning = false; |
| } |
| + @Override |
| + public void onOptionSectionFocusChanged( |
| + @PaymentRequestUI.DataType int dataType, boolean willFocus) { |
| + assert dataType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES; |
| + |
|
please use gerrit instead
2016/11/23 21:40:50
You might want to "assert mShippingAddressesSectio
sebsg
2016/11/25 15:55:20
Done.
|
| + AutofillAddress selectedAddress = |
| + (AutofillAddress) mShippingAddressesSection.getSelectedItem(); |
| + |
| + // The label should only include the country if the view is focused. |
| + if (willFocus) { |
| + selectedAddress.setShippingAddressLabelWithCountry(); |
| + } else { |
| + selectedAddress.setShippingAddressLabelWithoutCountry(); |
| + } |
| + |
| + mUI.updateSection(PaymentRequestUI.TYPE_SHIPPING_ADDRESSES, mShippingAddressesSection); |
| + } |
| + |
| /** |
| * Closes the UI. If the client is still connected, then it's notified of UI hiding. |
| * |