| 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..878634e5db895d953dce4293c57034b1a72f6bbd 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"
|
| @@ -130,6 +131,7 @@ AutofillAgent::AutofillAgent(
|
| was_query_node_autofilled_(false),
|
| has_shown_autofill_popup_for_current_edit_(false),
|
| did_set_node_text_(false),
|
| + has_requested_autocomplete_(false),
|
| ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
|
| render_view->GetWebView()->setAutofillClient(this);
|
| }
|
| @@ -157,6 +159,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 +215,30 @@ void AutofillAgent::DidChangeScrollOffset(WebKit::WebFrame*) {
|
| Send(new AutofillHostMsg_HideAutofillPopup(routing_id()));
|
| }
|
|
|
| +void AutofillAgent::didRequestAutocomplete(WebKit::WebFrame* frame,
|
| + const WebFormElement& form) {
|
| + if (has_requested_autocomplete_)
|
| + return;
|
| +
|
| + // Cancel any pending Autofill requests.
|
| + ++autofill_query_id_;
|
| +
|
| + // Any popup currently showing is obsolete.
|
| + HidePopups();
|
| +
|
| + FormData form_data;
|
| + if (WebFormElementToFormData(form,
|
| + WebFormControlElement(),
|
| + REQUIRE_AUTOCOMPLETE,
|
| + EXTRACT_NONE,
|
| + &form_data,
|
| + NULL)) {
|
| + form_ = form;
|
| + has_requested_autocomplete_ = true;
|
| + Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data));
|
| + }
|
| +}
|
| +
|
| bool AutofillAgent::InputElementClicked(const WebInputElement& element,
|
| bool was_focused,
|
| bool is_focused) {
|
| @@ -574,6 +602,16 @@ void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) {
|
| DCHECK(handled);
|
| }
|
|
|
| +void AutofillAgent::OnRequestAutocompleteFinished(int result) {
|
| + DCHECK(has_requested_autocomplete_);
|
| + has_requested_autocomplete_ = false;
|
| +
|
| + DCHECK_(result == WebFormElement::AutocompleteSuccess ||
|
| + result == WebFormElement::AutocompleteError);
|
| + form_.finishRequestAutocomplete(
|
| + static_cast<WebFormElement::AutocompleteResult>(result));
|
| +}
|
| +
|
| void AutofillAgent::ShowSuggestions(const WebInputElement& element,
|
| bool autofill_on_empty_values,
|
| bool requires_caret_at_end,
|
| @@ -591,10 +629,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 +729,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
|
|
|