Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillAddress.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillAddress.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillAddress.java |
| index 4453c3e2ae10f0c8fe09867fd2ae8cadc91cf627..d3b528050236c138484d593d0e65921069fc8faf 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillAddress.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillAddress.java |
| @@ -59,6 +59,12 @@ public class AutofillAddress extends PaymentOption { |
| private Context mContext; |
| private AutofillProfile mProfile; |
| @Nullable private Pattern mLanguageScriptCodePattern; |
| + @Nullable |
|
please use gerrit instead
2016/11/23 21:40:50
Nit: put on same line to match the other member va
sebsg
2016/11/25 15:55:20
Yeah sorry it's "git cl format" again :P I should
|
| + private String mShippingLabelWithCountry; |
| + @Nullable |
| + private String mShippingLabelWithoutCountry; |
| + @Nullable |
| + private String mBillingLabel; |
| /** |
| * Builds the autofill address. |
| @@ -86,6 +92,12 @@ public class AutofillAddress extends PaymentOption { |
| * @param profile The new profile to use. |
| */ |
| public void completeAddress(AutofillProfile profile) { |
| + // Since the profile changed, our cached labels are now out of date. Set them to null so the |
| + // labels are recomputed next time they are needed. |
| + mShippingLabelWithCountry = null; |
| + mShippingLabelWithoutCountry = null; |
| + mBillingLabel = null; |
| + |
| mProfile = profile; |
| updateIdentifierAndLabels(mProfile.getGUID(), mProfile.getFullName(), mProfile.getLabel(), |
| mProfile.getPhoneNumber()); |
| @@ -94,15 +106,36 @@ public class AutofillAddress extends PaymentOption { |
| } |
| /* |
|
please use gerrit instead
2016/11/23 21:40:50
Should be /** because this is a javadoc for a publ
sebsg
2016/11/25 15:55:20
Done.
|
| - * Gets the shipping address label for the profile associated with this address and sets it as |
| - * sublabel for this PaymentOption. |
| + * Gets the shipping address label which includes the country for the profile associated with |
| + * this address and sets it as sublabel for this PaymentOption. |
| */ |
| - public void setShippingAddressLabel() { |
| + public void setShippingAddressLabelWithCountry() { |
| assert mProfile != null; |
| - mProfile.setLabel( |
| - PersonalDataManager.getInstance().getShippingAddressLabelForPaymentRequest( |
| - mProfile)); |
| + if (mShippingLabelWithCountry == null) { |
| + mShippingLabelWithCountry = |
| + PersonalDataManager.getInstance() |
| + .getShippingAddressLabelWithCountryForPaymentRequest(mProfile); |
| + } |
| + |
| + mProfile.setLabel(mShippingLabelWithCountry); |
| + updateSublabel(mProfile.getLabel()); |
| + } |
| + |
| + /* |
|
please use gerrit instead
2016/11/23 21:40:50
/**
sebsg
2016/11/25 15:55:20
Done.
|
| + * Gets the shipping address label which does not include the country for the profile associated |
| + * with this address and sets it as sublabel for this PaymentOption. |
| + */ |
| + public void setShippingAddressLabelWithoutCountry() { |
| + assert mProfile != null; |
| + |
| + if (mShippingLabelWithoutCountry == null) { |
| + mShippingLabelWithoutCountry = |
| + PersonalDataManager.getInstance() |
| + .getShippingAddressLabelWithoutCountryForPaymentRequest(mProfile); |
| + } |
| + |
| + mProfile.setLabel(mShippingLabelWithoutCountry); |
| updateSublabel(mProfile.getLabel()); |
| } |
| @@ -113,8 +146,13 @@ public class AutofillAddress extends PaymentOption { |
| public void setBillingAddressLabel() { |
| assert mProfile != null; |
| - mProfile.setLabel(PersonalDataManager.getInstance().getBillingAddressLabelForPaymentRequest( |
| - mProfile)); |
| + if (mBillingLabel == null) { |
| + mBillingLabel = |
| + PersonalDataManager.getInstance().getBillingAddressLabelForPaymentRequest( |
| + mProfile); |
| + } |
| + |
| + mProfile.setLabel(mBillingLabel); |
| updateSublabel(mProfile.getLabel()); |
| } |