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

Side by Side Diff: chrome/browser/autofill/autofill_external_delegate.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 "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/autocomplete_history_manager.h"
6 #include "chrome/browser/autofill/autofill_external_delegate.h" 7 #include "chrome/browser/autofill/autofill_external_delegate.h"
7 #include "chrome/browser/autofill/autofill_manager.h" 8 #include "chrome/browser/autofill/autofill_manager.h"
8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
9 #include "chrome/common/autofill_messages.h" 10 #include "chrome/common/autofill_messages.h"
10 #include "chrome/common/chrome_constants.h" 11 #include "chrome/common/chrome_constants.h"
11 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
13 #include "grit/chromium_strings.h" 14 #include "grit/chromium_strings.h"
14 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
16 17
17 using content::RenderViewHost; 18 using content::RenderViewHost;
18 19
19 namespace { 20 namespace {
20
21 // The value to give as the unique id for all warnings.
22 const int kWarningId = -1;
23
24 // The value to give as the unique id for all password entries. 21 // The value to give as the unique id for all password entries.
25 const int kPasswordEntryId = -2; 22 const int kPasswordEntryId = -2;
26 23
27 } // namespace 24 } // namespace
28 25
29 AutofillExternalDelegate::~AutofillExternalDelegate() { 26 AutofillExternalDelegate::~AutofillExternalDelegate() {
30 } 27 }
31 28
32 AutofillExternalDelegate::AutofillExternalDelegate( 29 AutofillExternalDelegate::AutofillExternalDelegate(
33 TabContentsWrapper* tab_contents_wrapper, 30 TabContentsWrapper* tab_contents_wrapper,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return; 160 return;
164 } 161 }
165 162
166 SetBounds(bounds); 163 SetBounds(bounds);
167 164
168 std::vector<string16> empty(suggestions.size()); 165 std::vector<string16> empty(suggestions.size());
169 std::vector<int> password_ids(suggestions.size(), kPasswordEntryId); 166 std::vector<int> password_ids(suggestions.size(), kPasswordEntryId);
170 ApplyAutofillSuggestions(suggestions, empty, empty, password_ids, -1); 167 ApplyAutofillSuggestions(suggestions, empty, empty, password_ids, -1);
171 } 168 }
172 169
170 void AutofillExternalDelegate::RemoveAutocompleteEntry(const string16& value) {
171 if (tab_contents_wrapper_) {
172 tab_contents_wrapper_->autocomplete_history_manager()->
173 OnRemoveAutocompleteEntry(autofill_query_field_.name, value);
174 }
175
176 AdjustIndicesAfterDeletion();
Ilya Sherman 2012/04/18 18:12:51 nit: This probably makes sense to do in a follow-u
csharp 2012/04/19 15:33:24 I just added that to this change. Let me remove a
177 }
178
179 void AutofillExternalDelegate::RemoveAutofillProfileOrCreditCard(
180 int unique_id) {
181 autofill_manager_->RemoveAutofillProfileOrCreditCard(unique_id);
182
183 AdjustIndicesAfterDeletion();
184 }
185
186
173 void AutofillExternalDelegate::DidEndTextFieldEditing() { 187 void AutofillExternalDelegate::DidEndTextFieldEditing() {
174 has_shown_autofill_popup_for_current_edit_ = false; 188 has_shown_autofill_popup_for_current_edit_ = false;
175 } 189 }
176 190
177 bool AutofillExternalDelegate::DidAcceptAutofillSuggestions( 191 bool AutofillExternalDelegate::DidAcceptAutofillSuggestions(
178 const string16& value, 192 const string16& value,
179 int unique_id, 193 int unique_id,
180 unsigned index) { 194 unsigned index) {
181 // If the selected element is a warning we don't want to do anything. 195 // If the selected element is a warning we don't want to do anything.
182 if (unique_id == kWarningId) 196 if (unique_id == kWarningId)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 host->GetRoutingID())); 268 host->GetRoutingID()));
255 } 269 }
256 270
257 // Fill the values for the whole form. 271 // Fill the values for the whole form.
258 autofill_manager_->OnFillAutofillFormData(autofill_query_id_, 272 autofill_manager_->OnFillAutofillFormData(autofill_query_id_,
259 autofill_query_form_, 273 autofill_query_form_,
260 autofill_query_field_, 274 autofill_query_field_,
261 unique_id); 275 unique_id);
262 } 276 }
263 277
278 void AutofillExternalDelegate::AdjustIndicesAfterDeletion() {
279 if (suggestions_clear_index_ != -1)
280 --suggestions_clear_index_;
281
282 if (suggestions_options_index_ != -1)
283 --suggestions_options_index_;
284 }
285
264 // Add a "!defined(OS_YOUROS) for each platform that implements this 286 // Add a "!defined(OS_YOUROS) for each platform that implements this
265 // in an autofill_external_delegate_YOUROS.cc. Currently there are 287 // in an autofill_external_delegate_YOUROS.cc. Currently there are
266 // none, so all platforms use the default. 288 // none, so all platforms use the default.
267 289
268 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK) 290 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK)
269 291
270 AutofillExternalDelegate* AutofillExternalDelegate::Create( 292 AutofillExternalDelegate* AutofillExternalDelegate::Create(
271 TabContentsWrapper*, AutofillManager*) { 293 TabContentsWrapper*, AutofillManager*) {
272 return NULL; 294 return NULL;
273 } 295 }
274 296
275 #endif 297 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698