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

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

Issue 2526943003: [Payments] Remove country from shipping label in bottom and fullsheet. (Closed)
Patch Set: Moved assertion Created 4 years, 1 month 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/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..c4af2085c022e8746d312a8b593cdbc015a8a0e4 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,9 @@ public class AutofillAddress extends PaymentOption {
private Context mContext;
private AutofillProfile mProfile;
@Nullable private Pattern mLanguageScriptCodePattern;
+ @Nullable private String mShippingLabelWithCountry;
+ @Nullable private String mShippingLabelWithoutCountry;
+ @Nullable private String mBillingLabel;
/**
* Builds the autofill address.
@@ -86,6 +89,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());
@@ -93,16 +102,37 @@ public class AutofillAddress extends PaymentOption {
assert mIsComplete;
}
- /*
- * 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());
+ }
+
+ /**
+ * 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 +143,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());
}

Powered by Google App Engine
This is Rietveld 408576698