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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
723 WebInputElement* node) { | 724 WebInputElement* node) { |
724 base::AutoReset<bool> auto_reset(&ignore_text_changes_, true); | 725 base::AutoReset<bool> auto_reset(&ignore_text_changes_, true); |
725 node->setEditingValue(value.substr(0, node->maxLength())); | 726 node->setEditingValue(value.substr(0, node->maxLength())); |
726 } | 727 } |
727 | 728 |
728 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, | 729 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
729 WebInputElement* node) { | 730 WebInputElement* node) { |
730 was_query_node_autofilled_ = element_.isAutofilled(); | 731 was_query_node_autofilled_ = element_.isAutofilled(); |
731 node->setSuggestedValue(value.substr(0, node->maxLength())); | 732 node->setSuggestedValue(value.substr(0, node->maxLength())); |
732 node->setAutofilled(true); | 733 node->setAutofilled(true); |
733 node->setSelectionRange(node->value().length(), | 734 |
734 node->suggestedValue().length()); | 735 if (IsFeatureSubstringMatchEnabled()) { |
736 size_t start = autofill::GetTextSelectionStart(value, node->value()); | |
please use gerrit instead
2015/06/11 19:10:25
You've calculated the |start| value previously, so
Pritam Nikam
2015/06/12 11:09:11
We do not recalculate |start| here, we do it only
please use gerrit instead
2015/06/22 00:32:59
Ah, I was slightly confused. I thought that you ca
Pritam Nikam
2015/06/22 18:31:39
Cases where ContainsTokenThatStartsWith() returned
| |
737 node->setSelectionRange(start, node->suggestedValue().length()); | |
738 } else { | |
739 node->setSelectionRange(node->value().length(), | |
740 node->suggestedValue().length()); | |
741 } | |
735 } | 742 } |
736 | 743 |
737 void AutofillAgent::ProcessForms() { | 744 void AutofillAgent::ProcessForms() { |
738 // Record timestamp of when the forms are first seen. This is used to | 745 // Record timestamp of when the forms are first seen. This is used to |
739 // measure the overhead of the Autofill feature. | 746 // measure the overhead of the Autofill feature. |
740 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); | 747 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); |
741 | 748 |
742 WebLocalFrame* frame = render_frame()->GetWebFrame(); | 749 WebLocalFrame* frame = render_frame()->GetWebFrame(); |
743 std::vector<FormData> forms = form_cache_.ExtractNewForms(); | 750 std::vector<FormData> forms = form_cache_.ExtractNewForms(); |
744 | 751 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
794 | 801 |
795 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 802 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
796 // No-op. Don't delete |this|. | 803 // No-op. Don't delete |this|. |
797 } | 804 } |
798 | 805 |
799 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 806 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
800 agent_->FocusChangeComplete(); | 807 agent_->FocusChangeComplete(); |
801 } | 808 } |
802 | 809 |
803 } // namespace autofill | 810 } // namespace autofill |
OLD | NEW |