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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java

Issue 2680143002: Use dropdown list for admin areas in pr form. (Closed)
Patch Set: The one where I fixed a line (an error from sync!) Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void onFullCardDetails(CreditCard card, String cvc); 55 void onFullCardDetails(CreditCard card, String cvc);
56 56
57 /** 57 /**
58 * Called when user did not provide full card details. 58 * Called when user did not provide full card details.
59 */ 59 */
60 @CalledByNative("FullCardRequestDelegate") 60 @CalledByNative("FullCardRequestDelegate")
61 void onFullCardError(); 61 void onFullCardError();
62 } 62 }
63 63
64 /** 64 /**
65 * Callback for subKeys request.
66 */
67 public interface GetSubKeysRequestDelegate {
68 /**
69 * Called when the sub-keys are received sucessfully.
70 *
71 * @param subKeys The subKeys.
72 */
73 @CalledByNative("GetSubKeysRequestDelegate")
74 void onSubKeysReceived(String[] subKeys);
75 }
76
77 /**
65 * Callback for normalized addresses. 78 * Callback for normalized addresses.
66 */ 79 */
67 public interface NormalizedAddressRequestDelegate { 80 public interface NormalizedAddressRequestDelegate {
68 /** 81 /**
69 * Called when the address has been sucessfully normalized. 82 * Called when the address has been sucessfully normalized.
70 * 83 *
71 * @param profile The profile with the normalized address. 84 * @param profile The profile with the normalized address.
72 */ 85 */
73 @CalledByNative("NormalizedAddressRequestDelegate") 86 @CalledByNative("NormalizedAddressRequestDelegate")
74 void onAddressNormalized(AutofillProfile profile); 87 void onAddressNormalized(AutofillProfile profile);
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 527
515 public static PersonalDataManager getInstance() { 528 public static PersonalDataManager getInstance() {
516 ThreadUtils.assertOnUiThread(); 529 ThreadUtils.assertOnUiThread();
517 if (sManager == null) { 530 if (sManager == null) {
518 sManager = new PersonalDataManager(); 531 sManager = new PersonalDataManager();
519 } 532 }
520 return sManager; 533 return sManager;
521 } 534 }
522 535
523 private static int sNormalizationTimeoutSeconds = 5; 536 private static int sNormalizationTimeoutSeconds = 5;
537 private static boolean sTestingMode = false;
524 538
525 private final long mPersonalDataManagerAndroid; 539 private final long mPersonalDataManagerAndroid;
526 private final List<PersonalDataManagerObserver> mDataObservers = 540 private final List<PersonalDataManagerObserver> mDataObservers =
527 new ArrayList<PersonalDataManagerObserver>(); 541 new ArrayList<PersonalDataManagerObserver>();
528 542
529 private PersonalDataManager() { 543 private PersonalDataManager() {
530 // Note that this technically leaks the native object, however, Personal DataManager 544 // Note that this technically leaks the native object, however, Personal DataManager
531 // is a singleton that lives forever and there's no clean shutdown of Ch rome on Android 545 // is a singleton that lives forever and there's no clean shutdown of Ch rome on Android
532 mPersonalDataManagerAndroid = nativeInit(); 546 mPersonalDataManagerAndroid = nativeInit();
533 } 547 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 long getCurrentDateForTesting() { 812 long getCurrentDateForTesting() {
799 ThreadUtils.assertOnUiThread(); 813 ThreadUtils.assertOnUiThread();
800 return nativeGetCurrentDateForTesting(mPersonalDataManagerAndroid); 814 return nativeGetCurrentDateForTesting(mPersonalDataManagerAndroid);
801 } 815 }
802 816
803 /** 817 /**
804 * Starts loading the address validation rules for the specified {@code regi onCode}. 818 * Starts loading the address validation rules for the specified {@code regi onCode}.
805 * 819 *
806 * @param regionCode The code of the region for which to load the rules. 820 * @param regionCode The code of the region for which to load the rules.
807 */ 821 */
808 public void loadRulesForRegion(String regionCode) { 822 public void loadRulesForAddressNormalization(String regionCode) {
809 ThreadUtils.assertOnUiThread(); 823 ThreadUtils.assertOnUiThread();
810 nativeLoadRulesForRegion(mPersonalDataManagerAndroid, regionCode); 824 nativeLoadRulesForAddressNormalization(mPersonalDataManagerAndroid, regi onCode);
811 } 825 }
812 826
813 /** 827 /**
814 * Normalizes the address of the {@code profile} if the rules associated wit h the 828 * Starts loading the sub-key request rules for the specified {@code regionC ode}.
815 * {@code regionCode} are done loading. Otherwise sets up the callback to st art normalizing the 829 *
816 * address when the rules are loaded. The normalized profile will be sent to the 830 * @param regionCode The code of the region for which to load the rules.
817 * {@code delegate}. If the profile is not normalized in the specified 831 */
832 public void loadRulesForSubKeys(String regionCode) {
833 ThreadUtils.assertOnUiThread();
834 nativeLoadRulesForSubKeys(mPersonalDataManagerAndroid, regionCode);
835 }
836
837 /**
838 * Starts loading the sub keys for the specified {@code regionCode}.
839 *
840 * @param regionCode The code of the region for which to load the sub keys.
841 */
842 public void getRegionSubKeys(String regionCode, GetSubKeysRequestDelegate de legate) {
843 ThreadUtils.assertOnUiThread();
844 nativeStartGettingRegionSubKeys(mPersonalDataManagerAndroid, regionCode, delegate);
845 }
846
847 /**
848 * Normalizes the address of the profile associated with the {@code guid} if the rules
849 * associated with the {@code regionCode} are done loading. Otherwise sets u p the callback to
850 * start normalizing the address when the rules are loaded. The normalized p rofile will be sent
851 * to the {@code delegate}. If the profile is not normalized in the specifie d
818 * {@code sNormalizationTimeoutSeconds}, the {@code delegate} will be notifi ed. 852 * {@code sNormalizationTimeoutSeconds}, the {@code delegate} will be notifi ed.
819 * 853 *
820 * @param profile The profile to normalize. 854 * @param profile The profile to normalize.
821 * @param regionCode The region code indicating which rules to use for norma lization. 855 * @param regionCode The region code indicating which rules to use for norma lization.
822 * @param delegate The object requesting the normalization. 856 * @param delegate The object requesting the normalization.
823 */ 857 */
824 public void normalizeAddress( 858 public void normalizeAddress(
825 AutofillProfile profile, String regionCode, NormalizedAddressRequest Delegate delegate) { 859 AutofillProfile profile, String regionCode, NormalizedAddressRequest Delegate delegate) {
826 ThreadUtils.assertOnUiThread(); 860 ThreadUtils.assertOnUiThread();
827 nativeStartAddressNormalization(mPersonalDataManagerAndroid, profile, re gionCode, 861 nativeStartAddressNormalization(mPersonalDataManagerAndroid, profile, re gionCode,
828 sNormalizationTimeoutSeconds, delegate); 862 sNormalizationTimeoutSeconds, delegate);
829 } 863 }
830 864
865 /** Cancels the pending sub keys request. */
866 public void cancelPendingGetSubKeys() {
867 ThreadUtils.assertOnUiThread();
868 nativeCancelPendingGetSubKeys(mPersonalDataManagerAndroid);
869 }
870
831 /** 871 /**
832 * Checks whether the Autofill PersonalDataManager has profiles. 872 * Checks whether the Autofill PersonalDataManager has profiles.
833 * 873 *
834 * @return True If there are profiles. 874 * @return True If there are profiles.
835 */ 875 */
836 public boolean hasProfiles() { 876 public boolean hasProfiles() {
837 return nativeHasProfiles(mPersonalDataManagerAndroid); 877 return nativeHasProfiles(mPersonalDataManagerAndroid);
838 } 878 }
839 879
840 /** 880 /**
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 */ 921 */
882 public static void setPaymentsIntegrationEnabled(boolean enable) { 922 public static void setPaymentsIntegrationEnabled(boolean enable) {
883 nativeSetPaymentsIntegrationEnabled(enable); 923 nativeSetPaymentsIntegrationEnabled(enable);
884 } 924 }
885 925
886 @VisibleForTesting 926 @VisibleForTesting
887 public static void setNormalizationTimeoutForTesting(int timeout) { 927 public static void setNormalizationTimeoutForTesting(int timeout) {
888 sNormalizationTimeoutSeconds = timeout; 928 sNormalizationTimeoutSeconds = timeout;
889 } 929 }
890 930
931 public static int getTimeoutMS() {
Mathieu 2017/03/24 17:24:32 Would call this getRequestTimeoutMs
Parastoo 2017/03/24 22:42:23 Done.
932 return sNormalizationTimeoutSeconds * 1000;
933 }
934
935 public static void setToTestingMode() {
936 sTestingMode = true;
937 }
938
939 public static boolean isOnTestingMode() {
940 return sTestingMode;
941 }
942
Mathieu 2017/03/24 17:24:32 extra line here
Parastoo 2017/03/24 22:42:23 Done.
943
891 private native long nativeInit(); 944 private native long nativeInit();
892 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr oid); 945 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr oid);
893 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal DataManagerAndroid); 946 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal DataManagerAndroid);
894 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa taManagerAndroid); 947 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa taManagerAndroid);
895 private native String[] nativeGetProfileLabelsForSettings( 948 private native String[] nativeGetProfileLabelsForSettings(
896 long nativePersonalDataManagerAndroid); 949 long nativePersonalDataManagerAndroid);
897 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD ataManagerAndroid, 950 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD ataManagerAndroid,
898 boolean includeNameInLabel, boolean includeOrganizationInLabel, 951 boolean includeNameInLabel, boolean includeOrganizationInLabel,
899 boolean includeCountryInLabel); 952 boolean includeCountryInLabel);
900 private native AutofillProfile nativeGetProfileByGUID(long nativePersonalDat aManagerAndroid, 953 private native AutofillProfile nativeGetProfileByGUID(long nativePersonalDat aManagerAndroid,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 long nativePersonalDataManagerAndroid, String guid, int count, long date); 993 long nativePersonalDataManagerAndroid, String guid, int count, long date);
941 private native int nativeGetCreditCardUseCountForTesting(long nativePersonal DataManagerAndroid, 994 private native int nativeGetCreditCardUseCountForTesting(long nativePersonal DataManagerAndroid,
942 String guid); 995 String guid);
943 private native long nativeGetCreditCardUseDateForTesting(long nativePersonal DataManagerAndroid, 996 private native long nativeGetCreditCardUseDateForTesting(long nativePersonal DataManagerAndroid,
944 String guid); 997 String guid);
945 private native long nativeGetCurrentDateForTesting(long nativePersonalDataMa nagerAndroid); 998 private native long nativeGetCurrentDateForTesting(long nativePersonalDataMa nagerAndroid);
946 private native void nativeClearUnmaskedCache( 999 private native void nativeClearUnmaskedCache(
947 long nativePersonalDataManagerAndroid, String guid); 1000 long nativePersonalDataManagerAndroid, String guid);
948 private native void nativeGetFullCardForPaymentRequest(long nativePersonalDa taManagerAndroid, 1001 private native void nativeGetFullCardForPaymentRequest(long nativePersonalDa taManagerAndroid,
949 WebContents webContents, CreditCard card, FullCardRequestDelegate de legate); 1002 WebContents webContents, CreditCard card, FullCardRequestDelegate de legate);
950 private native void nativeLoadRulesForRegion( 1003 private native void nativeLoadRulesForAddressNormalization(
1004 long nativePersonalDataManagerAndroid, String regionCode);
1005 private native void nativeLoadRulesForSubKeys(
951 long nativePersonalDataManagerAndroid, String regionCode); 1006 long nativePersonalDataManagerAndroid, String regionCode);
952 private native void nativeStartAddressNormalization(long nativePersonalDataM anagerAndroid, 1007 private native void nativeStartAddressNormalization(long nativePersonalDataM anagerAndroid,
953 AutofillProfile profile, String regionCode, int timeoutSeconds, 1008 AutofillProfile profile, String regionCode, int timeoutSeconds,
954 NormalizedAddressRequestDelegate delegate); 1009 NormalizedAddressRequestDelegate delegate);
1010 private native void nativeStartGettingRegionSubKeys(
1011 long nativePersonalDataManagerAndroid, String regionCode,
1012 GetSubKeysRequestDelegate delegate);
955 private static native boolean nativeHasProfiles(long nativePersonalDataManag erAndroid); 1013 private static native boolean nativeHasProfiles(long nativePersonalDataManag erAndroid);
956 private static native boolean nativeHasCreditCards(long nativePersonalDataMa nagerAndroid); 1014 private static native boolean nativeHasCreditCards(long nativePersonalDataMa nagerAndroid);
957 private static native boolean nativeIsAutofillEnabled(); 1015 private static native boolean nativeIsAutofillEnabled();
958 private static native void nativeSetAutofillEnabled(boolean enable); 1016 private static native void nativeSetAutofillEnabled(boolean enable);
959 private static native boolean nativeIsAutofillManaged(); 1017 private static native boolean nativeIsAutofillManaged();
960 private static native boolean nativeIsPaymentsIntegrationEnabled(); 1018 private static native boolean nativeIsPaymentsIntegrationEnabled();
961 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl e); 1019 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl e);
962 private static native String nativeToCountryCode(String countryName); 1020 private static native String nativeToCountryCode(String countryName);
1021 private static native void nativeCancelPendingGetSubKeys(long nativePersonal DataManagerAndroid);
963 } 1022 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698