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

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

Issue 2338283003: [Payments] Normalize addresses before passing them to merchants. (Closed)
Patch Set: Created 4 years, 3 months 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/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 ae353c0e2cf68353cfe9a94a62c9b88d6fb5662c..7cb5f131789c74cbe4c456d5dd160d6a887327e5 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
@@ -298,6 +298,12 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
firstCompleteAddressIndex = 0;
}
+ // Start loading the validation rules for the regions associated with the profiles.
please use gerrit instead 2016/09/16 22:30:41 Put this block after line 291, which is the last l
sebsg 2016/09/22 19:50:40 Done.
+ for (AutofillAddress address : addresses) {
please use gerrit instead 2016/09/16 22:30:41 Use index loop. It's faster on Android.
sebsg 2016/09/22 19:50:40 Done.
+ PersonalDataManager.getInstance().loadRulesForRegion(
+ AutofillAddress.getCountryCode(address.getProfile()));
+ }
+
mShippingAddressesSection =
new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_ADDRESSES,
firstCompleteAddressIndex, addresses);
@@ -1025,6 +1031,19 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
PersonalDataManager.getInstance().recordAndLogProfileUse(
selectedAutofillAddress.getProfile().getGUID());
+ // Get the normalized profile
+ AutofillProfile normalizedProfile =
+ PersonalDataManager.getInstance().getNormalizedProfile(
+ selectedAutofillAddress.getProfile().getGUID(),
+ AutofillAddress.getCountryCode(
+ selectedAutofillAddress.getProfile()));
+
+ // If a valid profile was returned, use that one since it is normalized.
+ if (!normalizedProfile.getGUID().equals("")) {
please use gerrit instead 2016/09/16 22:30:41 If GUID cannot be null, use .isEmpty() instead of
sebsg 2016/09/22 19:50:40 Done.
+ selectedAutofillAddress = new AutofillAddress(
+ normalizedProfile, selectedAutofillAddress.isComplete());
+ }
+
response.shippingAddress = selectedAutofillAddress.toPaymentAddress();
}
}

Powered by Google App Engine
This is Rietveld 408576698