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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autofill/autofill_popup_view.h" 5 #include "chrome/browser/autofill/autofill_popup_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/autofill/autofill_external_delegate.h" 8 #include "chrome/browser/autofill/autofill_external_delegate.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 DCHECK_GE(selected_line_, 0); 105 DCHECK_GE(selected_line_, 0);
106 DCHECK_LT(selected_line_, static_cast<int>(autofill_values_.size())); 106 DCHECK_LT(selected_line_, static_cast<int>(autofill_values_.size()));
107 107
108 return external_delegate()->DidAcceptAutofillSuggestions( 108 return external_delegate()->DidAcceptAutofillSuggestions(
109 autofill_values_[selected_line_], 109 autofill_values_[selected_line_],
110 autofill_unique_ids_[selected_line_], 110 autofill_unique_ids_[selected_line_],
111 selected_line_); 111 selected_line_);
112 } 112 }
113 113
114 bool AutofillPopupView::RemoveSelectedLine() { 114 bool AutofillPopupView::RemoveSelectedLine() {
115 if (selected_line_ == kNoSelection) 115 if (selected_line_ == kNoSelection ||
116 (separator_index_ != -1 && separator_index_ <= selected_line_))
116 return false; 117 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.
117 118
118 // TODO(csharp) add removal code. 119 DCHECK_GE(selected_line_, 0);
119 return false; 120 DCHECK_LT(selected_line_, static_cast<int>(autofill_values_.size()));
121
122 // 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
123 if (autofill_unique_ids_[selected_line_] > 0) {
124 Hide();
125 return true;
126 }
127
128 external_delegate()->RemoveAutocompleteEntry(
129 autofill_values_[selected_line_]);
130
131 --separator_index_;
132
133 // Remove the deleted element.
134 autofill_values_.erase(autofill_values_.begin() + selected_line_);
135 autofill_labels_.erase(autofill_labels_.begin() + selected_line_);
136 autofill_icons_.erase(autofill_icons_.begin() + selected_line_);
137 autofill_unique_ids_.erase(autofill_unique_ids_.begin() + selected_line_);
138
139 SetSelectedLine(kNoSelection);
140
141 // Hide the popup if all the Autofill entries are gone.
142 if (autofill_values_.size() == 0 || separator_index_ == 0)
143 Hide();
144
145 return true;
120 } 146 }
121 147
122 void AutofillPopupView::Observe(int type, 148 void AutofillPopupView::Observe(int type,
123 const content::NotificationSource& source, 149 const content::NotificationSource& source,
124 const content::NotificationDetails& details) { 150 const content::NotificationDetails& details) {
125 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN 151 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN
126 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) 152 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED)
127 Hide(); 153 Hide();
128 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698