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

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: Incorporates Evan's review comments. Created 5 years, 7 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/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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/autofill/content/common/autofill_messages.h" 15 #include "components/autofill/content/common/autofill_messages.h"
16 #include "components/autofill/content/renderer/form_autofill_util.h" 16 #include "components/autofill/content/renderer/form_autofill_util.h"
17 #include "components/autofill/content/renderer/page_click_tracker.h" 17 #include "components/autofill/content/renderer/page_click_tracker.h"
18 #include "components/autofill/content/renderer/password_autofill_agent.h" 18 #include "components/autofill/content/renderer/password_autofill_agent.h"
19 #include "components/autofill/content/renderer/password_generation_agent.h" 19 #include "components/autofill/content/renderer/password_generation_agent.h"
20 #include "components/autofill/core/common/autofill_constants.h" 20 #include "components/autofill/core/common/autofill_constants.h"
21 #include "components/autofill/core/common/autofill_data_validation.h" 21 #include "components/autofill/core/common/autofill_data_validation.h"
22 #include "components/autofill/core/common/autofill_switches.h" 22 #include "components/autofill/core/common/autofill_switches.h"
23 #include "components/autofill/core/common/autofill_util.h"
23 #include "components/autofill/core/common/form_data.h" 24 #include "components/autofill/core/common/form_data.h"
24 #include "components/autofill/core/common/form_data_predictions.h" 25 #include "components/autofill/core/common/form_data_predictions.h"
25 #include "components/autofill/core/common/form_field_data.h" 26 #include "components/autofill/core/common/form_field_data.h"
26 #include "components/autofill/core/common/password_form.h" 27 #include "components/autofill/core/common/password_form.h"
27 #include "components/autofill/core/common/web_element_descriptor.h" 28 #include "components/autofill/core/common/web_element_descriptor.h"
28 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
29 #include "content/public/common/ssl_status.h" 30 #include "content/public/common/ssl_status.h"
30 #include "content/public/common/url_constants.h" 31 #include "content/public/common/url_constants.h"
31 #include "content/public/renderer/render_frame.h" 32 #include "content/public/renderer/render_frame.h"
32 #include "content/public/renderer/render_view.h" 33 #include "content/public/renderer/render_view.h"
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 WebInputElement* node) { 720 WebInputElement* node) {
720 base::AutoReset<bool> auto_reset(&ignore_text_changes_, true); 721 base::AutoReset<bool> auto_reset(&ignore_text_changes_, true);
721 node->setEditingValue(value.substr(0, node->maxLength())); 722 node->setEditingValue(value.substr(0, node->maxLength()));
722 } 723 }
723 724
724 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, 725 void AutofillAgent::PreviewFieldWithValue(const base::string16& value,
725 WebInputElement* node) { 726 WebInputElement* node) {
726 was_query_node_autofilled_ = element_.isAutofilled(); 727 was_query_node_autofilled_ = element_.isAutofilled();
727 node->setSuggestedValue(value.substr(0, node->maxLength())); 728 node->setSuggestedValue(value.substr(0, node->maxLength()));
728 node->setAutofilled(true); 729 node->setAutofilled(true);
729 node->setSelectionRange(node->value().length(), 730
730 node->suggestedValue().length()); 731 if (IsFeatureSubstringMatchEnabled()) {
732 size_t start = autofill::GetTextSelectionStart(value, node->value());
733 if (start != base::string16::npos)
734 node->setSelectionRange(start, node->suggestedValue().length());
735 } else {
736 node->setSelectionRange(node->value().length(),
737 node->suggestedValue().length());
738 }
731 } 739 }
732 740
733 void AutofillAgent::ProcessForms() { 741 void AutofillAgent::ProcessForms() {
734 // Record timestamp of when the forms are first seen. This is used to 742 // Record timestamp of when the forms are first seen. This is used to
735 // measure the overhead of the Autofill feature. 743 // measure the overhead of the Autofill feature.
736 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); 744 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now();
737 745
738 WebLocalFrame* frame = render_frame()->GetWebFrame(); 746 WebLocalFrame* frame = render_frame()->GetWebFrame();
739 std::vector<FormData> forms = form_cache_.ExtractNewForms(); 747 std::vector<FormData> forms = form_cache_.ExtractNewForms();
740 748
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 798
791 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { 799 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
792 // No-op. Don't delete |this|. 800 // No-op. Don't delete |this|.
793 } 801 }
794 802
795 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { 803 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() {
796 agent_->FocusChangeComplete(); 804 agent_->FocusChangeComplete();
797 } 805 }
798 806
799 } // namespace autofill 807 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698