Chromium Code Reviews| 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" |
| 11 #include "chrome/common/autofill_messages.h" | 11 #include "chrome/common/autofill_messages.h" |
| 12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
| 13 #include "chrome/renderer/autofill/form_autofill_util.h" | 13 #include "chrome/renderer/autofill/form_autofill_util.h" |
| 14 #include "chrome/renderer/autofill/password_autofill_manager.h" | 14 #include "chrome/renderer/autofill/password_autofill_manager.h" |
| 15 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
| 16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 23 #include "ui/base/keycodes/keyboard_codes.h" | 24 #include "ui/base/keycodes/keyboard_codes.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "webkit/glue/form_data.h" | 26 #include "webkit/glue/form_data.h" |
| 26 #include "webkit/glue/form_data_predictions.h" | 27 #include "webkit/glue/form_data_predictions.h" |
| 27 #include "webkit/glue/form_field.h" | 28 #include "webkit/glue/form_field.h" |
| 28 #include "webkit/glue/password_form.h" | 29 #include "webkit/glue/password_form.h" |
| 29 | 30 |
| 30 using WebKit::WebFormControlElement; | 31 using WebKit::WebFormControlElement; |
| 31 using WebKit::WebFormElement; | 32 using WebKit::WebFormElement; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 bool AutofillAgent::InputElementClicked(const WebInputElement& element, | 118 bool AutofillAgent::InputElementClicked(const WebInputElement& element, |
| 118 bool was_focused, | 119 bool was_focused, |
| 119 bool is_focused) { | 120 bool is_focused) { |
| 120 if (was_focused) | 121 if (was_focused) |
| 121 ShowSuggestions(element, true, false, true); | 122 ShowSuggestions(element, true, false, true); |
| 122 | 123 |
| 123 return false; | 124 return false; |
| 124 } | 125 } |
| 125 | 126 |
| 126 bool AutofillAgent::InputElementLostFocus() { | 127 bool AutofillAgent::InputElementLostFocus() { |
| 128 Send(new AutofillHostMsg_HideAutofillPopup(routing_id())); | |
| 129 | |
| 127 return false; | 130 return false; |
| 128 } | 131 } |
| 129 | 132 |
| 130 void AutofillAgent::didAcceptAutofillSuggestion(const WebNode& node, | 133 void AutofillAgent::didAcceptAutofillSuggestion(const WebNode& node, |
| 131 const WebString& value, | 134 const WebString& value, |
| 132 const WebString& label, | 135 const WebString& label, |
| 133 int unique_id, | 136 int unique_id, |
| 134 unsigned index) { | 137 unsigned index) { |
| 135 if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value)) | 138 if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value)) |
| 136 return; | 139 return; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 | 410 |
| 408 webkit_glue::FormData form; | 411 webkit_glue::FormData form; |
| 409 webkit_glue::FormField field; | 412 webkit_glue::FormField field; |
| 410 if (!FindFormAndFieldForInputElement(element, &form, &field, | 413 if (!FindFormAndFieldForInputElement(element, &form, &field, |
| 411 REQUIRE_AUTOCOMPLETE)) { | 414 REQUIRE_AUTOCOMPLETE)) { |
| 412 // If we didn't find the cached form, at least let autocomplete have a shot | 415 // If we didn't find the cached form, at least let autocomplete have a shot |
| 413 // at providing suggestions. | 416 // at providing suggestions. |
| 414 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); | 417 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); |
| 415 } | 418 } |
| 416 | 419 |
| 420 gfx::Rect bounding_box(autofill_query_element_.boundsInWindowSpace()); | |
|
Ilya Sherman
2011/11/17 02:29:23
So that you're not blocked by the WebKit work... H
| |
| 421 | |
| 417 Send(new AutofillHostMsg_QueryFormFieldAutofill( | 422 Send(new AutofillHostMsg_QueryFormFieldAutofill( |
| 418 routing_id(), autofill_query_id_, form, field)); | 423 routing_id(), autofill_query_id_, form, field, bounding_box)); |
| 419 } | 424 } |
| 420 | 425 |
| 421 void AutofillAgent::FillAutofillFormData(const WebNode& node, | 426 void AutofillAgent::FillAutofillFormData(const WebNode& node, |
| 422 int unique_id, | 427 int unique_id, |
| 423 AutofillAction action) { | 428 AutofillAction action) { |
| 424 static int query_counter = 0; | 429 static int query_counter = 0; |
| 425 autofill_query_id_ = query_counter++; | 430 autofill_query_id_ = query_counter++; |
| 426 | 431 |
| 427 webkit_glue::FormData form; | 432 webkit_glue::FormData form; |
| 428 webkit_glue::FormField field; | 433 webkit_glue::FormField field; |
| 429 if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, | 434 if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, |
| 430 &field, REQUIRE_AUTOCOMPLETE)) { | 435 &field, REQUIRE_AUTOCOMPLETE)) { |
| 431 return; | 436 return; |
| 432 } | 437 } |
| 433 | 438 |
| 434 autofill_action_ = action; | 439 autofill_action_ = action; |
| 435 was_query_node_autofilled_ = field.is_autofilled; | 440 was_query_node_autofilled_ = field.is_autofilled; |
| 436 Send(new AutofillHostMsg_FillAutofillFormData( | 441 Send(new AutofillHostMsg_FillAutofillFormData( |
| 437 routing_id(), autofill_query_id_, form, field, unique_id)); | 442 routing_id(), autofill_query_id_, form, field, unique_id)); |
| 438 } | 443 } |
| 439 | 444 |
| 440 } // namespace autofill | 445 } // namespace autofill |
| OLD | NEW |