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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "components/autofill/content/common/autofill_messages.h" | 14 #include "components/autofill/content/common/autofill_messages.h" |
15 #include "components/autofill/content/renderer/form_autofill_util.h" | 15 #include "components/autofill/content/renderer/form_autofill_util.h" |
16 #include "components/autofill/content/renderer/page_click_tracker.h" | 16 #include "components/autofill/content/renderer/page_click_tracker.h" |
17 #include "components/autofill/content/renderer/password_autofill_agent.h" | 17 #include "components/autofill/content/renderer/password_autofill_agent.h" |
18 #include "components/autofill/content/renderer/password_generation_agent.h" | 18 #include "components/autofill/content/renderer/password_generation_agent.h" |
19 #include "components/autofill/core/common/autofill_constants.h" | 19 #include "components/autofill/core/common/autofill_constants.h" |
20 #include "components/autofill/core/common/autofill_data_validation.h" | 20 #include "components/autofill/core/common/autofill_data_validation.h" |
21 #include "components/autofill/core/common/autofill_switches.h" | 21 #include "components/autofill/core/common/autofill_switches.h" |
22 #include "components/autofill/core/common/autofill_util.h" | |
22 #include "components/autofill/core/common/form_data.h" | 23 #include "components/autofill/core/common/form_data.h" |
23 #include "components/autofill/core/common/form_data_predictions.h" | 24 #include "components/autofill/core/common/form_data_predictions.h" |
24 #include "components/autofill/core/common/form_field_data.h" | 25 #include "components/autofill/core/common/form_field_data.h" |
25 #include "components/autofill/core/common/password_form.h" | 26 #include "components/autofill/core/common/password_form.h" |
26 #include "components/autofill/core/common/web_element_descriptor.h" | 27 #include "components/autofill/core/common/web_element_descriptor.h" |
27 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
28 #include "content/public/common/ssl_status.h" | 29 #include "content/public/common/ssl_status.h" |
29 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
30 #include "content/public/renderer/render_frame.h" | 31 #include "content/public/renderer/render_frame.h" |
31 #include "content/public/renderer/render_view.h" | 32 #include "content/public/renderer/render_view.h" |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
716 WebInputElement* node) { | 717 WebInputElement* node) { |
717 did_set_node_text_ = true; | 718 did_set_node_text_ = true; |
718 node->setEditingValue(value.substr(0, node->maxLength())); | 719 node->setEditingValue(value.substr(0, node->maxLength())); |
719 } | 720 } |
720 | 721 |
721 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, | 722 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
722 WebInputElement* node) { | 723 WebInputElement* node) { |
723 was_query_node_autofilled_ = element_.isAutofilled(); | 724 was_query_node_autofilled_ = element_.isAutofilled(); |
724 node->setSuggestedValue(value.substr(0, node->maxLength())); | 725 node->setSuggestedValue(value.substr(0, node->maxLength())); |
725 node->setAutofilled(true); | 726 node->setAutofilled(true); |
726 node->setSelectionRange(node->value().length(), | 727 |
727 node->suggestedValue().length()); | 728 if (IsFeatureSubstringMatchEnabled()) { |
729 size_t start = autofill::GetTextSelectionStart(value, node->value()); | |
730 if (start != base::string16::npos) { | |
Evan Stade
2015/04/27 19:25:21
no curlies
Pritam Nikam
2015/04/28 14:45:55
Done.
| |
731 node->setSelectionRange(start, node->suggestedValue().length()); | |
732 } | |
733 } else { | |
734 node->setSelectionRange(node->value().length(), | |
735 node->suggestedValue().length()); | |
736 } | |
728 } | 737 } |
729 | 738 |
730 void AutofillAgent::ProcessForms() { | 739 void AutofillAgent::ProcessForms() { |
731 // Record timestamp of when the forms are first seen. This is used to | 740 // Record timestamp of when the forms are first seen. This is used to |
732 // measure the overhead of the Autofill feature. | 741 // measure the overhead of the Autofill feature. |
733 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); | 742 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); |
734 | 743 |
735 WebLocalFrame* frame = render_frame()->GetWebFrame(); | 744 WebLocalFrame* frame = render_frame()->GetWebFrame(); |
736 std::vector<FormData> forms = form_cache_.ExtractNewForms(); | 745 std::vector<FormData> forms = form_cache_.ExtractNewForms(); |
737 | 746 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 | 792 |
784 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 793 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
785 // No-op. Don't delete |this|. | 794 // No-op. Don't delete |this|. |
786 } | 795 } |
787 | 796 |
788 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 797 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
789 agent_->FocusChangeComplete(); | 798 agent_->FocusChangeComplete(); |
790 } | 799 } |
791 | 800 |
792 } // namespace autofill | 801 } // namespace autofill |
OLD | NEW |