Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4705)

Unified Diff: chrome/renderer/autofill/autofill_agent.cc

Issue 11270018: [autofill] Adding new API to request an interactive autocomplete UI flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: smaller codez == better codez Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/autofill/autofill_agent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..759886980fac2dd5df10c5440e2a570839d725a6 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,29 @@ void AutofillAgent::DidChangeScrollOffset(WebKit::WebFrame*) {
Send(new AutofillHostMsg_HideAutofillPopup(routing_id()));
}
+void AutofillAgent::didRequestAutocomplete(WebKit::WebFrame* frame,
+ const WebFormElement& form) {
+ FormData form_data;
+ if (!in_flight_request_form_.isNull() ||
+ !WebFormElementToFormData(form,
+ WebFormControlElement(),
+ REQUIRE_AUTOCOMPLETE,
+ EXTRACT_NONE,
+ &form_data,
+ NULL)) {
+ WebFormElement(form).finishRequestAutocomplete(
+ WebFormElement::AutocompleteResultError);
+ return;
+ }
+
+ // Cancel any pending Autofill requests and hide any currently showing popups.
+ ++autofill_query_id_;
+ HidePopups();
+
+ in_flight_request_form_ = form;
+ Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data));
+}
+
bool AutofillAgent::InputElementClicked(const WebInputElement& element,
bool was_focused,
bool is_focused) {
@@ -574,6 +600,14 @@ void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) {
DCHECK(handled);
}
+void AutofillAgent::OnRequestAutocompleteFinished(
+ WebFormElement::AutocompleteResult result) {
+ DCHECK(!in_flight_request_form_.isNull());
+
+ in_flight_request_form_.finishRequestAutocomplete(result);
+ in_flight_request_form_.reset();
+}
+
void AutofillAgent::ShowSuggestions(const WebInputElement& element,
bool autofill_on_empty_values,
bool requires_caret_at_end,
@@ -591,10 +625,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 +725,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
« no previous file with comments | « chrome/renderer/autofill/autofill_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698