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

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

Issue 2708933003: [Payments] Add timeout to the address_normalizer. (Closed)
Patch Set: Nits Created 3 years, 10 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 private static PersonalDataManager sManager; 513 private static PersonalDataManager sManager;
514 514
515 public static PersonalDataManager getInstance() { 515 public static PersonalDataManager getInstance() {
516 ThreadUtils.assertOnUiThread(); 516 ThreadUtils.assertOnUiThread();
517 if (sManager == null) { 517 if (sManager == null) {
518 sManager = new PersonalDataManager(); 518 sManager = new PersonalDataManager();
519 } 519 }
520 return sManager; 520 return sManager;
521 } 521 }
522 522
523 private static int sNormalizationTimeoutMs = 5000; 523 private static int sNormalizationTimeoutSeconds = 5;
524 524
525 private final long mPersonalDataManagerAndroid; 525 private final long mPersonalDataManagerAndroid;
526 private final List<PersonalDataManagerObserver> mDataObservers = 526 private final List<PersonalDataManagerObserver> mDataObservers =
527 new ArrayList<PersonalDataManagerObserver>(); 527 new ArrayList<PersonalDataManagerObserver>();
528 528
529 private PersonalDataManager() { 529 private PersonalDataManager() {
530 // Note that this technically leaks the native object, however, Personal DataManager 530 // 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 531 // is a singleton that lives forever and there's no clean shutdown of Ch rome on Android
532 mPersonalDataManagerAndroid = nativeInit(); 532 mPersonalDataManagerAndroid = nativeInit();
533 } 533 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 */ 807 */
808 public void loadRulesForRegion(String regionCode) { 808 public void loadRulesForRegion(String regionCode) {
809 ThreadUtils.assertOnUiThread(); 809 ThreadUtils.assertOnUiThread();
810 nativeLoadRulesForRegion(mPersonalDataManagerAndroid, regionCode); 810 nativeLoadRulesForRegion(mPersonalDataManagerAndroid, regionCode);
811 } 811 }
812 812
813 /** 813 /**
814 * Normalizes the address of the profile associated with the {@code guid} if the rules 814 * Normalizes the address of the profile associated with the {@code guid} if the rules
815 * associated with the {@code regionCode} are done loading. Otherwise sets u p the callback to 815 * associated with the {@code regionCode} are done loading. Otherwise sets u p the callback to
816 * start normalizing the address when the rules are loaded. The normalized p rofile will be sent 816 * start normalizing the address when the rules are loaded. The normalized p rofile will be sent
817 * to the {@code delegate}. 817 * to the {@code delegate}. If the profile is not normalized in the specifie d
818 * {@code sNormalizationTimeoutSeconds}, the {@code delegate} will be notifi ed.
818 * 819 *
819 * @param guid The GUID of the profile to normalize. 820 * @param guid The GUID of the profile to normalize.
820 * @param regionCode The region code indicating which rules to use for norma lization. 821 * @param regionCode The region code indicating which rules to use for norma lization.
821 * @param delegate The object requesting the normalization. 822 * @param delegate The object requesting the normalization.
822 */ 823 */
823 public void normalizeAddress( 824 public void normalizeAddress(
824 String guid, String regionCode, NormalizedAddressRequestDelegate del egate) { 825 String guid, String regionCode, NormalizedAddressRequestDelegate del egate) {
825 ThreadUtils.assertOnUiThread(); 826 ThreadUtils.assertOnUiThread();
826 nativeStartAddressNormalization(mPersonalDataManagerAndroid, guid, regio nCode, delegate); 827 nativeStartAddressNormalization(mPersonalDataManagerAndroid, guid, regio nCode,
828 sNormalizationTimeoutSeconds, delegate);
827 } 829 }
828 830
829 /** 831 /**
830 * Checks whether the Autofill PersonalDataManager has profiles. 832 * Checks whether the Autofill PersonalDataManager has profiles.
831 * 833 *
832 * @return True If there are profiles. 834 * @return True If there are profiles.
833 */ 835 */
834 public boolean hasProfiles() { 836 public boolean hasProfiles() {
835 return nativeHasProfiles(mPersonalDataManagerAndroid); 837 return nativeHasProfiles(mPersonalDataManagerAndroid);
836 } 838 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 } 876 }
875 877
876 /** 878 /**
877 * Enables or disables the Payments integration. 879 * Enables or disables the Payments integration.
878 * @param enable True to enable Payments data import. 880 * @param enable True to enable Payments data import.
879 */ 881 */
880 public static void setPaymentsIntegrationEnabled(boolean enable) { 882 public static void setPaymentsIntegrationEnabled(boolean enable) {
881 nativeSetPaymentsIntegrationEnabled(enable); 883 nativeSetPaymentsIntegrationEnabled(enable);
882 } 884 }
883 885
884 /**
885 * @return The timeout value for normalization.
886 */
887 public static int getNormalizationTimeoutMS() {
888 return sNormalizationTimeoutMs;
889 }
890
891 @VisibleForTesting 886 @VisibleForTesting
892 public static void setNormalizationTimeoutForTesting(int timeout) { 887 public static void setNormalizationTimeoutForTesting(int timeout) {
893 sNormalizationTimeoutMs = timeout; 888 sNormalizationTimeoutSeconds = timeout;
894 } 889 }
895 890
896 private native long nativeInit(); 891 private native long nativeInit();
897 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr oid); 892 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr oid);
898 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal DataManagerAndroid); 893 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal DataManagerAndroid);
899 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa taManagerAndroid); 894 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa taManagerAndroid);
900 private native String[] nativeGetProfileLabelsForSettings( 895 private native String[] nativeGetProfileLabelsForSettings(
901 long nativePersonalDataManagerAndroid); 896 long nativePersonalDataManagerAndroid);
902 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD ataManagerAndroid, 897 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD ataManagerAndroid,
903 boolean includeNameInLabel, boolean includeOrganizationInLabel, 898 boolean includeNameInLabel, boolean includeOrganizationInLabel,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 private native long nativeGetCreditCardUseDateForTesting(long nativePersonal DataManagerAndroid, 943 private native long nativeGetCreditCardUseDateForTesting(long nativePersonal DataManagerAndroid,
949 String guid); 944 String guid);
950 private native long nativeGetCurrentDateForTesting(long nativePersonalDataMa nagerAndroid); 945 private native long nativeGetCurrentDateForTesting(long nativePersonalDataMa nagerAndroid);
951 private native void nativeClearUnmaskedCache( 946 private native void nativeClearUnmaskedCache(
952 long nativePersonalDataManagerAndroid, String guid); 947 long nativePersonalDataManagerAndroid, String guid);
953 private native void nativeGetFullCardForPaymentRequest(long nativePersonalDa taManagerAndroid, 948 private native void nativeGetFullCardForPaymentRequest(long nativePersonalDa taManagerAndroid,
954 WebContents webContents, CreditCard card, FullCardRequestDelegate de legate); 949 WebContents webContents, CreditCard card, FullCardRequestDelegate de legate);
955 private native void nativeLoadRulesForRegion( 950 private native void nativeLoadRulesForRegion(
956 long nativePersonalDataManagerAndroid, String regionCode); 951 long nativePersonalDataManagerAndroid, String regionCode);
957 private native void nativeStartAddressNormalization(long nativePersonalDataM anagerAndroid, 952 private native void nativeStartAddressNormalization(long nativePersonalDataM anagerAndroid,
958 String guid, String regionCode, NormalizedAddressRequestDelegate del egate); 953 String guid, String regionCode, int timeoutSeconds,
954 NormalizedAddressRequestDelegate delegate);
959 private static native boolean nativeHasProfiles(long nativePersonalDataManag erAndroid); 955 private static native boolean nativeHasProfiles(long nativePersonalDataManag erAndroid);
960 private static native boolean nativeHasCreditCards(long nativePersonalDataMa nagerAndroid); 956 private static native boolean nativeHasCreditCards(long nativePersonalDataMa nagerAndroid);
961 private static native boolean nativeIsAutofillEnabled(); 957 private static native boolean nativeIsAutofillEnabled();
962 private static native void nativeSetAutofillEnabled(boolean enable); 958 private static native void nativeSetAutofillEnabled(boolean enable);
963 private static native boolean nativeIsAutofillManaged(); 959 private static native boolean nativeIsAutofillManaged();
964 private static native boolean nativeIsPaymentsIntegrationEnabled(); 960 private static native boolean nativeIsPaymentsIntegrationEnabled();
965 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl e); 961 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl e);
966 private static native String nativeToCountryCode(String countryName); 962 private static native String nativeToCountryCode(String countryName);
967 } 963 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/AutofillPaymentInstrument.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698