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..d3f9d6d90868481a335544bc76f7f003c54ac5e5 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,38 @@ public class PersonalDataManager { |
mDataObservers.remove(observer); |
} |
- public List<AutofillProfile> getProfiles() { |
- return getProfilesWithAddressOnlyLabels(false); |
+ public List<AutofillProfile> getProfilesForSettings() { |
+ return getProfilesWithAddressOnlyLabelsForSettings(false); |
} |
- public List<AutofillProfile> getAddressOnlyProfiles() { |
- return getProfilesWithAddressOnlyLabels(true); |
+ public List<AutofillProfile> getProfilesToSuggest() { |
please use gerrit instead
2016/05/27 21:47:30
This method is never called in production. Let's r
sebsg
2016/05/31 15:26:14
Done.
|
+ return getProfilesWithAddressOnlyLabelsToSuggest(false); |
} |
- private List<AutofillProfile> getProfilesWithAddressOnlyLabels(boolean addressOnly) { |
+ public List<AutofillProfile> getAddressOnlyProfilesToSuggest() { |
+ return getProfilesWithAddressOnlyLabelsToSuggest(true); |
+ } |
+ |
+ private List<AutofillProfile> getProfilesWithAddressOnlyLabelsForSettings(boolean addressOnly) { |
please use gerrit instead
2016/05/27 21:47:30
This function is used only in getProfilesForSettin
sebsg
2016/05/31 15:26:14
Done.
|
ThreadUtils.assertOnUiThread(); |
+ return getProfilesWithLabels( |
+ nativeGetProfileLabelsForSettings(mPersonalDataManagerAndroid, addressOnly), |
+ nativeGetProfileGUIDsForSettings(mPersonalDataManagerAndroid)); |
please use gerrit instead
2016/05/27 21:47:30
Java-to-Native and Native-to-Java calls are relati
sebsg
2016/05/31 15:26:14
I added a TODO and I'm going to tackle this issue
|
+ } |
- String[] profileLabels = nativeGetProfileLabels(mPersonalDataManagerAndroid, addressOnly); |
+ private List<AutofillProfile> getProfilesWithAddressOnlyLabelsToSuggest(boolean addressOnly) { |
please use gerrit instead
2016/05/27 21:47:30
After getProfilesToSuggest() is removed, this meth
sebsg
2016/05/31 15:26:14
Done.
|
+ ThreadUtils.assertOnUiThread(); |
+ return getProfilesWithLabels( |
+ nativeGetProfileLabelsToSuggest(mPersonalDataManagerAndroid, addressOnly), |
+ nativeGetProfileGUIDsToSuggest(mPersonalDataManagerAndroid)); |
+ } |
- 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 +527,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)); |
+ |
+ return getCreditCards(nativeGetCreditCardGUIDsForSettings(mPersonalDataManagerAndroid)); |
+ } |
+ |
+ public List<CreditCard> getCreditCardsToSuggest() { |
+ ThreadUtils.assertOnUiThread(); |
+ |
+ 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 +580,18 @@ public class PersonalDataManager { |
mPersonalDataManagerAndroid, webContents, guid, delegate); |
} |
+ @VisibleForTesting |
+ public void setProfileUseStatsForTesting(String guid, int count, int date) { |
+ 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 +630,20 @@ 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, boolean addressOnly); |
+ private native String[] nativeGetProfileLabelsToSuggest( |
+ long nativePersonalDataManagerAndroid, boolean addressOnly); |
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 +651,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, |