| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 suggestions_clear_index_--; | 196 suggestions_clear_index_--; |
| 197 if (suggestions_options_index_ != -1) | 197 if (suggestions_options_index_ != -1) |
| 198 suggestions_options_index_--; | 198 suggestions_options_index_--; |
| 199 | 199 |
| 200 Send(new AutofillHostMsg_RemoveAutocompleteEntry(routing_id(), name, value)); | 200 Send(new AutofillHostMsg_RemoveAutocompleteEntry(routing_id(), name, value)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { | 203 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
| 204 password_autofill_manager_->TextFieldDidEndEditing(element); | 204 password_autofill_manager_->TextFieldDidEndEditing(element); |
| 205 has_shown_autofill_popup_for_current_edit_ = false; | 205 has_shown_autofill_popup_for_current_edit_ = false; |
| 206 Send(new AutofillHostMsg_SetDidEndTextFieldEditing(routing_id())); |
| 206 } | 207 } |
| 207 | 208 |
| 208 void AutofillAgent::textFieldDidChange(const WebInputElement& element) { | 209 void AutofillAgent::textFieldDidChange(const WebInputElement& element) { |
| 209 // We post a task for doing the Autofill as the caret position is not set | 210 // We post a task for doing the Autofill as the caret position is not set |
| 210 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and | 211 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and |
| 211 // it is needed to trigger autofill. | 212 // it is needed to trigger autofill. |
| 212 weak_ptr_factory_.InvalidateWeakPtrs(); | 213 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 213 MessageLoop::current()->PostTask( | 214 MessageLoop::current()->PostTask( |
| 214 FROM_HERE, | 215 FROM_HERE, |
| 215 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, | 216 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 408 |
| 408 webkit_glue::FormData form; | 409 webkit_glue::FormData form; |
| 409 webkit_glue::FormField field; | 410 webkit_glue::FormField field; |
| 410 if (!FindFormAndFieldForInputElement(element, &form, &field, | 411 if (!FindFormAndFieldForInputElement(element, &form, &field, |
| 411 REQUIRE_AUTOCOMPLETE)) { | 412 REQUIRE_AUTOCOMPLETE)) { |
| 412 // If we didn't find the cached form, at least let autocomplete have a shot | 413 // If we didn't find the cached form, at least let autocomplete have a shot |
| 413 // at providing suggestions. | 414 // at providing suggestions. |
| 414 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); | 415 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); |
| 415 } | 416 } |
| 416 | 417 |
| 417 Send(new AutofillHostMsg_QueryFormFieldAutofill( | 418 Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(), |
| 418 routing_id(), autofill_query_id_, form, field)); | 419 autofill_query_id_, |
| 420 form, |
| 421 field, |
| 422 display_warning_if_disabled)); |
| 419 } | 423 } |
| 420 | 424 |
| 421 void AutofillAgent::FillAutofillFormData(const WebNode& node, | 425 void AutofillAgent::FillAutofillFormData(const WebNode& node, |
| 422 int unique_id, | 426 int unique_id, |
| 423 AutofillAction action) { | 427 AutofillAction action) { |
| 424 static int query_counter = 0; | 428 static int query_counter = 0; |
| 425 autofill_query_id_ = query_counter++; | 429 autofill_query_id_ = query_counter++; |
| 426 | 430 |
| 427 webkit_glue::FormData form; | 431 webkit_glue::FormData form; |
| 428 webkit_glue::FormField field; | 432 webkit_glue::FormField field; |
| 429 if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, | 433 if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, |
| 430 &field, REQUIRE_AUTOCOMPLETE)) { | 434 &field, REQUIRE_AUTOCOMPLETE)) { |
| 431 return; | 435 return; |
| 432 } | 436 } |
| 433 | 437 |
| 434 autofill_action_ = action; | 438 autofill_action_ = action; |
| 435 was_query_node_autofilled_ = field.is_autofilled; | 439 was_query_node_autofilled_ = field.is_autofilled; |
| 436 Send(new AutofillHostMsg_FillAutofillFormData( | 440 Send(new AutofillHostMsg_FillAutofillFormData( |
| 437 routing_id(), autofill_query_id_, form, field, unique_id)); | 441 routing_id(), autofill_query_id_, form, field, unique_id)); |
| 438 } | 442 } |
| 439 | 443 |
| 440 } // namespace autofill | 444 } // namespace autofill |
| OLD | NEW |