Chromium Code Reviews| 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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 includeNameInLabel Whether to include the name in the profile's la bel. | 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 includeNameInLabel ) { | 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, includeNameInLabel), | 558 mPersonalDataManagerAndroid, includeNameInLabel, |
| 559 true /* includeOrganizationInLabel */, true /* includeCo untryInLabel */), | |
| 559 nativeGetProfileGUIDsToSuggest(mPersonalDataManagerAndroid)); | 560 nativeGetProfileGUIDsToSuggest(mPersonalDataManagerAndroid)); |
| 560 } | 561 } |
| 561 | 562 |
| 563 // TODO(crbug.com/616102): Reduce the number of Java to Native calls when ge tting profiles. | |
|
gone
2016/11/07 18:50:26
Plop this in as part of the function javadoc?
sebsg
2016/11/07 19:58:28
Done.
| |
| 564 /** | |
| 565 * Gets the profiles to suggest when associating a billing address to a cred it card. The | |
| 566 * profiles will have been processed to be more relevant to the user. | |
| 567 * | |
| 568 * @return The list of billing addresses to suggest to the user. | |
| 569 */ | |
| 570 public List<AutofillProfile> getBillingAddressesToSuggest() { | |
| 571 ThreadUtils.assertOnUiThread(); | |
| 572 return getProfilesWithLabels( | |
| 573 nativeGetProfileLabelsToSuggest( | |
| 574 mPersonalDataManagerAndroid, true /* includeNameInLabel */, | |
| 575 false /* includeOrganizationInLabel */, false /* include CountryInLabel */), | |
| 576 nativeGetProfileGUIDsToSuggest(mPersonalDataManagerAndroid)); | |
| 577 } | |
| 578 | |
| 562 private List<AutofillProfile> getProfilesWithLabels( | 579 private List<AutofillProfile> getProfilesWithLabels( |
| 563 String[] profileLabels, String[] profileGUIDs) { | 580 String[] profileLabels, String[] profileGUIDs) { |
| 564 List<AutofillProfile> profiles = new ArrayList<AutofillProfile>(profileG UIDs.length); | 581 List<AutofillProfile> profiles = new ArrayList<AutofillProfile>(profileG UIDs.length); |
| 565 for (int i = 0; i < profileGUIDs.length; i++) { | 582 for (int i = 0; i < profileGUIDs.length; i++) { |
| 566 AutofillProfile profile = | 583 AutofillProfile profile = |
| 567 nativeGetProfileByGUID(mPersonalDataManagerAndroid, profileG UIDs[i]); | 584 nativeGetProfileByGUID(mPersonalDataManagerAndroid, profileG UIDs[i]); |
| 568 profile.setLabel(profileLabels[i]); | 585 profile.setLabel(profileLabels[i]); |
| 569 profiles.add(profile); | 586 profiles.add(profile); |
| 570 } | 587 } |
| 571 | 588 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 sNormalizationTimeoutMs = timeout; | 834 sNormalizationTimeoutMs = timeout; |
| 818 } | 835 } |
| 819 | 836 |
| 820 private native long nativeInit(); | 837 private native long nativeInit(); |
| 821 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr oid); | 838 private native boolean nativeIsDataLoaded(long nativePersonalDataManagerAndr oid); |
| 822 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal DataManagerAndroid); | 839 private native String[] nativeGetProfileGUIDsForSettings(long nativePersonal DataManagerAndroid); |
| 823 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa taManagerAndroid); | 840 private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDa taManagerAndroid); |
| 824 private native String[] nativeGetProfileLabelsForSettings( | 841 private native String[] nativeGetProfileLabelsForSettings( |
| 825 long nativePersonalDataManagerAndroid); | 842 long nativePersonalDataManagerAndroid); |
| 826 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD ataManagerAndroid, | 843 private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalD ataManagerAndroid, |
| 827 boolean includeNameInLabel); | 844 boolean includeNameInLabel, boolean includeOrganizationInLabel, |
| 845 boolean includeCountryInLabel); | |
| 828 private native AutofillProfile nativeGetProfileByGUID(long nativePersonalDat aManagerAndroid, | 846 private native AutofillProfile nativeGetProfileByGUID(long nativePersonalDat aManagerAndroid, |
| 829 String guid); | 847 String guid); |
| 830 private native String nativeSetProfile(long nativePersonalDataManagerAndroid , | 848 private native String nativeSetProfile(long nativePersonalDataManagerAndroid , |
| 831 AutofillProfile profile); | 849 AutofillProfile profile); |
| 832 private native String nativeGetAddressLabelForPaymentRequest( | 850 private native String nativeGetAddressLabelForPaymentRequest( |
| 833 long nativePersonalDataManagerAndroid, AutofillProfile profile); | 851 long nativePersonalDataManagerAndroid, AutofillProfile profile); |
| 834 private native String[] nativeGetCreditCardGUIDsForSettings( | 852 private native String[] nativeGetCreditCardGUIDsForSettings( |
| 835 long nativePersonalDataManagerAndroid); | 853 long nativePersonalDataManagerAndroid); |
| 836 private native String[] nativeGetCreditCardGUIDsToSuggest( | 854 private native String[] nativeGetCreditCardGUIDsToSuggest( |
| 837 long nativePersonalDataManagerAndroid); | 855 long nativePersonalDataManagerAndroid); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 875 String guid, String regionCode, NormalizedAddressRequestDelegate del egate); | 893 String guid, String regionCode, NormalizedAddressRequestDelegate del egate); |
| 876 private native void nativeCancelPendingAddressNormalizations( | 894 private native void nativeCancelPendingAddressNormalizations( |
| 877 long nativePersonalDataManagerAndroid); | 895 long nativePersonalDataManagerAndroid); |
| 878 private static native boolean nativeIsAutofillEnabled(); | 896 private static native boolean nativeIsAutofillEnabled(); |
| 879 private static native void nativeSetAutofillEnabled(boolean enable); | 897 private static native void nativeSetAutofillEnabled(boolean enable); |
| 880 private static native boolean nativeIsAutofillManaged(); | 898 private static native boolean nativeIsAutofillManaged(); |
| 881 private static native boolean nativeIsPaymentsIntegrationEnabled(); | 899 private static native boolean nativeIsPaymentsIntegrationEnabled(); |
| 882 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl e); | 900 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl e); |
| 883 private static native String nativeToCountryCode(String countryName); | 901 private static native String nativeToCountryCode(String countryName); |
| 884 } | 902 } |
| OLD | NEW |