OLD | NEW |
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/autofill/autocomplete_history_manager.h" | 6 #include "chrome/browser/autofill/autocomplete_history_manager.h" |
7 #include "chrome/browser/autofill/autofill_external_delegate.h" | 7 #include "chrome/browser/autofill/autofill_external_delegate.h" |
8 #include "chrome/browser/autofill/autofill_manager.h" | 8 #include "chrome/browser/autofill/autofill_manager.h" |
9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
10 #include "chrome/common/autofill_messages.h" | 10 #include "chrome/common/autofill_messages.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 int unique_id) { | 216 int unique_id) { |
217 autofill_manager_->RemoveAutofillProfileOrCreditCard(unique_id); | 217 autofill_manager_->RemoveAutofillProfileOrCreditCard(unique_id); |
218 } | 218 } |
219 | 219 |
220 void AutofillExternalDelegate::DidEndTextFieldEditing() { | 220 void AutofillExternalDelegate::DidEndTextFieldEditing() { |
221 HideAutofillPopup(); | 221 HideAutofillPopup(); |
222 | 222 |
223 has_shown_autofill_popup_for_current_edit_ = false; | 223 has_shown_autofill_popup_for_current_edit_ = false; |
224 } | 224 } |
225 | 225 |
226 bool AutofillExternalDelegate::DidAcceptAutofillSuggestion( | 226 void AutofillExternalDelegate::DidAcceptAutofillSuggestion( |
227 const string16& value, | 227 const string16& value, |
228 int unique_id, | 228 int unique_id) { |
229 unsigned index) { | |
230 // If the selected element is a warning we don't want to do anything. | |
231 if (unique_id == WebAutofillClient::MenuItemIDWarningMessage) | |
232 return false; | |
233 | |
234 RenderViewHost* host = web_contents_->GetRenderViewHost(); | 229 RenderViewHost* host = web_contents_->GetRenderViewHost(); |
235 | 230 |
236 if (unique_id == WebAutofillClient::MenuItemIDAutofillOptions) { | 231 if (unique_id == WebAutofillClient::MenuItemIDAutofillOptions) { |
237 // User selected 'Autofill Options'. | 232 // User selected 'Autofill Options'. |
238 autofill_manager_->OnShowAutofillDialog(); | 233 autofill_manager_->OnShowAutofillDialog(); |
239 } else if (unique_id == WebAutofillClient::MenuItemIDClearForm) { | 234 } else if (unique_id == WebAutofillClient::MenuItemIDClearForm) { |
240 // User selected 'Clear form'. | 235 // User selected 'Clear form'. |
241 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); | 236 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); |
242 } else if (unique_id == WebAutofillClient::MenuItemIDPasswordEntry && | 237 } else if (unique_id == WebAutofillClient::MenuItemIDPasswordEntry && |
243 password_autofill_manager_.DidAcceptAutofillSuggestion( | 238 password_autofill_manager_.DidAcceptAutofillSuggestion( |
244 autofill_query_field_, value)) { | 239 autofill_query_field_, value)) { |
245 // DidAcceptAutofillSuggestion has already handled the work to fill in | 240 // DidAcceptAutofillSuggestion has already handled the work to fill in |
246 // the page as required. | 241 // the page as required. |
247 } else if (unique_id == WebAutofillClient::MenuItemIDDataListEntry) { | 242 } else if (unique_id == WebAutofillClient::MenuItemIDDataListEntry) { |
248 host->Send(new AutofillMsg_AcceptDataListSuggestion(host->GetRoutingID(), | 243 host->Send(new AutofillMsg_AcceptDataListSuggestion(host->GetRoutingID(), |
249 value)); | 244 value)); |
250 } else if (unique_id == WebAutofillClient::MenuItemIDAutocompleteEntry) { | 245 } else if (unique_id == WebAutofillClient::MenuItemIDAutocompleteEntry) { |
251 // User selected an Autocomplete, so we fill directly. | 246 // User selected an Autocomplete, so we fill directly. |
252 host->Send(new AutofillMsg_SetNodeText( | 247 host->Send(new AutofillMsg_SetNodeText( |
253 host->GetRoutingID(), | 248 host->GetRoutingID(), |
254 value)); | 249 value)); |
255 } else { | 250 } else { |
256 FillAutofillFormData(unique_id, false); | 251 FillAutofillFormData(unique_id, false); |
257 } | 252 } |
258 | 253 |
259 HideAutofillPopup(); | 254 HideAutofillPopup(); |
260 | |
261 return true; | |
262 } | 255 } |
263 | 256 |
264 void AutofillExternalDelegate::ClearPreviewedForm() { | 257 void AutofillExternalDelegate::ClearPreviewedForm() { |
265 if (web_contents_) { | 258 if (web_contents_) { |
266 RenderViewHost* host = web_contents_->GetRenderViewHost(); | 259 RenderViewHost* host = web_contents_->GetRenderViewHost(); |
267 | 260 |
268 if (host) | 261 if (host) |
269 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); | 262 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); |
270 } | 263 } |
271 } | 264 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (!*content::Details<bool>(details).ptr()) | 408 if (!*content::Details<bool>(details).ptr()) |
416 HideAutofillPopup(); | 409 HideAutofillPopup(); |
417 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { | 410 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { |
418 HideAutofillPopup(); | 411 HideAutofillPopup(); |
419 } else { | 412 } else { |
420 NOTREACHED(); | 413 NOTREACHED(); |
421 } | 414 } |
422 } | 415 } |
423 | 416 |
424 | 417 |
OLD | NEW |