| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 suggestions_clear_index_--; | 199 suggestions_clear_index_--; |
| 200 if (suggestions_options_index_ != -1) | 200 if (suggestions_options_index_ != -1) |
| 201 suggestions_options_index_--; | 201 suggestions_options_index_--; |
| 202 | 202 |
| 203 Send(new AutofillHostMsg_RemoveAutocompleteEntry(routing_id(), name, value)); | 203 Send(new AutofillHostMsg_RemoveAutocompleteEntry(routing_id(), name, value)); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { | 206 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
| 207 password_autofill_manager_->TextFieldDidEndEditing(element); | 207 password_autofill_manager_->TextFieldDidEndEditing(element); |
| 208 has_shown_autofill_popup_for_current_edit_ = false; | 208 has_shown_autofill_popup_for_current_edit_ = false; |
| 209 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); |
| 209 } | 210 } |
| 210 | 211 |
| 211 void AutofillAgent::textFieldDidChange(const WebInputElement& element) { | 212 void AutofillAgent::textFieldDidChange(const WebInputElement& element) { |
| 212 // We post a task for doing the Autofill as the caret position is not set | 213 // We post a task for doing the Autofill as the caret position is not set |
| 213 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and | 214 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and |
| 214 // it is needed to trigger autofill. | 215 // it is needed to trigger autofill. |
| 215 weak_ptr_factory_.InvalidateWeakPtrs(); | 216 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 216 MessageLoop::current()->PostTask( | 217 MessageLoop::current()->PostTask( |
| 217 FROM_HERE, | 218 FROM_HERE, |
| 218 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, | 219 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 // If we didn't find the cached form, at least let autocomplete have a shot | 416 // If we didn't find the cached form, at least let autocomplete have a shot |
| 416 // at providing suggestions. | 417 // at providing suggestions. |
| 417 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); | 418 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); |
| 418 } | 419 } |
| 419 | 420 |
| 420 // TODO(csharp): Stop using the hardcoded value once the WebKit change to | 421 // TODO(csharp): Stop using the hardcoded value once the WebKit change to |
| 421 // expose the position lands. | 422 // expose the position lands. |
| 422 // gfx::Rect bounding_box(autofill_query_element_.boundsInRootViewSpace()); | 423 // gfx::Rect bounding_box(autofill_query_element_.boundsInRootViewSpace()); |
| 423 gfx::Rect bounding_box(26, 51, 155, 22); | 424 gfx::Rect bounding_box(26, 51, 155, 22); |
| 424 | 425 |
| 425 Send(new AutofillHostMsg_QueryFormFieldAutofill( | 426 Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(), |
| 426 routing_id(), autofill_query_id_, form, field, bounding_box)); | 427 autofill_query_id_, |
| 428 form, |
| 429 field, |
| 430 bounding_box, |
| 431 display_warning_if_disabled)); |
| 427 } | 432 } |
| 428 | 433 |
| 429 void AutofillAgent::FillAutofillFormData(const WebNode& node, | 434 void AutofillAgent::FillAutofillFormData(const WebNode& node, |
| 430 int unique_id, | 435 int unique_id, |
| 431 AutofillAction action) { | 436 AutofillAction action) { |
| 432 static int query_counter = 0; | 437 static int query_counter = 0; |
| 433 autofill_query_id_ = query_counter++; | 438 autofill_query_id_ = query_counter++; |
| 434 | 439 |
| 435 webkit_glue::FormData form; | 440 webkit_glue::FormData form; |
| 436 webkit_glue::FormField field; | 441 webkit_glue::FormField field; |
| 437 if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, | 442 if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, |
| 438 &field, REQUIRE_AUTOCOMPLETE)) { | 443 &field, REQUIRE_AUTOCOMPLETE)) { |
| 439 return; | 444 return; |
| 440 } | 445 } |
| 441 | 446 |
| 442 autofill_action_ = action; | 447 autofill_action_ = action; |
| 443 was_query_node_autofilled_ = field.is_autofilled; | 448 was_query_node_autofilled_ = field.is_autofilled; |
| 444 Send(new AutofillHostMsg_FillAutofillFormData( | 449 Send(new AutofillHostMsg_FillAutofillFormData( |
| 445 routing_id(), autofill_query_id_, form, field, unique_id)); | 450 routing_id(), autofill_query_id_, form, field, unique_id)); |
| 446 } | 451 } |
| 447 | 452 |
| 448 } // namespace autofill | 453 } // namespace autofill |
| OLD | NEW |