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

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: Adding profile and credit card deleteion 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;
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 // Don't remove warnings
123 if (autofill_unique_ids_[selected_line_] ==
124 AutofillExternalDelegate::kWarningId)
125 return false;
126
127 if (autofill_unique_ids_[selected_line_] > 0) {
128 external_delegate()->RemoveAutofillProfileOrCreditCard(
129 autofill_unique_ids_[selected_line_]);
130 } else {
131 external_delegate()->RemoveAutocompleteEntry(
132 autofill_values_[selected_line_]);
133 }
134
135 // Move the separator index by one if it exists
136 if (separator_index_ != -1)
137 --separator_index_;
138
139 // Remove the deleted element.
140 autofill_values_.erase(autofill_values_.begin() + selected_line_);
141 autofill_labels_.erase(autofill_labels_.begin() + selected_line_);
142 autofill_icons_.erase(autofill_icons_.begin() + selected_line_);
143 autofill_unique_ids_.erase(autofill_unique_ids_.begin() + selected_line_);
144
145 // Resize the popup.
146 ResizePopup();
147
148 SetSelectedLine(kNoSelection);
149
150 // Hide the popup if all the Autofill entries are gone.
151 if (autofill_values_.size() == 0 || separator_index_ == 0)
152 Hide();
153
154 return true;
120 } 155 }
121 156
122 void AutofillPopupView::Observe(int type, 157 void AutofillPopupView::Observe(int type,
123 const content::NotificationSource& source, 158 const content::NotificationSource& source,
124 const content::NotificationDetails& details) { 159 const content::NotificationDetails& details) {
125 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN 160 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN
126 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) 161 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED)
127 Hide(); 162 Hide();
128 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698