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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.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/autofill/PersonalDataManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java
index 059cee3757afa2eca75e2c541bc7800c3fc1f238..3fef8acb1ebbb3619f8b11dedc371468cc65e6d0 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java
@@ -718,6 +718,49 @@ public class PersonalDataManager {
}
/**
+ * Starts loading the address validation rules for the specified {@code regionCode}.
+ *
+ * @param regionCode The code of the region for which to load the rules.
+ */
+ public void loadRulesForRegion(String regionCode) {
+ ThreadUtils.assertOnUiThread();
+ nativeLoadRulesForRegion(mPersonalDataManagerAndroid, regionCode);
+ }
+
+ @VisibleForTesting
+ boolean areRulesDoneLoadingForRegion(String regionCode) {
+ ThreadUtils.assertOnUiThread();
+ return nativeAreRulesDoneLoadingForRegion(mPersonalDataManagerAndroid, regionCode);
+ }
+
+ @VisibleForTesting
+ boolean areRulesSuccessfullyLoadedForRegion(String regionCode) {
+ ThreadUtils.assertOnUiThread();
+ return nativeAreRulesSuccessfullyLoadedForRegion(mPersonalDataManagerAndroid, regionCode);
+ }
+
+ /**
+ * Returns the normalized profile associated with the specified {@code guid}. The profile fields
+ * are normalized with the rules associated with the {@code regionCode}.
+ *
+ * This method will wait a certain amount of time for the rules to load if they are not done
+ * loading.
+ *
+ * @param guid The GUID of the profile.
+ * @param regionCode The code of the region to use for normalization.
+ */
+ public AutofillProfile getNormalizedProfile(String guid, String regionCode) {
+ ThreadUtils.assertOnUiThread();
+ return nativeGetNormalizedProfile(mPersonalDataManagerAndroid, guid, regionCode);
+ }
+
+ @VisibleForTesting
+ void setMockAddressValidatorForTesting(boolean rulesLoadedResponse) {
+ ThreadUtils.assertOnUiThread();
+ nativeSetMockAddressValidatorForTesting(mPersonalDataManagerAndroid, rulesLoadedResponse);
+ }
+
+ /**
* @return Whether the Autofill feature is enabled.
*/
public static boolean isAutofillEnabled() {
@@ -806,6 +849,16 @@ public class PersonalDataManager {
long nativePersonalDataManagerAndroid, String guid);
private native void nativeGetFullCardForPaymentRequest(long nativePersonalDataManagerAndroid,
WebContents webContents, CreditCard card, FullCardRequestDelegate delegate);
+ private native void nativeLoadRulesForRegion(
+ long nativePersonalDataManagerAndroid, String regionCode);
+ private native boolean nativeAreRulesDoneLoadingForRegion(
+ long nativePersonalDataManagerAndroid, String regionCode);
+ private native boolean nativeAreRulesSuccessfullyLoadedForRegion(
+ long nativePersonalDataManagerAndroid, String regionCode);
+ private native AutofillProfile nativeGetNormalizedProfile(
+ long nativePersonalDataManagerAndroid, String guid, String regionCode);
+ private native void nativeSetMockAddressValidatorForTesting(
+ long nativePersonalDataManagerAndroid, boolean rulesLoadedResponse);
private static native boolean nativeIsAutofillEnabled();
private static native void nativeSetAutofillEnabled(boolean enable);
private static native boolean nativeIsAutofillManaged();

Powered by Google App Engine
This is Rietveld 408576698