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

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

Issue 10443084: Add Datalist Support to New Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill, 119 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill,
120 OnSetAutofillActionFill) 120 OnSetAutofillActionFill)
121 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, 121 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm,
122 OnClearForm) 122 OnClearForm)
123 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview, 123 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview,
124 OnSetAutofillActionPreview) 124 OnSetAutofillActionPreview)
125 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, 125 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm,
126 OnClearPreviewedForm) 126 OnClearPreviewedForm)
127 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText, 127 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText,
128 OnSetNodeText) 128 OnSetNodeText)
129 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion,
130 OnAcceptDataListSuggestion)
129 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, 131 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion,
130 OnAcceptPasswordAutofillSuggestion) 132 OnAcceptPasswordAutofillSuggestion)
131 IPC_MESSAGE_UNHANDLED(handled = false) 133 IPC_MESSAGE_UNHANDLED(handled = false)
132 IPC_END_MESSAGE_MAP() 134 IPC_END_MESSAGE_MAP()
133 return handled; 135 return handled;
134 } 136 }
135 137
136 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { 138 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
137 // The document has now been fully loaded. Scan for forms to be sent up to 139 // The document has now been fully loaded. Scan for forms to be sent up to
138 // the browser. 140 // the browser.
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 524 }
523 525
524 void AutofillAgent::OnClearPreviewedForm() { 526 void AutofillAgent::OnClearPreviewedForm() {
525 didClearAutofillSelection(element_); 527 didClearAutofillSelection(element_);
526 } 528 }
527 529
528 void AutofillAgent::OnSetNodeText(const string16& value) { 530 void AutofillAgent::OnSetNodeText(const string16& value) {
529 SetNodeText(value, &element_); 531 SetNodeText(value, &element_);
530 } 532 }
531 533
534 void AutofillAgent::OnAcceptDataListSuggestion(const string16& value) {
535 AcceptDataListSuggestion(value);
536 }
537
532 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) { 538 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) {
533 // We need to make sure this is handled here because the browser process 539 // We need to make sure this is handled here because the browser process
534 // skipped it handling because it believed it would be handled here. If it 540 // skipped it handling because it believed it would be handled here. If it
535 // isn't handled here then the browser logic needs to be updated. 541 // isn't handled here then the browser logic needs to be updated.
536 bool handled = password_autofill_manager_->DidAcceptAutofillSuggestion( 542 bool handled = password_autofill_manager_->DidAcceptAutofillSuggestion(
537 element_, 543 element_,
538 value); 544 value);
539 DCHECK(handled); 545 DCHECK(handled);
540 } 546 }
541 547
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 webkit::forms::FormField field; 599 webkit::forms::FormField field;
594 if (!FindFormAndFieldForInputElement(element, &form, &field, 600 if (!FindFormAndFieldForInputElement(element, &form, &field,
595 REQUIRE_AUTOCOMPLETE)) { 601 REQUIRE_AUTOCOMPLETE)) {
596 // If we didn't find the cached form, at least let autocomplete have a shot 602 // If we didn't find the cached form, at least let autocomplete have a shot
597 // at providing suggestions. 603 // at providing suggestions.
598 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); 604 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field);
599 } 605 }
600 606
601 gfx::Rect bounding_box(element_.boundsInViewportSpace()); 607 gfx::Rect bounding_box(element_.boundsInViewportSpace());
602 608
609 // Find the datalist values and send them to the the browser process.
Ilya Sherman 2012/06/06 22:25:45 nit: "the the" -> "the"
csharp 2012/06/07 14:57:43 Done.
610 std::vector<string16> data_list_values;
611 std::vector<string16> data_list_labels;
612 std::vector<string16> data_list_icons;
613 std::vector<int> data_list_unique_ids;
614 AppendDataListSuggestions(element_,
615 &data_list_values,
616 &data_list_labels,
617 &data_list_icons,
618 &data_list_unique_ids);
619
620 Send(new AutofillHostMsg_SetDataList(routing_id(),
621 data_list_values,
622 data_list_labels,
623 data_list_icons,
624 data_list_unique_ids));
Ilya Sherman 2012/06/06 22:25:45 To avoid the potential for DOS, we should limit th
csharp 2012/06/07 14:57:43 Done, I set the limit to 30. I don't have any real
Ilya Sherman 2012/06/07 22:56:05 Thanks, 30 seems reasonable to me. We can always
625
603 Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(), 626 Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(),
604 autofill_query_id_, 627 autofill_query_id_,
605 form, 628 form,
606 field, 629 field,
607 bounding_box, 630 bounding_box,
608 display_warning_if_disabled)); 631 display_warning_if_disabled));
609 } 632 }
610 633
611 void AutofillAgent::FillAutofillFormData(const WebNode& node, 634 void AutofillAgent::FillAutofillFormData(const WebNode& node,
612 int unique_id, 635 int unique_id,
(...skipping 18 matching lines...) Expand all
631 void AutofillAgent::SetNodeText(const string16& value, 654 void AutofillAgent::SetNodeText(const string16& value,
632 WebKit::WebInputElement* node) { 655 WebKit::WebInputElement* node) {
633 did_set_node_text_ = true; 656 did_set_node_text_ = true;
634 string16 substring = value; 657 string16 substring = value;
635 substring = substring.substr(0, node->maxLength()); 658 substring = substring.substr(0, node->maxLength());
636 659
637 node->setEditingValue(substring); 660 node->setEditingValue(substring);
638 } 661 }
639 662
640 } // namespace autofill 663 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698