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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 ThreadUtils.assertOnUiThread(); | 541 ThreadUtils.assertOnUiThread(); |
542 return getProfilesWithLabels(nativeGetProfileLabelsForSettings(mPersonal
DataManagerAndroid), | 542 return getProfilesWithLabels(nativeGetProfileLabelsForSettings(mPersonal
DataManagerAndroid), |
543 nativeGetProfileGUIDsForSettings(mPersonalDataManagerAndroid)); | 543 nativeGetProfileGUIDsForSettings(mPersonalDataManagerAndroid)); |
544 } | 544 } |
545 | 545 |
546 // TODO(crbug.com/616102): Reduce the number of Java to Native calls when ge
tting profiles. | 546 // TODO(crbug.com/616102): Reduce the number of Java to Native calls when ge
tting profiles. |
547 /** | 547 /** |
548 * Gets the profiles to suggest when filling a form or completing a transact
ion. The profiles | 548 * Gets the profiles to suggest when filling a form or completing a transact
ion. The profiles |
549 * will have been processed to be more relevant to the user. | 549 * will have been processed to be more relevant to the user. |
550 * | 550 * |
551 * @param includeName Whether to include the name in the profile's label. | 551 * @param includeNameInLabel Whether to include the name in the profile's la
bel. |
552 * @return The list of profiles to suggest to the user. | 552 * @return The list of profiles to suggest to the user. |
553 */ | 553 */ |
554 public List<AutofillProfile> getProfilesToSuggest(boolean includeName) { | 554 public List<AutofillProfile> getProfilesToSuggest(boolean includeNameInLabel
) { |
555 ThreadUtils.assertOnUiThread(); | 555 ThreadUtils.assertOnUiThread(); |
556 return getProfilesWithLabels( | 556 return getProfilesWithLabels( |
557 nativeGetProfileLabelsToSuggest( | 557 nativeGetProfileLabelsToSuggest( |
558 mPersonalDataManagerAndroid, includeName), | 558 mPersonalDataManagerAndroid, includeNameInLabel), |
559 nativeGetProfileGUIDsToSuggest(mPersonalDataManagerAndroid)); | 559 nativeGetProfileGUIDsToSuggest(mPersonalDataManagerAndroid)); |
560 } | 560 } |
561 | 561 |
562 private List<AutofillProfile> getProfilesWithLabels( | 562 private List<AutofillProfile> getProfilesWithLabels( |
563 String[] profileLabels, String[] profileGUIDs) { | 563 String[] profileLabels, String[] profileGUIDs) { |
564 List<AutofillProfile> profiles = new ArrayList<AutofillProfile>(profileG
UIDs.length); | 564 List<AutofillProfile> profiles = new ArrayList<AutofillProfile>(profileG
UIDs.length); |
565 for (int i = 0; i < profileGUIDs.length; i++) { | 565 for (int i = 0; i < profileGUIDs.length; i++) { |
566 AutofillProfile profile = | 566 AutofillProfile profile = |
567 nativeGetProfileByGUID(mPersonalDataManagerAndroid, profileG
UIDs[i]); | 567 nativeGetProfileByGUID(mPersonalDataManagerAndroid, profileG
UIDs[i]); |
568 profile.setLabel(profileLabels[i]); | 568 profile.setLabel(profileLabels[i]); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 sNormalizationTimeoutMs = timeout; | 816 sNormalizationTimeoutMs = timeout; |
817 } | 817 } |
818 | 818 |
819 private native long nativeInit(); | 819 private native long nativeInit(); |
820 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr
oid); | 820 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr
oid); |
821 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal
DataManagerAndroid); | 821 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal
DataManagerAndroid); |
822 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa
taManagerAndroid); | 822 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa
taManagerAndroid); |
823 private native String[] nativeGetProfileLabelsForSettings( | 823 private native String[] nativeGetProfileLabelsForSettings( |
824 long nativePersonalDataManagerAndroid); | 824 long nativePersonalDataManagerAndroid); |
825 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD
ataManagerAndroid, | 825 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD
ataManagerAndroid, |
826 boolean includeName); | 826 boolean includeNameInLabel); |
827 private native AutofillProfile nativeGetProfileByGUID(long nativePersonalDat
aManagerAndroid, | 827 private native AutofillProfile nativeGetProfileByGUID(long nativePersonalDat
aManagerAndroid, |
828 String guid); | 828 String guid); |
829 private native String nativeSetProfile(long nativePersonalDataManagerAndroid
, | 829 private native String nativeSetProfile(long nativePersonalDataManagerAndroid
, |
830 AutofillProfile profile); | 830 AutofillProfile profile); |
831 private native String nativeGetAddressLabelForPaymentRequest( | 831 private native String nativeGetAddressLabelForPaymentRequest( |
832 long nativePersonalDataManagerAndroid, AutofillProfile profile); | 832 long nativePersonalDataManagerAndroid, AutofillProfile profile); |
833 private native String[] nativeGetCreditCardGUIDsForSettings( | 833 private native String[] nativeGetCreditCardGUIDsForSettings( |
834 long nativePersonalDataManagerAndroid); | 834 long nativePersonalDataManagerAndroid); |
835 private native String[] nativeGetCreditCardGUIDsToSuggest( | 835 private native String[] nativeGetCreditCardGUIDsToSuggest( |
836 long nativePersonalDataManagerAndroid); | 836 long nativePersonalDataManagerAndroid); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 String guid, String regionCode, NormalizedAddressRequestDelegate del
egate); | 874 String guid, String regionCode, NormalizedAddressRequestDelegate del
egate); |
875 private native void nativeCancelPendingAddressNormalization( | 875 private native void nativeCancelPendingAddressNormalization( |
876 long nativePersonalDataManagerAndroid); | 876 long nativePersonalDataManagerAndroid); |
877 private static native boolean nativeIsAutofillEnabled(); | 877 private static native boolean nativeIsAutofillEnabled(); |
878 private static native void nativeSetAutofillEnabled(boolean enable); | 878 private static native void nativeSetAutofillEnabled(boolean enable); |
879 private static native boolean nativeIsAutofillManaged(); | 879 private static native boolean nativeIsAutofillManaged(); |
880 private static native boolean nativeIsPaymentsIntegrationEnabled(); | 880 private static native boolean nativeIsPaymentsIntegrationEnabled(); |
881 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl
e); | 881 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl
e); |
882 private static native String nativeToCountryCode(String countryName); | 882 private static native String nativeToCountryCode(String countryName); |
883 } | 883 } |
OLD | NEW |