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 2428e99e1118b820bb7f499142e22abd6d26a6f6..327f696a3504be28adebc2ff4a262563874dc6f2 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 |
@@ -62,6 +62,19 @@ public class PersonalDataManager { |
} |
/** |
+ * Callback for subKeys request. |
+ */ |
+ public interface GetSubKeysRequestDelegate { |
+ /** |
+ * Called when the sub-keys are received sucessfully. |
+ * |
+ * @param subKeys The subKeys. |
+ */ |
+ @CalledByNative("GetSubKeysRequestDelegate") |
+ void onSubKeysReceived(String[] subKeys); |
+ } |
+ |
+ /** |
* Callback for normalized addresses. |
*/ |
public interface NormalizedAddressRequestDelegate { |
@@ -520,7 +533,8 @@ public class PersonalDataManager { |
return sManager; |
} |
- private static int sNormalizationTimeoutSeconds = 5; |
+ private static int sNormalizationTimeoutSeconds = 5000; |
sebsg
2017/03/21 15:29:51
I use this in my address normalizer as seconds, so
Parastoo
2017/03/21 20:05:51
Done.
|
+ private static boolean sTestingMode = false; |
private final long mPersonalDataManagerAndroid; |
private final List<PersonalDataManagerObserver> mDataObservers = |
@@ -805,16 +819,36 @@ public class PersonalDataManager { |
* |
* @param regionCode The code of the region for which to load the rules. |
*/ |
- public void loadRulesForRegion(String regionCode) { |
+ public void loadRulesForAddressNormalization(String regionCode) { |
+ ThreadUtils.assertOnUiThread(); |
+ nativeLoadRulesForAddressNormalization(mPersonalDataManagerAndroid, regionCode); |
+ } |
+ |
+ /** |
+ * Starts loading the sub-key request rules for the specified {@code regionCode}. |
+ * |
+ * @param regionCode The code of the region for which to load the rules. |
+ */ |
+ public void loadRulesForSubKeys(String regionCode) { |
ThreadUtils.assertOnUiThread(); |
- nativeLoadRulesForRegion(mPersonalDataManagerAndroid, regionCode); |
+ nativeLoadRulesForSubKeys(mPersonalDataManagerAndroid, regionCode); |
} |
/** |
- * Normalizes the address of the {@code profile} if the rules associated with the |
- * {@code regionCode} are done loading. Otherwise sets up the callback to start normalizing the |
- * address when the rules are loaded. The normalized profile will be sent to the |
- * {@code delegate}. If the profile is not normalized in the specified |
+ * Starts loading the sub keys for the specified {@code regionCode}. |
+ * |
+ * @param regionCode The code of the region for which to load the sub keys. |
+ */ |
+ public void getRegionSubKeys(String regionCode, GetSubKeysRequestDelegate delegate) { |
+ ThreadUtils.assertOnUiThread(); |
+ nativeStartGettingRegionSubKeys(mPersonalDataManagerAndroid, regionCode, delegate); |
+ } |
+ |
+ /** |
+ * Normalizes the address of the profile associated with the {@code guid} if the rules |
+ * associated with the {@code regionCode} are done loading. Otherwise sets up the callback to |
+ * start normalizing the address when the rules are loaded. The normalized profile will be sent |
+ * to the {@code delegate}. If the profile is not normalized in the specified |
* {@code sNormalizationTimeoutSeconds}, the {@code delegate} will be notified. |
* |
* @param profile The profile to normalize. |
@@ -828,6 +862,12 @@ public class PersonalDataManager { |
sNormalizationTimeoutSeconds, delegate); |
} |
+ /** Cancels the pending sub keys request. */ |
+ public void cancelPendingGetSubKeys() { |
+ ThreadUtils.assertOnUiThread(); |
+ nativeCancelPendingGetSubKeys(mPersonalDataManagerAndroid); |
+ } |
+ |
/** |
* Checks whether the Autofill PersonalDataManager has profiles. |
* |
@@ -888,6 +928,19 @@ public class PersonalDataManager { |
sNormalizationTimeoutSeconds = timeout; |
} |
+ public static int getTimeoutMS() { |
+ return sNormalizationTimeoutSeconds; |
+ } |
+ |
+ public static void setToTestingMode() { |
+ sTestingMode = true; |
+ } |
+ |
+ public static boolean isOnTestingMode() { |
+ return sTestingMode; |
+ } |
+ |
+ |
private native long nativeInit(); |
private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndroid); |
private native String[] nativeGetProfileGUIDsForSettings(long nativePersonalDataManagerAndroid); |
@@ -947,11 +1000,16 @@ public class PersonalDataManager { |
long nativePersonalDataManagerAndroid, String guid); |
private native void nativeGetFullCardForPaymentRequest(long nativePersonalDataManagerAndroid, |
WebContents webContents, CreditCard card, FullCardRequestDelegate delegate); |
- private native void nativeLoadRulesForRegion( |
+ private native void nativeLoadRulesForAddressNormalization( |
+ long nativePersonalDataManagerAndroid, String regionCode); |
+ private native void nativeLoadRulesForSubKeys( |
long nativePersonalDataManagerAndroid, String regionCode); |
private native void nativeStartAddressNormalization(long nativePersonalDataManagerAndroid, |
AutofillProfile profile, String regionCode, int timeoutSeconds, |
NormalizedAddressRequestDelegate delegate); |
+ private native void nativeStartGettingRegionSubKeys( |
+ long nativePersonalDataManagerAndroid, String regionCode, |
+ GetSubKeysRequestDelegate delegate); |
private static native boolean nativeHasProfiles(long nativePersonalDataManagerAndroid); |
private static native boolean nativeHasCreditCards(long nativePersonalDataManagerAndroid); |
private static native boolean nativeIsAutofillEnabled(); |
@@ -960,4 +1018,5 @@ public class PersonalDataManager { |
private static native boolean nativeIsPaymentsIntegrationEnabled(); |
private static native void nativeSetPaymentsIntegrationEnabled(boolean enable); |
private static native String nativeToCountryCode(String countryName); |
+ private static native void nativeCancelPendingGetSubKeys(long nativePersonalDataManagerAndroid); |
} |