OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/content/renderer/autofill_agent.h" | 5 #include "components/autofill/content/renderer/autofill_agent.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 did_set_node_text_ = true; | 594 did_set_node_text_ = true; |
595 node->setEditingValue(value.substr(0, node->maxLength())); | 595 node->setEditingValue(value.substr(0, node->maxLength())); |
596 node->setAutofilled(true); | 596 node->setAutofilled(true); |
597 } | 597 } |
598 | 598 |
599 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, | 599 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
600 WebInputElement* node) { | 600 WebInputElement* node) { |
601 was_query_node_autofilled_ = element_.isAutofilled(); | 601 was_query_node_autofilled_ = element_.isAutofilled(); |
602 node->setSuggestedValue(value.substr(0, node->maxLength())); | 602 node->setSuggestedValue(value.substr(0, node->maxLength())); |
603 node->setAutofilled(true); | 603 node->setAutofilled(true); |
| 604 node->setSelectionRange(node->value().length(), |
| 605 node->suggestedValue().length()); |
604 } | 606 } |
605 | 607 |
606 void AutofillAgent::HidePopup() { | 608 void AutofillAgent::HidePopup() { |
607 if (!is_popup_possibly_visible_) | 609 if (!is_popup_possibly_visible_) |
608 return; | 610 return; |
609 | 611 |
610 if (!element_.isNull()) | 612 if (!element_.isNull()) |
611 OnClearPreviewedForm(); | 613 OnClearPreviewedForm(); |
612 | 614 |
613 is_popup_possibly_visible_ = false; | 615 is_popup_possibly_visible_ = false; |
614 Send(new AutofillHostMsg_HidePopup(routing_id())); | 616 Send(new AutofillHostMsg_HidePopup(routing_id())); |
615 } | 617 } |
616 | 618 |
617 // TODO(isherman): Decide if we want to support non-password autofill with AJAX. | 619 // TODO(isherman): Decide if we want to support non-password autofill with AJAX. |
618 void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) { | 620 void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) { |
619 for (size_t i = 0; i < nodes.size(); ++i) { | 621 for (size_t i = 0; i < nodes.size(); ++i) { |
620 WebFrame* frame = nodes[i].document().frame(); | 622 WebFrame* frame = nodes[i].document().frame(); |
621 // Only monitors dynamic forms created in the top frame. Dynamic forms | 623 // Only monitors dynamic forms created in the top frame. Dynamic forms |
622 // inserted in iframes are not captured yet. | 624 // inserted in iframes are not captured yet. |
623 if (frame && !frame->parent()) { | 625 if (frame && !frame->parent()) { |
624 password_autofill_agent_->OnDynamicFormsSeen(frame); | 626 password_autofill_agent_->OnDynamicFormsSeen(frame); |
625 return; | 627 return; |
626 } | 628 } |
627 } | 629 } |
628 } | 630 } |
629 | 631 |
630 } // namespace autofill | 632 } // namespace autofill |
OLD | NEW |