Index: ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java |
diff --git a/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java b/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java |
index f41c3f464f3aa46ab6cad8df33584d17936838af..0019b4cd1d90c5474d0c712a7baff19406272afd 100644 |
--- a/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java |
+++ b/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java |
@@ -25,7 +25,7 @@ import java.util.List; |
* The Autofill suggestion popup that lists relevant suggestions. |
*/ |
public class AutofillPopup extends DropdownPopupWindow implements AdapterView.OnItemClickListener, |
- PopupWindow.OnDismissListener { |
+ AdapterView.OnItemLongClickListener, PopupWindow.OnDismissListener { |
/** |
* The constant used to specify a separator in a list of Autofill suggestions. |
@@ -52,6 +52,12 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On |
* @param listIndex The index of the selected Autofill suggestion. |
*/ |
public void suggestionSelected(int listIndex); |
+ |
+ /** |
+ * Initiates the deletion process for an item. (A confirm dialog should be shown.) |
+ * @param listIndex The index of the suggestion to delete. |
+ */ |
+ public void deleteSuggestion(int listIndex); |
} |
/** |
@@ -95,6 +101,7 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On |
setAdapter(new DropdownAdapter(mContext, cleanedData, separators)); |
setRtl(isRtl); |
show(); |
+ getListView().setOnItemLongClickListener(this); |
} |
@Override |
@@ -106,6 +113,18 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On |
} |
@Override |
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { |
+ DropdownAdapter adapter = (DropdownAdapter) parent.getAdapter(); |
+ AutofillSuggestion suggestion = (AutofillSuggestion) adapter.getItem(position); |
+ if (!suggestion.isDeletable()) return false; |
+ |
+ int listIndex = mSuggestions.indexOf(suggestion); |
+ assert listIndex > -1; |
+ mAutofillCallback.deleteSuggestion(listIndex); |
+ return true; |
+ } |
+ |
+ @Override |
public void onDismiss() { |
mAutofillCallback.dismissed(); |
} |