Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java |
| index 305b302e69d025a07217d3d83f4a01d3aa5c5fa0..ec410bcfff3e29c6221f3364f6a03422a760e2c3 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java |
| @@ -473,23 +473,26 @@ public class PersonalDataManager { |
| mDataObservers.remove(observer); |
| } |
| - public List<AutofillProfile> getProfiles() { |
| - return getProfilesWithAddressOnlyLabels(false); |
| - } |
| - |
| - public List<AutofillProfile> getAddressOnlyProfiles() { |
| - return getProfilesWithAddressOnlyLabels(true); |
| + // TODO(crbug.com/616102): Reduce the number of Java to Native calls when getting profiles. |
| + public List<AutofillProfile> getProfilesForSettings() { |
|
gone
2016/05/31 22:39:42
Add a javadoc here so that people who aren't famil
please use gerrit instead
2016/06/01 17:42:59
It was originally my request. getProfiles(), which
gone
2016/06/01 17:48:10
Eh, it's fine. I'm just worried that you could ge
sebsg
2016/06/01 20:58:24
Good point to the javadoc. I'll stay purposely vag
|
| + ThreadUtils.assertOnUiThread(); |
| + return getProfilesWithLabels(nativeGetProfileLabelsForSettings(mPersonalDataManagerAndroid), |
| + nativeGetProfileGUIDsForSettings(mPersonalDataManagerAndroid)); |
| } |
| - private List<AutofillProfile> getProfilesWithAddressOnlyLabels(boolean addressOnly) { |
| + // TODO(crbug.com/616102): Reduce the number of Java to Native calls when getting profiles. |
|
gone
2016/05/31 22:39:42
This really is kind of an absurd number of JNI cal
sebsg
2016/06/01 20:58:24
You are correct, this seems like an unncessary num
|
| + public List<AutofillProfile> getProfilesToSuggest() { |
| ThreadUtils.assertOnUiThread(); |
| + return getProfilesWithLabels(nativeGetProfileLabelsToSuggest(mPersonalDataManagerAndroid), |
| + nativeGetProfileGUIDsToSuggest(mPersonalDataManagerAndroid)); |
| + } |
| - String[] profileLabels = nativeGetProfileLabels(mPersonalDataManagerAndroid, addressOnly); |
| - |
| - int profileCount = nativeGetProfileCount(mPersonalDataManagerAndroid); |
| - List<AutofillProfile> profiles = new ArrayList<AutofillProfile>(profileCount); |
| - for (int i = 0; i < profileCount; i++) { |
| - AutofillProfile profile = nativeGetProfileByIndex(mPersonalDataManagerAndroid, i); |
| + private List<AutofillProfile> getProfilesWithLabels( |
| + String[] profileLabels, String[] profileGUIDs) { |
| + List<AutofillProfile> profiles = new ArrayList<AutofillProfile>(profileGUIDs.length); |
| + for (int i = 0; i < profileGUIDs.length; i++) { |
| + AutofillProfile profile = |
| + nativeGetProfileByGUID(mPersonalDataManagerAndroid, profileGUIDs[i]); |
| profile.setLabel(profileLabels[i]); |
| profiles.add(profile); |
| } |
| @@ -512,12 +515,22 @@ public class PersonalDataManager { |
| return nativeSetProfile(mPersonalDataManagerAndroid, profile); |
| } |
| - public List<CreditCard> getCreditCards() { |
| + public List<CreditCard> getCreditCardsForSettings() { |
| ThreadUtils.assertOnUiThread(); |
| - int count = nativeGetCreditCardCount(mPersonalDataManagerAndroid); |
| - List<CreditCard> cards = new ArrayList<CreditCard>(count); |
| - for (int i = 0; i < count; i++) { |
| - cards.add(nativeGetCreditCardByIndex(mPersonalDataManagerAndroid, i)); |
| + |
|
please use gerrit instead
2016/05/31 18:51:56
nit: no new line.
sebsg
2016/06/01 20:58:24
Done.
|
| + return getCreditCards(nativeGetCreditCardGUIDsForSettings(mPersonalDataManagerAndroid)); |
| + } |
| + |
| + public List<CreditCard> getCreditCardsToSuggest() { |
| + ThreadUtils.assertOnUiThread(); |
| + |
|
please use gerrit instead
2016/05/31 18:51:56
nit: no new line.
sebsg
2016/06/01 20:58:24
Done.
|
| + return getCreditCards(nativeGetCreditCardGUIDsToSuggest(mPersonalDataManagerAndroid)); |
| + } |
| + |
| + private List<CreditCard> getCreditCards(String[] creditCardGUIDs) { |
| + List<CreditCard> cards = new ArrayList<CreditCard>(creditCardGUIDs.length); |
| + for (int i = 0; i < creditCardGUIDs.length; i++) { |
| + cards.add(nativeGetCreditCardByGUID(mPersonalDataManagerAndroid, creditCardGUIDs[i])); |
| } |
| return cards; |
| } |
| @@ -555,6 +568,18 @@ public class PersonalDataManager { |
| mPersonalDataManagerAndroid, webContents, guid, delegate); |
| } |
| + @VisibleForTesting |
| + public void setProfileUseStatsForTesting(String guid, int count, int date) { |
|
gone
2016/05/31 22:39:42
1) Can this be package protected?
2) Timestamps ar
sebsg
2016/06/01 20:58:24
Done.
|
| + ThreadUtils.assertOnUiThread(); |
| + nativeSetProfileUseStatsForTesting(mPersonalDataManagerAndroid, guid, count, date); |
| + } |
| + |
| + @VisibleForTesting |
| + public void setCreditCardUseStatsForTesting(String guid, int count, int date) { |
| + ThreadUtils.assertOnUiThread(); |
| + nativeSetCreditCardUseStatsForTesting(mPersonalDataManagerAndroid, guid, count, date); |
| + } |
| + |
| /** |
| * @return Whether the Autofill feature is enabled. |
| */ |
| @@ -593,18 +618,19 @@ public class PersonalDataManager { |
| } |
| private native long nativeInit(); |
| - private native int nativeGetProfileCount(long nativePersonalDataManagerAndroid); |
| - private native String[] nativeGetProfileLabels(long nativePersonalDataManagerAndroid, |
| - boolean addressOnly); |
| - private native AutofillProfile nativeGetProfileByIndex(long nativePersonalDataManagerAndroid, |
| - int index); |
| + private native String[] nativeGetProfileGUIDsForSettings(long nativePersonalDataManagerAndroid); |
| + private native String[] nativeGetProfileGUIDsToSuggest(long nativePersonalDataManagerAndroid); |
| + private native String[] nativeGetProfileLabelsForSettings( |
| + long nativePersonalDataManagerAndroid); |
| + private native String[] nativeGetProfileLabelsToSuggest(long nativePersonalDataManagerAndroid); |
| private native AutofillProfile nativeGetProfileByGUID(long nativePersonalDataManagerAndroid, |
| String guid); |
| private native String nativeSetProfile(long nativePersonalDataManagerAndroid, |
| AutofillProfile profile); |
| - private native int nativeGetCreditCardCount(long nativePersonalDataManagerAndroid); |
| - private native CreditCard nativeGetCreditCardByIndex(long nativePersonalDataManagerAndroid, |
| - int index); |
| + private native String[] nativeGetCreditCardGUIDsForSettings( |
| + long nativePersonalDataManagerAndroid); |
| + private native String[] nativeGetCreditCardGUIDsToSuggest( |
| + long nativePersonalDataManagerAndroid); |
| private native CreditCard nativeGetCreditCardByGUID(long nativePersonalDataManagerAndroid, |
| String guid); |
| private native String nativeSetCreditCard(long nativePersonalDataManagerAndroid, |
| @@ -612,6 +638,10 @@ public class PersonalDataManager { |
| private native void nativeAddServerCreditCardForTest(long nativePersonalDataManagerAndroid, |
| CreditCard card); |
| private native void nativeRemoveByGUID(long nativePersonalDataManagerAndroid, String guid); |
| + private native void nativeSetProfileUseStatsForTesting( |
| + long nativePersonalDataManagerAndroid, String guid, int count, int date); |
| + private native void nativeSetCreditCardUseStatsForTesting( |
| + long nativePersonalDataManagerAndroid, String guid, int count, int date); |
| private native void nativeClearUnmaskedCache( |
| long nativePersonalDataManagerAndroid, String guid); |
| private native void nativeGetFullCardForPaymentRequest(long nativePersonalDataManagerAndroid, |