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..948091a7348152ba9099508a80c466add2f8526f 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 |
@@ -478,6 +478,9 @@ public class PersonalDataManager { |
private final List<PersonalDataManagerObserver> mDataObservers = |
new ArrayList<PersonalDataManagerObserver>(); |
+ // The requester of the address normalization. |
+ private NormalizedAddressRequester mRequester; |
please use gerrit instead
2016/09/23 09:04:39
Don't save the pointer here. Follow the pattern of
sebsg
2016/09/27 18:48:37
Done.
|
+ |
private PersonalDataManager() { |
// Note that this technically leaks the native object, however, PersonalDataManager |
// is a singleton that lives forever and there's no clean shutdown of Chrome on Android |
@@ -718,6 +721,57 @@ 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); |
+ } |
+ |
+ /** |
+ * Sets up the task to start normalizing the address of the profile associated with the |
+ * specified {@code guid} when the rules associated with the {@code regionCode} are done |
+ * loading. After completion, the normalized profile will be sent to the {@code requester}. |
+ * |
+ * @param guid The GUID of the profile to normalize. |
+ * @param regionCode The region code indicating which rules to use for normalization. |
+ * @param requester The object requesting the normalization. |
+ */ |
+ public void startAddressNormalizationTask( |
please use gerrit instead
2016/09/23 09:04:39
"normalizeAddress()" is a simpler name.
sebsg
2016/09/27 18:48:37
I wanted the name to reflect the fact that it can
|
+ String guid, String regionCode, NormalizedAddressRequester requester) { |
+ ThreadUtils.assertOnUiThread(); |
+ mRequester = requester; |
+ nativeStartAddressNormalizationTask(mPersonalDataManagerAndroid, guid, regionCode); |
+ } |
+ |
+ /** |
+ * Cancels the pending normalization task. |
+ */ |
+ public void cancelAddressNormalizationTask() { |
please use gerrit instead
2016/09/23 09:04:39
"cancelPendingAddressNormalization()"
sebsg
2016/09/27 18:48:37
Done.
|
+ ThreadUtils.assertOnUiThread(); |
+ if (mRequester != null) { |
+ mRequester = null; |
+ nativeCancelAddressNormalizationTask(mPersonalDataManagerAndroid); |
+ } |
+ } |
+ |
+ /** |
+ * Called from native when the requested address normalization has been completed. |
+ * |
+ * @param profile The profile with the normalized address. |
+ */ |
+ @CalledByNative |
+ private void onAddressNormalized(AutofillProfile profile) { |
+ ThreadUtils.assertOnUiThread(); |
+ if (mRequester != null) { |
+ mRequester.onAddressNormalized(profile); |
+ mRequester = null; |
+ } |
+ } |
+ |
+ /** |
* @return Whether the Autofill feature is enabled. |
*/ |
public static boolean isAutofillEnabled() { |
@@ -806,6 +860,11 @@ 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 void nativeStartAddressNormalizationTask( |
+ long nativePersonalDataManagerAndroid, String guid, String regionCode); |
+ private native void nativeCancelAddressNormalizationTask(long nativePersonalDataManagerAndroid); |
private static native boolean nativeIsAutofillEnabled(); |
private static native void nativeSetAutofillEnabled(boolean enable); |
private static native boolean nativeIsAutofillManaged(); |