Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Unified Diff: chrome/browser/autofill/autofill_popup_view.cc

Issue 10073018: Add Delete Support to New Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autofill/autofill_popup_view.cc
diff --git a/chrome/browser/autofill/autofill_popup_view.cc b/chrome/browser/autofill/autofill_popup_view.cc
index 657fc4b7640d51470107e455f4fc979b65c529f2..9587555274fbe838d3e22cf6fb8546c980961de9 100644
--- a/chrome/browser/autofill/autofill_popup_view.cc
+++ b/chrome/browser/autofill/autofill_popup_view.cc
@@ -112,11 +112,37 @@ bool AutofillPopupView::AcceptSelectedLine() {
}
bool AutofillPopupView::RemoveSelectedLine() {
- if (selected_line_ == kNoSelection)
+ if (selected_line_ == kNoSelection ||
+ (separator_index_ != -1 && separator_index_ <= selected_line_))
return false;
Ilya Sherman 2012/04/17 08:31:20 It should also be impossible to delete a warning.
csharp 2012/04/18 15:35:58 Done.
- // TODO(csharp) add removal code.
- return false;
+ DCHECK_GE(selected_line_, 0);
+ DCHECK_LT(selected_line_, static_cast<int>(autofill_values_.size()));
+
+ // If the user attempts to delete an Autofill entry, just hide the popup.
Ilya Sherman 2012/04/17 08:31:20 Ideally we would delete the autofill entry as well
csharp 2012/04/18 15:35:58 K, I dug into the code a bit and got deletion of p
+ if (autofill_unique_ids_[selected_line_] > 0) {
+ Hide();
+ return true;
+ }
+
+ external_delegate()->RemoveAutocompleteEntry(
+ autofill_values_[selected_line_]);
+
+ --separator_index_;
+
+ // Remove the deleted element.
+ autofill_values_.erase(autofill_values_.begin() + selected_line_);
+ autofill_labels_.erase(autofill_labels_.begin() + selected_line_);
+ autofill_icons_.erase(autofill_icons_.begin() + selected_line_);
+ autofill_unique_ids_.erase(autofill_unique_ids_.begin() + selected_line_);
+
+ SetSelectedLine(kNoSelection);
+
+ // Hide the popup if all the Autofill entries are gone.
+ if (autofill_values_.size() == 0 || separator_index_ == 0)
+ Hide();
+
+ return true;
}
void AutofillPopupView::Observe(int type,

Powered by Google App Engine
This is Rietveld 408576698