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/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "components/autofill/content/common/autofill_messages.h" | 17 #include "components/autofill/content/common/autofill_messages.h" |
18 #include "components/autofill/content/renderer/form_autofill_util.h" | 18 #include "components/autofill/content/renderer/form_autofill_util.h" |
19 #include "components/autofill/content/renderer/page_click_tracker.h" | 19 #include "components/autofill/content/renderer/page_click_tracker.h" |
20 #include "components/autofill/content/renderer/password_autofill_agent.h" | 20 #include "components/autofill/content/renderer/password_autofill_agent.h" |
21 #include "components/autofill/content/renderer/password_generation_agent.h" | 21 #include "components/autofill/content/renderer/password_generation_agent.h" |
22 #include "components/autofill/core/common/autofill_constants.h" | 22 #include "components/autofill/core/common/autofill_constants.h" |
23 #include "components/autofill/core/common/autofill_data_validation.h" | 23 #include "components/autofill/core/common/autofill_data_validation.h" |
24 #include "components/autofill/core/common/autofill_switches.h" | 24 #include "components/autofill/core/common/autofill_switches.h" |
25 #include "components/autofill/core/common/autofill_util.h" | |
25 #include "components/autofill/core/common/form_data.h" | 26 #include "components/autofill/core/common/form_data.h" |
26 #include "components/autofill/core/common/form_data_predictions.h" | 27 #include "components/autofill/core/common/form_data_predictions.h" |
27 #include "components/autofill/core/common/form_field_data.h" | 28 #include "components/autofill/core/common/form_field_data.h" |
28 #include "components/autofill/core/common/password_form.h" | 29 #include "components/autofill/core/common/password_form.h" |
29 #include "components/autofill/core/common/web_element_descriptor.h" | 30 #include "components/autofill/core/common/web_element_descriptor.h" |
30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
31 #include "content/public/common/ssl_status.h" | 32 #include "content/public/common/ssl_status.h" |
32 #include "content/public/common/url_constants.h" | 33 #include "content/public/common/url_constants.h" |
33 #include "content/public/renderer/render_frame.h" | 34 #include "content/public/renderer/render_frame.h" |
34 #include "content/public/renderer/render_view.h" | 35 #include "content/public/renderer/render_view.h" |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 WebInputElement* node) { | 734 WebInputElement* node) { |
734 base::AutoReset<bool> auto_reset(&ignore_text_changes_, true); | 735 base::AutoReset<bool> auto_reset(&ignore_text_changes_, true); |
735 node->setEditingValue(value.substr(0, node->maxLength())); | 736 node->setEditingValue(value.substr(0, node->maxLength())); |
736 } | 737 } |
737 | 738 |
738 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, | 739 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
739 WebInputElement* node) { | 740 WebInputElement* node) { |
740 was_query_node_autofilled_ = element_.isAutofilled(); | 741 was_query_node_autofilled_ = element_.isAutofilled(); |
741 node->setSuggestedValue(value.substr(0, node->maxLength())); | 742 node->setSuggestedValue(value.substr(0, node->maxLength())); |
742 node->setAutofilled(true); | 743 node->setAutofilled(true); |
743 node->setSelectionRange(node->value().length(), | 744 |
744 node->suggestedValue().length()); | 745 if (IsFeatureSubstringMatchEnabled()) { |
please use gerrit instead
2015/06/28 00:43:03
You can inline this:
node->setSelectionRange(
Pritam Nikam
2015/06/29 15:38:21
Sure, I'll move this code restructuring under |Pre
please use gerrit instead
2015/06/29 17:06:45
Sounds good.
| |
746 size_t start = autofill::GetTextSelectionStart(value, node->value()); | |
747 node->setSelectionRange(start, node->suggestedValue().length()); | |
748 } else { | |
749 node->setSelectionRange(node->value().length(), | |
750 node->suggestedValue().length()); | |
751 } | |
745 } | 752 } |
746 | 753 |
747 void AutofillAgent::ProcessForms() { | 754 void AutofillAgent::ProcessForms() { |
748 // Record timestamp of when the forms are first seen. This is used to | 755 // Record timestamp of when the forms are first seen. This is used to |
749 // measure the overhead of the Autofill feature. | 756 // measure the overhead of the Autofill feature. |
750 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); | 757 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); |
751 | 758 |
752 WebLocalFrame* frame = render_frame()->GetWebFrame(); | 759 WebLocalFrame* frame = render_frame()->GetWebFrame(); |
753 std::vector<FormData> forms = form_cache_.ExtractNewForms(); | 760 std::vector<FormData> forms = form_cache_.ExtractNewForms(); |
754 | 761 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 | 812 |
806 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 813 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
807 // No-op. Don't delete |this|. | 814 // No-op. Don't delete |this|. |
808 } | 815 } |
809 | 816 |
810 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 817 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
811 agent_->FocusChangeComplete(); | 818 agent_->FocusChangeComplete(); |
812 } | 819 } |
813 | 820 |
814 } // namespace autofill | 821 } // namespace autofill |
OLD | NEW |