OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/autofill/autofill_agent.h" | 5 #include "chrome/renderer/autofill/autofill_agent.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/common/autofill_messages.h" | 10 #include "chrome/common/autofill_messages.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 215 } |
216 | 216 |
217 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { | 217 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { |
218 if (password_autofill_manager_->TextDidChangeInTextField(element)) | 218 if (password_autofill_manager_->TextDidChangeInTextField(element)) |
219 return; | 219 return; |
220 | 220 |
221 ShowSuggestions(element, false, true, false); | 221 ShowSuggestions(element, false, true, false); |
222 | 222 |
223 webkit_glue::FormData form; | 223 webkit_glue::FormData form; |
224 webkit_glue::FormField field; | 224 webkit_glue::FormField field; |
225 if (FindFormAndFieldForNode(element, &form, &field)) { | 225 if (FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_NONE)) { |
226 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field, | 226 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field, |
227 base::TimeTicks::Now())); | 227 base::TimeTicks::Now())); |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element, | 231 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element, |
232 const WebKeyboardEvent& event) { | 232 const WebKeyboardEvent& event) { |
233 if (password_autofill_manager_->TextFieldHandlingKeyDown(element, event)) | 233 if (password_autofill_manager_->TextFieldHandlingKeyDown(element, event)) |
234 return; | 234 return; |
235 | 235 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 392 |
393 void AutofillAgent::QueryAutofillSuggestions(const WebInputElement& element, | 393 void AutofillAgent::QueryAutofillSuggestions(const WebInputElement& element, |
394 bool display_warning_if_disabled) { | 394 bool display_warning_if_disabled) { |
395 static int query_counter = 0; | 395 static int query_counter = 0; |
396 autofill_query_id_ = query_counter++; | 396 autofill_query_id_ = query_counter++; |
397 autofill_query_element_ = element; | 397 autofill_query_element_ = element; |
398 display_warning_if_disabled_ = display_warning_if_disabled; | 398 display_warning_if_disabled_ = display_warning_if_disabled; |
399 | 399 |
400 webkit_glue::FormData form; | 400 webkit_glue::FormData form; |
401 webkit_glue::FormField field; | 401 webkit_glue::FormField field; |
402 if (!FindFormAndFieldForNode(element, &form, &field)) { | 402 if (!FindFormAndFieldForInputElement(element, &form, &field, |
| 403 REQUIRE_AUTOCOMPLETE)) { |
403 // If we didn't find the cached form, at least let autocomplete have a shot | 404 // If we didn't find the cached form, at least let autocomplete have a shot |
404 // at providing suggestions. | 405 // at providing suggestions. |
405 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); | 406 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); |
406 } | 407 } |
407 | 408 |
408 Send(new AutofillHostMsg_QueryFormFieldAutofill( | 409 Send(new AutofillHostMsg_QueryFormFieldAutofill( |
409 routing_id(), autofill_query_id_, form, field)); | 410 routing_id(), autofill_query_id_, form, field)); |
410 } | 411 } |
411 | 412 |
412 void AutofillAgent::FillAutofillFormData(const WebNode& node, | 413 void AutofillAgent::FillAutofillFormData(const WebNode& node, |
413 int unique_id, | 414 int unique_id, |
414 AutofillAction action) { | 415 AutofillAction action) { |
415 static int query_counter = 0; | 416 static int query_counter = 0; |
416 autofill_query_id_ = query_counter++; | 417 autofill_query_id_ = query_counter++; |
417 | 418 |
418 webkit_glue::FormData form; | 419 webkit_glue::FormData form; |
419 webkit_glue::FormField field; | 420 webkit_glue::FormField field; |
420 if (!FindFormAndFieldForNode(node, &form, &field)) | 421 if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, |
| 422 &field, REQUIRE_AUTOCOMPLETE)) { |
421 return; | 423 return; |
| 424 } |
422 | 425 |
423 autofill_action_ = action; | 426 autofill_action_ = action; |
424 was_query_node_autofilled_ = field.is_autofilled; | 427 was_query_node_autofilled_ = field.is_autofilled; |
425 Send(new AutofillHostMsg_FillAutofillFormData( | 428 Send(new AutofillHostMsg_FillAutofillFormData( |
426 routing_id(), autofill_query_id_, form, field, unique_id)); | 429 routing_id(), autofill_query_id_, form, field, unique_id)); |
427 } | 430 } |
428 | 431 |
429 bool AutofillAgent::FindFormAndFieldForNode(const WebNode& node, | |
430 webkit_glue::FormData* form, | |
431 webkit_glue::FormField* field) { | |
432 const WebInputElement& element = node.toConst<WebInputElement>(); | |
433 return FindFormAndFieldForFormControlElement(element, form, field); | |
434 } | |
435 | |
436 } // namespace autofill | 432 } // namespace autofill |
OLD | NEW |