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

Side by Side 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: isherman@ review Created 8 years 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
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_util.h" 9 #include "base/string_util.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview, 151 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview,
152 OnSetAutofillActionPreview) 152 OnSetAutofillActionPreview)
153 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, 153 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm,
154 OnClearPreviewedForm) 154 OnClearPreviewedForm)
155 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText, 155 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText,
156 OnSetNodeText) 156 OnSetNodeText)
157 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, 157 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion,
158 OnAcceptDataListSuggestion) 158 OnAcceptDataListSuggestion)
159 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, 159 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion,
160 OnAcceptPasswordAutofillSuggestion) 160 OnAcceptPasswordAutofillSuggestion)
161 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteFinished, 161 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteSuccess,
162 OnRequestAutocompleteFinished) 162 OnRequestAutocompleteSuccess)
163 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteError,
164 OnRequestAutocompleteError)
163 IPC_MESSAGE_UNHANDLED(handled = false) 165 IPC_MESSAGE_UNHANDLED(handled = false)
164 IPC_END_MESSAGE_MAP() 166 IPC_END_MESSAGE_MAP()
165 return handled; 167 return handled;
166 } 168 }
167 169
168 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { 170 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
169 // 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
170 // the browser. 172 // the browser.
171 std::vector<FormData> forms; 173 std::vector<FormData> forms;
172 form_cache_.ExtractForms(*frame, &forms); 174 form_cache_.ExtractForms(*frame, &forms);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 326 }
325 327
326 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { 328 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) {
327 password_autofill_manager_->TextFieldDidEndEditing(element); 329 password_autofill_manager_->TextFieldDidEndEditing(element);
328 has_shown_autofill_popup_for_current_edit_ = false; 330 has_shown_autofill_popup_for_current_edit_ = false;
329 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); 331 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id()));
330 } 332 }
331 333
332 void AutofillAgent::textFieldDidChange(const WebInputElement& element) { 334 void AutofillAgent::textFieldDidChange(const WebInputElement& element) {
333 if (did_set_node_text_) { 335 if (did_set_node_text_) {
334 did_set_node_text_ = false; 336 did_set_node_text_ = false;
335 return; 337 return;
336 } 338 }
337 339
338 // We post a task for doing the Autofill as the caret position is not set 340 // We post a task for doing the Autofill as the caret position is not set
339 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and 341 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and
340 // it is needed to trigger autofill. 342 // it is needed to trigger autofill.
341 weak_ptr_factory_.InvalidateWeakPtrs(); 343 weak_ptr_factory_.InvalidateWeakPtrs();
342 MessageLoop::current()->PostTask( 344 MessageLoop::current()->PostTask(
343 FROM_HERE, 345 FROM_HERE,
344 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, 346 base::Bind(&AutofillAgent::TextFieldDidChangeImpl,
345 weak_ptr_factory_.GetWeakPtr(), element)); 347 weak_ptr_factory_.GetWeakPtr(), element));
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) { 584 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) {
583 // We need to make sure this is handled here because the browser process 585 // We need to make sure this is handled here because the browser process
584 // skipped it handling because it believed it would be handled here. If it 586 // skipped it handling because it believed it would be handled here. If it
585 // isn't handled here then the browser logic needs to be updated. 587 // isn't handled here then the browser logic needs to be updated.
586 bool handled = password_autofill_manager_->DidAcceptAutofillSuggestion( 588 bool handled = password_autofill_manager_->DidAcceptAutofillSuggestion(
587 element_, 589 element_,
588 value); 590 value);
589 DCHECK(handled); 591 DCHECK(handled);
590 } 592 }
591 593
592 void AutofillAgent::OnRequestAutocompleteFinished( 594 void AutofillAgent::FinishAutocompleteRequest(
593 WebFormElement::AutocompleteResult result) { 595 WebFormElement::AutocompleteResult result) {
594 DCHECK(!in_flight_request_form_.isNull()); 596 DCHECK(!in_flight_request_form_.isNull());
595
596 in_flight_request_form_.finishRequestAutocomplete(result); 597 in_flight_request_form_.finishRequestAutocomplete(result);
597 in_flight_request_form_.reset(); 598 in_flight_request_form_.reset();
598 } 599 }
599 600
601 void AutofillAgent::OnRequestAutocompleteSuccess(const FormData& form_data) {
602 FillFormAndNonFocusableElements(form_data, in_flight_request_form_);
603 FinishAutocompleteRequest(WebFormElement::AutocompleteResultSuccess);
604 }
605
606 void AutofillAgent::OnRequestAutocompleteError() {
607 FinishAutocompleteRequest(WebFormElement::AutocompleteResultError);
608 }
609
600 void AutofillAgent::ShowSuggestions(const WebInputElement& element, 610 void AutofillAgent::ShowSuggestions(const WebInputElement& element,
601 bool autofill_on_empty_values, 611 bool autofill_on_empty_values,
602 bool requires_caret_at_end, 612 bool requires_caret_at_end,
603 bool display_warning_if_disabled) { 613 bool display_warning_if_disabled) {
604 if (!element.isEnabled() || element.isReadOnly() || !element.isTextField() || 614 if (!element.isEnabled() || element.isReadOnly() || !element.isTextField() ||
605 element.isPasswordField() || !element.suggestedValue().isEmpty()) 615 element.isPasswordField() || !element.suggestedValue().isEmpty())
606 return; 616 return;
607 617
608 // Don't attempt to autofill with values that are too large or if filling 618 // Don't attempt to autofill with values that are too large or if filling
609 // criteria are not met. 619 // criteria are not met.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 web_view->hidePopups(); 743 web_view->hidePopups();
734 744
735 HideHostPopups(); 745 HideHostPopups();
736 } 746 }
737 747
738 void AutofillAgent::HideHostPopups() { 748 void AutofillAgent::HideHostPopups() {
739 Send(new AutofillHostMsg_HideAutofillPopup(routing_id())); 749 Send(new AutofillHostMsg_HideAutofillPopup(routing_id()));
740 } 750 }
741 751
742 } // namespace autofill 752 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698