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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 WebInputElement* node) { | 759 WebInputElement* node) { |
759 did_set_node_text_ = true; | 760 did_set_node_text_ = true; |
760 node->setEditingValue(value.substr(0, node->maxLength())); | 761 node->setEditingValue(value.substr(0, node->maxLength())); |
761 } | 762 } |
762 | 763 |
763 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, | 764 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
764 WebInputElement* node) { | 765 WebInputElement* node) { |
765 was_query_node_autofilled_ = element_.isAutofilled(); | 766 was_query_node_autofilled_ = element_.isAutofilled(); |
766 node->setSuggestedValue(value.substr(0, node->maxLength())); | 767 node->setSuggestedValue(value.substr(0, node->maxLength())); |
767 node->setAutofilled(true); | 768 node->setAutofilled(true); |
768 node->setSelectionRange(node->value().length(), | 769 |
769 node->suggestedValue().length()); | 770 if (IsFeatureSubStringMatchEnabled()) { |
| 771 size_t start = 0, end = 0; |
| 772 if (base::string16::npos != |
| 773 ComputeRange(value, node->value(), &start, &end)) { |
| 774 node->setSelectionRange(start, end); |
| 775 } |
| 776 } else { |
| 777 node->setSelectionRange(node->value().length(), |
| 778 node->suggestedValue().length()); |
| 779 } |
770 } | 780 } |
771 | 781 |
772 void AutofillAgent::ProcessForms() { | 782 void AutofillAgent::ProcessForms() { |
773 // Record timestamp of when the forms are first seen. This is used to | 783 // Record timestamp of when the forms are first seen. This is used to |
774 // measure the overhead of the Autofill feature. | 784 // measure the overhead of the Autofill feature. |
775 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); | 785 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); |
776 | 786 |
777 WebLocalFrame* frame = render_frame()->GetWebFrame(); | 787 WebLocalFrame* frame = render_frame()->GetWebFrame(); |
778 std::vector<FormData> forms = form_cache_.ExtractNewForms(); | 788 std::vector<FormData> forms = form_cache_.ExtractNewForms(); |
779 | 789 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 | 831 |
822 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 832 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
823 // No-op. Don't delete |this|. | 833 // No-op. Don't delete |this|. |
824 } | 834 } |
825 | 835 |
826 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 836 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
827 agent_->FocusChangeComplete(); | 837 agent_->FocusChangeComplete(); |
828 } | 838 } |
829 | 839 |
830 } // namespace autofill | 840 } // namespace autofill |
OLD | NEW |