Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 962673004: [Autofill/Autocomplete Feature] Substring matching instead of prefix matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses review comments. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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;
772 size_t end = 0;
773 if (base::string16::npos !=
774 ComputeRange(value, node->value(), &start, &end)) {
775 node->setSelectionRange(start, end);
776 }
777 } else {
778 node->setSelectionRange(node->value().length(),
779 node->suggestedValue().length());
780 }
770 } 781 }
771 782
772 void AutofillAgent::ProcessForms() { 783 void AutofillAgent::ProcessForms() {
773 // Record timestamp of when the forms are first seen. This is used to 784 // Record timestamp of when the forms are first seen. This is used to
774 // measure the overhead of the Autofill feature. 785 // measure the overhead of the Autofill feature.
775 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); 786 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now();
776 787
777 WebLocalFrame* frame = render_frame()->GetWebFrame(); 788 WebLocalFrame* frame = render_frame()->GetWebFrame();
778 std::vector<FormData> forms = form_cache_.ExtractNewForms(); 789 std::vector<FormData> forms = form_cache_.ExtractNewForms();
779 790
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 836
826 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { 837 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
827 // No-op. Don't delete |this|. 838 // No-op. Don't delete |this|.
828 } 839 }
829 840
830 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { 841 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() {
831 agent_->FocusChangeComplete(); 842 agent_->FocusChangeComplete();
832 } 843 }
833 844
834 } // namespace autofill 845 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698