Chromium Code Reviews| Index: chrome/renderer/autofill/autofill_agent.cc |
| diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc |
| index 8af890ab029926c37efce9cfb7d83c3699cd94ca..3bea16e293cdb3d5e92798e66b7a77acf3ca8893 100644 |
| --- a/chrome/renderer/autofill/autofill_agent.cc |
| +++ b/chrome/renderer/autofill/autofill_agent.cc |
| @@ -24,6 +24,7 @@ |
| #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| @@ -157,6 +158,8 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { |
| OnAcceptDataListSuggestion) |
| IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, |
| OnAcceptPasswordAutofillSuggestion) |
| + IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteFinished, |
| + OnRequestAutocompleteFinished) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| return handled; |
| @@ -211,6 +214,30 @@ void AutofillAgent::DidChangeScrollOffset(WebKit::WebFrame*) { |
| Send(new AutofillHostMsg_HideAutofillPopup(routing_id())); |
| } |
| +void AutofillAgent::didRequestAutocomplete(WebKit::WebFrame* frame, |
| + const WebFormElement& form) { |
| + FormData form_data; |
| + if (!form_.isNull() || |
| + !WebFormElementToFormData(form, |
| + WebFormControlElement(), |
| + REQUIRE_AUTOCOMPLETE, |
| + EXTRACT_NONE, |
| + &form_data, |
| + NULL)) { |
| + WebFormElement non_const_form(form); |
|
Ilya Sherman
2012/11/02 02:56:57
nit: Seems like we shouldn't be passing in a const
Dan Beam
2012/11/02 03:10:15
So I removed const but there were issues with this
Ilya Sherman
2012/11/02 03:24:45
What are the issues with removing const? I agree
Dan Beam
2012/11/02 22:37:55
So it looks like this is already being done every
Ilya Sherman
2012/11/02 22:47:36
No counter-examples that I'm aware of, no.
|
| + non_const_form.finishRequestAutocomplete( |
| + WebFormElement::AutocompleteResultError); |
| + return; |
| + } |
| + |
| + // Cancel any pending Autofill requests and hide any currently showing popups. |
| + ++autofill_query_id_; |
| + HidePopups(); |
| + |
| + form_ = form; |
| + Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data)); |
| +} |
| + |
| bool AutofillAgent::InputElementClicked(const WebInputElement& element, |
| bool was_focused, |
| bool is_focused) { |
| @@ -574,6 +601,15 @@ void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) { |
| DCHECK(handled); |
| } |
| +void AutofillAgent::OnRequestAutocompleteFinished( |
| + WebFormElement::AutocompleteResult result) { |
| + if (form_.isNull()) |
| + return; |
|
Ilya Sherman
2012/11/02 02:56:57
When can this happen?
Dan Beam
2012/11/02 03:10:15
I'd think it's possible that the form *could* be r
Ilya Sherman
2012/11/02 03:24:45
The form could be removed from the DOM, but I don'
Dan Beam
2012/11/02 21:06:08
True, I definitely think you're right here and res
|
| + |
| + form_.finishRequestAutocomplete(result); |
| + form_.reset(); |
| +} |
| + |
| void AutofillAgent::ShowSuggestions(const WebInputElement& element, |
| bool autofill_on_empty_values, |
| bool requires_caret_at_end, |
| @@ -591,10 +627,7 @@ void AutofillAgent::ShowSuggestions(const WebInputElement& element, |
| (element.selectionStart() != element.selectionEnd() || |
| element.selectionEnd() != static_cast<int>(value.length())))) { |
| // Any popup currently showing is obsolete. |
| - WebKit::WebView* web_view = render_view()->GetWebView(); |
| - if (web_view) |
| - web_view->hidePopups(); |
| - |
| + HidePopups(); |
| return; |
| } |
| @@ -694,4 +727,10 @@ void AutofillAgent::SetNodeText(const string16& value, |
| node->setEditingValue(substring); |
| } |
| +void AutofillAgent::HidePopups() { |
| + WebKit::WebView* web_view = render_view()->GetWebView(); |
| + if (web_view) |
| + web_view->hidePopups(); |
| +} |
| + |
| } // namespace autofill |