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

Side by Side Diff: chrome/renderer/autofill/autofill_agent.cc

Issue 11821020: Chrome-side implementation of AutocompleteErrorEvent#reason. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/autofill/autofill_agent.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview, 153 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview,
154 OnSetAutofillActionPreview) 154 OnSetAutofillActionPreview)
155 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, 155 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm,
156 OnClearPreviewedForm) 156 OnClearPreviewedForm)
157 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText, 157 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText,
158 OnSetNodeText) 158 OnSetNodeText)
159 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, 159 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion,
160 OnAcceptDataListSuggestion) 160 OnAcceptDataListSuggestion)
161 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, 161 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion,
162 OnAcceptPasswordAutofillSuggestion) 162 OnAcceptPasswordAutofillSuggestion)
163 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteSuccess, 163 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult,
164 OnRequestAutocompleteSuccess) 164 OnRequestAutocompleteResult)
165 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteError,
166 OnRequestAutocompleteError)
167 IPC_MESSAGE_UNHANDLED(handled = false) 165 IPC_MESSAGE_UNHANDLED(handled = false)
168 IPC_END_MESSAGE_MAP() 166 IPC_END_MESSAGE_MAP()
169 return handled; 167 return handled;
170 } 168 }
171 169
172 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { 170 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
173 // The document has now been fully loaded. Scan for forms to be sent up to 171 // The document has now been fully loaded. Scan for forms to be sent up to
174 // the browser. 172 // the browser.
175 std::vector<FormData> forms; 173 std::vector<FormData> forms;
176 form_cache_.ExtractForms(*frame, &forms); 174 form_cache_.ExtractForms(*frame, &forms);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 const WebFormElement& form) { 217 const WebFormElement& form) {
220 FormData form_data; 218 FormData form_data;
221 if (!in_flight_request_form_.isNull() || 219 if (!in_flight_request_form_.isNull() ||
222 !WebFormElementToFormData(form, 220 !WebFormElementToFormData(form,
223 WebFormControlElement(), 221 WebFormControlElement(),
224 REQUIRE_AUTOCOMPLETE, 222 REQUIRE_AUTOCOMPLETE,
225 EXTRACT_OPTIONS, 223 EXTRACT_OPTIONS,
226 &form_data, 224 &form_data,
227 NULL)) { 225 NULL)) {
228 WebFormElement(form).finishRequestAutocomplete( 226 WebFormElement(form).finishRequestAutocomplete(
229 WebFormElement::AutocompleteResultError); 227 WebFormElement::AutocompleteResultErrorDisabled);
230 return; 228 return;
231 } 229 }
232 230
233 // Cancel any pending Autofill requests and hide any currently showing popups. 231 // Cancel any pending Autofill requests and hide any currently showing popups.
234 ++autofill_query_id_; 232 ++autofill_query_id_;
235 HidePopups(); 233 HidePopups();
236 234
237 in_flight_request_form_ = form; 235 in_flight_request_form_ = form;
238 Send(new AutofillHostMsg_RequestAutocomplete( 236 Send(new AutofillHostMsg_RequestAutocomplete(
239 routing_id(), 237 routing_id(),
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) { 593 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) {
596 // We need to make sure this is handled here because the browser process 594 // We need to make sure this is handled here because the browser process
597 // skipped it handling because it believed it would be handled here. If it 595 // skipped it handling because it believed it would be handled here. If it
598 // isn't handled here then the browser logic needs to be updated. 596 // isn't handled here then the browser logic needs to be updated.
599 bool handled = password_autofill_manager_->DidAcceptAutofillSuggestion( 597 bool handled = password_autofill_manager_->DidAcceptAutofillSuggestion(
600 element_, 598 element_,
601 value); 599 value);
602 DCHECK(handled); 600 DCHECK(handled);
603 } 601 }
604 602
605 void AutofillAgent::FinishAutocompleteRequest( 603 void AutofillAgent::OnRequestAutocompleteResult(
606 WebFormElement::AutocompleteResult result) { 604 WebFormElement::AutocompleteResult result, const FormData& form_data) {
607 DCHECK(!in_flight_request_form_.isNull()); 605 DCHECK(!in_flight_request_form_.isNull());
606 if (result == WebFormElement::AutocompleteResultSuccess)
607 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_);
608 in_flight_request_form_.finishRequestAutocomplete(result); 608 in_flight_request_form_.finishRequestAutocomplete(result);
609 in_flight_request_form_.reset(); 609 in_flight_request_form_.reset();
610 } 610 }
611 611
612 void AutofillAgent::OnRequestAutocompleteSuccess(const FormData& form_data) {
613 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_);
614 FinishAutocompleteRequest(WebFormElement::AutocompleteResultSuccess);
615 }
616
617 void AutofillAgent::OnRequestAutocompleteError() {
618 FinishAutocompleteRequest(WebFormElement::AutocompleteResultError);
619 }
620
621 void AutofillAgent::ShowSuggestions(const WebInputElement& element, 612 void AutofillAgent::ShowSuggestions(const WebInputElement& element,
622 bool autofill_on_empty_values, 613 bool autofill_on_empty_values,
623 bool requires_caret_at_end, 614 bool requires_caret_at_end,
624 bool display_warning_if_disabled) { 615 bool display_warning_if_disabled) {
625 if (!element.isEnabled() || element.isReadOnly() || !element.isTextField() || 616 if (!element.isEnabled() || element.isReadOnly() || !element.isTextField() ||
626 element.isPasswordField() || !element.suggestedValue().isEmpty()) 617 element.isPasswordField() || !element.suggestedValue().isEmpty())
627 return; 618 return;
628 619
629 // Don't attempt to autofill with values that are too large or if filling 620 // Don't attempt to autofill with values that are too large or if filling
630 // criteria are not met. 621 // criteria are not met.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 web_view->hidePopups(); 745 web_view->hidePopups();
755 746
756 HideHostPopups(); 747 HideHostPopups();
757 } 748 }
758 749
759 void AutofillAgent::HideHostPopups() { 750 void AutofillAgent::HideHostPopups() {
760 Send(new AutofillHostMsg_HideAutofillPopup(routing_id())); 751 Send(new AutofillHostMsg_HideAutofillPopup(routing_id()));
761 } 752 }
762 753
763 } // namespace autofill 754 } // namespace autofill
OLDNEW
« 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