OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.autofill; | 5 package org.chromium.chrome.browser.autofill; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 | 8 |
9 import org.chromium.base.ThreadUtils; | 9 import org.chromium.base.ThreadUtils; |
10 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 */ | 61 */ |
62 @CalledByNative("FullCardRequestDelegate") | 62 @CalledByNative("FullCardRequestDelegate") |
63 void onFullCardError(); | 63 void onFullCardError(); |
64 } | 64 } |
65 | 65 |
66 /** | 66 /** |
67 * Callback for subKeys request. | 67 * Callback for subKeys request. |
68 */ | 68 */ |
69 public interface GetSubKeysRequestDelegate { | 69 public interface GetSubKeysRequestDelegate { |
70 /** | 70 /** |
71 * Called when the sub-keys are received sucessfully. | 71 * Called when the subkeys are received sucessfully. |
72 * Here the sub-keys are admin areas. | 72 * Here the subkeys are admin areas. |
73 * | 73 * |
74 * @param subKeys The subKeys. | 74 * @param subKeys The subKeys. |
75 */ | 75 */ |
76 @CalledByNative("GetSubKeysRequestDelegate") | 76 @CalledByNative("GetSubKeysRequestDelegate") |
77 void onSubKeysReceived(String[] subKeys); | 77 void onSubKeysReceived(String[] subKeys); |
78 } | 78 } |
79 | 79 |
80 /** | 80 /** |
81 * Callback for normalized addresses. | 81 * Callback for normalized addresses. |
82 */ | 82 */ |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 // Suppress FindBugs warning, since |sManager| is only used on the UI thread
. | 531 // Suppress FindBugs warning, since |sManager| is only used on the UI thread
. |
532 @SuppressFBWarnings("LI_LAZY_INIT_STATIC") | 532 @SuppressFBWarnings("LI_LAZY_INIT_STATIC") |
533 public static PersonalDataManager getInstance() { | 533 public static PersonalDataManager getInstance() { |
534 ThreadUtils.assertOnUiThread(); | 534 ThreadUtils.assertOnUiThread(); |
535 if (sManager == null) { | 535 if (sManager == null) { |
536 sManager = new PersonalDataManager(); | 536 sManager = new PersonalDataManager(); |
537 } | 537 } |
538 return sManager; | 538 return sManager; |
539 } | 539 } |
540 | 540 |
541 private static int sNormalizationTimeoutSeconds = 5; | 541 private static int sRequestTimeoutSeconds = 5; |
542 | 542 |
543 private final long mPersonalDataManagerAndroid; | 543 private final long mPersonalDataManagerAndroid; |
544 private final List<PersonalDataManagerObserver> mDataObservers = | 544 private final List<PersonalDataManagerObserver> mDataObservers = |
545 new ArrayList<PersonalDataManagerObserver>(); | 545 new ArrayList<PersonalDataManagerObserver>(); |
546 | 546 |
547 private PersonalDataManager() { | 547 private PersonalDataManager() { |
548 // Note that this technically leaks the native object, however, Personal
DataManager | 548 // Note that this technically leaks the native object, however, Personal
DataManager |
549 // is a singleton that lives forever and there's no clean shutdown of Ch
rome on Android | 549 // is a singleton that lives forever and there's no clean shutdown of Ch
rome on Android |
550 mPersonalDataManagerAndroid = nativeInit(); | 550 mPersonalDataManagerAndroid = nativeInit(); |
551 } | 551 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 * Starts loading the sub-key request rules for the specified {@code regionC
ode}. | 832 * Starts loading the sub-key request rules for the specified {@code regionC
ode}. |
833 * | 833 * |
834 * @param regionCode The code of the region for which to load the rules. | 834 * @param regionCode The code of the region for which to load the rules. |
835 */ | 835 */ |
836 public void loadRulesForSubKeys(String regionCode) { | 836 public void loadRulesForSubKeys(String regionCode) { |
837 ThreadUtils.assertOnUiThread(); | 837 ThreadUtils.assertOnUiThread(); |
838 nativeLoadRulesForSubKeys(mPersonalDataManagerAndroid, regionCode); | 838 nativeLoadRulesForSubKeys(mPersonalDataManagerAndroid, regionCode); |
839 } | 839 } |
840 | 840 |
841 /** | 841 /** |
842 * Starts loading the sub keys for the specified {@code regionCode}. | 842 * Starts requesting the subkeys for the specified {@code regionCode}, if th
e rules |
| 843 * associated with the {@code regionCode} are done loading. Otherwise sets u
p the callback to |
| 844 * start loading the subkeys when the rules are loaded. The received subkeys
will be sent |
| 845 * to the {@code delegate}. If the subkeys are not received in the specified |
| 846 * {@code sRequestTimeoutSeconds}, the {@code delegate} will be notified. |
843 * | 847 * |
844 * @param regionCode The code of the region for which to load the sub keys. | 848 * @param regionCode The code of the region for which to load the subkeys. |
| 849 * @param delegate The object requesting the subkeys. |
845 */ | 850 */ |
846 public void getRegionSubKeys(String regionCode, GetSubKeysRequestDelegate de
legate) { | 851 public void getRegionSubKeys(String regionCode, GetSubKeysRequestDelegate de
legate) { |
847 ThreadUtils.assertOnUiThread(); | 852 ThreadUtils.assertOnUiThread(); |
848 nativeStartRegionSubKeysRequest(mPersonalDataManagerAndroid, regionCode,
delegate); | 853 nativeStartRegionSubKeysRequest( |
| 854 mPersonalDataManagerAndroid, regionCode, sRequestTimeoutSeconds,
delegate); |
849 } | 855 } |
850 | 856 |
851 /** Cancels the pending sub keys request. */ | 857 /** Cancels the pending subkeys request. */ |
852 public void cancelPendingGetSubKeys() { | 858 public void cancelPendingGetSubKeys() { |
853 ThreadUtils.assertOnUiThread(); | 859 ThreadUtils.assertOnUiThread(); |
854 nativeCancelPendingGetSubKeys(mPersonalDataManagerAndroid); | 860 nativeCancelPendingGetSubKeys(mPersonalDataManagerAndroid); |
855 } | 861 } |
856 | 862 |
857 /** | 863 /** |
858 * Normalizes the address of the profile associated with the {@code guid} if
the rules | 864 * Normalizes the address of the profile associated with the {@code guid} if
the rules |
859 * associated with the {@code regionCode} are done loading. Otherwise sets u
p the callback to | 865 * associated with the {@code regionCode} are done loading. Otherwise sets u
p the callback to |
860 * start normalizing the address when the rules are loaded. The normalized p
rofile will be sent | 866 * start normalizing the address when the rules are loaded. The normalized p
rofile will be sent |
861 * to the {@code delegate}. If the profile is not normalized in the specifie
d | 867 * to the {@code delegate}. If the profile is not normalized in the specifie
d |
862 * {@code sNormalizationTimeoutSeconds}, the {@code delegate} will be notifi
ed. | 868 * {@code sRequestTimeoutSeconds}, the {@code delegate} will be notified. |
863 * | 869 * |
864 * @param profile The profile to normalize. | 870 * @param profile The profile to normalize. |
865 * @param regionCode The region code indicating which rules to use for norma
lization. | 871 * @param regionCode The region code indicating which rules to use for norma
lization. |
866 * @param delegate The object requesting the normalization. | 872 * @param delegate The object requesting the normalization. |
867 */ | 873 */ |
868 public void normalizeAddress( | 874 public void normalizeAddress( |
869 AutofillProfile profile, String regionCode, NormalizedAddressRequest
Delegate delegate) { | 875 AutofillProfile profile, String regionCode, NormalizedAddressRequest
Delegate delegate) { |
870 ThreadUtils.assertOnUiThread(); | 876 ThreadUtils.assertOnUiThread(); |
871 nativeStartAddressNormalization(mPersonalDataManagerAndroid, profile, re
gionCode, | 877 nativeStartAddressNormalization( |
872 sNormalizationTimeoutSeconds, delegate); | 878 mPersonalDataManagerAndroid, profile, regionCode, sRequestTimeou
tSeconds, delegate); |
873 } | 879 } |
874 | 880 |
875 /** | 881 /** |
876 * Checks whether the Autofill PersonalDataManager has profiles. | 882 * Checks whether the Autofill PersonalDataManager has profiles. |
877 * | 883 * |
878 * @return True If there are profiles. | 884 * @return True If there are profiles. |
879 */ | 885 */ |
880 public boolean hasProfiles() { | 886 public boolean hasProfiles() { |
881 return nativeHasProfiles(mPersonalDataManagerAndroid); | 887 return nativeHasProfiles(mPersonalDataManagerAndroid); |
882 } | 888 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 | 927 |
922 /** | 928 /** |
923 * Enables or disables the Payments integration. | 929 * Enables or disables the Payments integration. |
924 * @param enable True to enable Payments data import. | 930 * @param enable True to enable Payments data import. |
925 */ | 931 */ |
926 public static void setPaymentsIntegrationEnabled(boolean enable) { | 932 public static void setPaymentsIntegrationEnabled(boolean enable) { |
927 nativeSetPaymentsIntegrationEnabled(enable); | 933 nativeSetPaymentsIntegrationEnabled(enable); |
928 } | 934 } |
929 | 935 |
930 @VisibleForTesting | 936 @VisibleForTesting |
931 public static void setNormalizationTimeoutForTesting(int timeout) { | 937 public static void setRequestTimeoutForTesting(int timeout) { |
932 sNormalizationTimeoutSeconds = timeout; | 938 sRequestTimeoutSeconds = timeout; |
933 } | 939 } |
934 | 940 |
935 /** | 941 /** |
936 * @return The sub-key request timeout in milliseconds. | 942 * @return The sub-key request timeout in milliseconds. |
937 */ | 943 */ |
938 public static long getRequestTimeoutMS() { | 944 public static long getRequestTimeoutMS() { |
939 return TimeUnit.SECONDS.toMillis(sNormalizationTimeoutSeconds); | 945 return TimeUnit.SECONDS.toMillis(sRequestTimeoutSeconds); |
940 } | 946 } |
941 | 947 |
942 private native long nativeInit(); | 948 private native long nativeInit(); |
943 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr
oid); | 949 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr
oid); |
944 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal
DataManagerAndroid); | 950 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal
DataManagerAndroid); |
945 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa
taManagerAndroid); | 951 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa
taManagerAndroid); |
946 private native String[] nativeGetProfileLabelsForSettings( | 952 private native String[] nativeGetProfileLabelsForSettings( |
947 long nativePersonalDataManagerAndroid); | 953 long nativePersonalDataManagerAndroid); |
948 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD
ataManagerAndroid, | 954 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD
ataManagerAndroid, |
949 boolean includeNameInLabel, boolean includeOrganizationInLabel, | 955 boolean includeNameInLabel, boolean includeOrganizationInLabel, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 private native void nativeGetFullCardForPaymentRequest(long nativePersonalDa
taManagerAndroid, | 1005 private native void nativeGetFullCardForPaymentRequest(long nativePersonalDa
taManagerAndroid, |
1000 WebContents webContents, CreditCard card, FullCardRequestDelegate de
legate); | 1006 WebContents webContents, CreditCard card, FullCardRequestDelegate de
legate); |
1001 private native void nativeLoadRulesForAddressNormalization( | 1007 private native void nativeLoadRulesForAddressNormalization( |
1002 long nativePersonalDataManagerAndroid, String regionCode); | 1008 long nativePersonalDataManagerAndroid, String regionCode); |
1003 private native void nativeLoadRulesForSubKeys( | 1009 private native void nativeLoadRulesForSubKeys( |
1004 long nativePersonalDataManagerAndroid, String regionCode); | 1010 long nativePersonalDataManagerAndroid, String regionCode); |
1005 private native void nativeStartAddressNormalization(long nativePersonalDataM
anagerAndroid, | 1011 private native void nativeStartAddressNormalization(long nativePersonalDataM
anagerAndroid, |
1006 AutofillProfile profile, String regionCode, int timeoutSeconds, | 1012 AutofillProfile profile, String regionCode, int timeoutSeconds, |
1007 NormalizedAddressRequestDelegate delegate); | 1013 NormalizedAddressRequestDelegate delegate); |
1008 private native void nativeStartRegionSubKeysRequest(long nativePersonalDataM
anagerAndroid, | 1014 private native void nativeStartRegionSubKeysRequest(long nativePersonalDataM
anagerAndroid, |
1009 String regionCode, GetSubKeysRequestDelegate delegate); | 1015 String regionCode, int timeoutSeconds, GetSubKeysRequestDelegate del
egate); |
1010 private static native boolean nativeHasProfiles(long nativePersonalDataManag
erAndroid); | 1016 private static native boolean nativeHasProfiles(long nativePersonalDataManag
erAndroid); |
1011 private static native boolean nativeHasCreditCards(long nativePersonalDataMa
nagerAndroid); | 1017 private static native boolean nativeHasCreditCards(long nativePersonalDataMa
nagerAndroid); |
1012 private static native boolean nativeIsAutofillEnabled(); | 1018 private static native boolean nativeIsAutofillEnabled(); |
1013 private static native void nativeSetAutofillEnabled(boolean enable); | 1019 private static native void nativeSetAutofillEnabled(boolean enable); |
1014 private static native boolean nativeIsAutofillManaged(); | 1020 private static native boolean nativeIsAutofillManaged(); |
1015 private static native boolean nativeIsPaymentsIntegrationEnabled(); | 1021 private static native boolean nativeIsPaymentsIntegrationEnabled(); |
1016 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl
e); | 1022 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl
e); |
1017 private static native String nativeToCountryCode(String countryName); | 1023 private static native String nativeToCountryCode(String countryName); |
1018 private static native void nativeCancelPendingGetSubKeys(long nativePersonal
DataManagerAndroid); | 1024 private static native void nativeCancelPendingGetSubKeys(long nativePersonal
DataManagerAndroid); |
1019 } | 1025 } |
OLD | NEW |