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

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

Issue 11348273: [autofill] Fill in values on a successful run of interactive autocomplete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: estade@ review 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') | chrome/renderer/autofill/form_autofill_util.h » ('j') | 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 69fd3ede8c5a02cb4a157d8105c24e55ad0d1cd8..d40e90d3e360f2eb35ba8774b15aa3dd5a0011f2 100644
--- a/chrome/renderer/autofill/autofill_agent.cc
+++ b/chrome/renderer/autofill/autofill_agent.cc
@@ -158,8 +158,10 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) {
OnAcceptDataListSuggestion)
IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion,
OnAcceptPasswordAutofillSuggestion)
- IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteFinished,
- OnRequestAutocompleteFinished)
+ IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteSuccess,
+ OnRequestAutocompleteSuccess)
+ IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteError,
+ OnRequestAutocompleteError)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -331,8 +333,8 @@ void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) {
void AutofillAgent::textFieldDidChange(const WebInputElement& element) {
if (did_set_node_text_) {
- did_set_node_text_ = false;
- return;
+ did_set_node_text_ = false;
+ return;
}
// We post a task for doing the Autofill as the caret position is not set
@@ -589,11 +591,42 @@ void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) {
DCHECK(handled);
}
-void AutofillAgent::OnRequestAutocompleteFinished(
- WebFormElement::AutocompleteResult result) {
+void AutofillAgent::OnRequestAutocompleteSuccess(const FormData& form_data) {
DCHECK(!in_flight_request_form_.isNull());
- in_flight_request_form_.finishRequestAutocomplete(result);
+ std::vector<WebKit::WebFormControlElement> elements;
+ autofill::ExtractAutofillableElements(in_flight_request_form_,
+ REQUIRE_AUTOCOMPLETE,
+ &elements);
+
+ for (size_t i = 0; i < form_data.fields.size(); ++i) {
+ const FormFieldData field = form_data.fields[i];
Evan Stade 2012/11/29 00:38:56 this should be const ref.
Dan Beam 2012/11/29 03:48:29 Done.
+
+ // TODO(dbeam): change to DCHECK() if values must be non-empty to confirm.
+ if (field.value.empty())
+ continue;
+
+ const std::string field_attr_lower =
+ StringToLowerASCII(field.autocomplete_attribute);
+ for (size_t j = 0; j < elements.size(); ++j) {
+ const std::string element_attr =
+ UTF16ToASCII(elements[j].getAttribute("autocomplete"));
Dan Beam 2012/11/29 01:05:48 double check that this is ASCII before converting
Dan Beam 2012/11/29 03:48:29 Done.
+ if (field_attr_lower == StringToLowerASCII(element_attr)) {
Evan Stade 2012/11/29 00:38:56 use LowerCaseEqualsASCII?
Dan Beam 2012/11/29 03:48:29 Done.
+ autofill::FillFormField(&elements[j], &field, false);
Evan Stade 2012/11/29 00:38:56 FillFormField's second param should be a const ref
Dan Beam 2012/11/29 03:48:29 Done.
+ break;
+ }
+ }
+ }
+
+ in_flight_request_form_.finishRequestAutocomplete(
+ WebFormElement::AutocompleteResultSuccess);
+ in_flight_request_form_.reset();
+}
+
+void AutofillAgent::OnRequestAutocompleteError() {
+ DCHECK(!in_flight_request_form_.isNull());
+ in_flight_request_form_.finishRequestAutocomplete(
+ WebFormElement::AutocompleteResultError);
in_flight_request_form_.reset();
}
« no previous file with comments | « chrome/renderer/autofill/autofill_agent.h ('k') | chrome/renderer/autofill/form_autofill_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698