WV Autofill: Use latest datalist suggestion
Previously, the internal class which extends AutofillPopup uses a copy
of suggestions when it is created, the copy one won't be changed
when suggestions changed.
This patch adds the suggestion array as data member, so the internal
class will always refer the latest suggestions.
(cherry picked from commit 125aefddf14425df5d080f8edd1be89064b4bd26)
Bug: 949555, 1136585
Test: verified manually
Change-Id: I4f300be648af4038c7b26f115161d8e56b9575b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462336
Reviewed-by: Dominic Battré <[email protected]>
Commit-Queue: Michael Bai <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#815716}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2466257
Reviewed-by: Michael Bai <[email protected]>
Cr-Commit-Position: refs/branch-heads/4280@{#244}
Cr-Branched-From: ea420fb963f9658c9969b6513c56b8f47efa1a2a-refs/heads/master@{#812852}
diff --git a/components/autofill/android/provider/java/src/org/chromium/components/autofill/AutofillProvider.java b/components/autofill/android/provider/java/src/org/chromium/components/autofill/AutofillProvider.java
index 3b7c63a..1546b3d 100644
--- a/components/autofill/android/provider/java/src/org/chromium/components/autofill/AutofillProvider.java
+++ b/components/autofill/android/provider/java/src/org/chromium/components/autofill/AutofillProvider.java
@@ -262,6 +262,7 @@
private long mAutofillTriggeredTimeMillis;
private Context mContext;
private AutofillPopup mDatalistPopup;
+ private AutofillSuggestion[] mDatalistSuggestions;
private WebContentsAccessibility mWebContentsAccessibility;
private View mAnchorView;
@@ -533,6 +534,7 @@
if (mDatalistPopup != null) {
mDatalistPopup.dismiss();
mDatalistPopup = null;
+ mDatalistSuggestions = null;
}
if (mWebContentsAccessibility != null) {
mWebContentsAccessibility.onAutofillPopupDismissed();
@@ -600,9 +602,9 @@
*/
private void showDatalistPopup(
String[] datalistValues, String[] datalistLabels, RectF bounds, boolean isRtl) {
- final AutofillSuggestion[] suggestions = new AutofillSuggestion[datalistValues.length];
- for (int i = 0; i < suggestions.length; i++) {
- suggestions[i] = new AutofillSuggestion(datalistValues[i], datalistLabels[i],
+ mDatalistSuggestions = new AutofillSuggestion[datalistValues.length];
+ for (int i = 0; i < mDatalistSuggestions.length; i++) {
+ mDatalistSuggestions[i] = new AutofillSuggestion(datalistValues[i], datalistLabels[i],
/* itemTag= */ "", DropdownItem.NO_ICON, false /* isIconAtLeft */, i,
false /* isDeletable */, false /* isMultilineLabel */, false /* isBoldLabel */);
}
@@ -623,7 +625,7 @@
@Override
public void suggestionSelected(int listIndex) {
- onSuggestionSelected(suggestions[listIndex].getLabel());
+ onSuggestionSelected(mDatalistSuggestions[listIndex].getLabel());
}
@Override
@@ -641,7 +643,7 @@
return;
}
}
- mDatalistPopup.filterAndShow(suggestions, isRtl, false);
+ mDatalistPopup.filterAndShow(mDatalistSuggestions, isRtl, false);
if (mWebContentsAccessibility != null) {
mWebContentsAccessibility.onAutofillPopupDisplayed(mDatalistPopup.getListView());
}