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

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

Issue 1208133002: [Autofill/Autocomplete Feature] Substring matching instead of prefix matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added |match_start| usage. Created 5 years, 5 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/location.h" 10 #include "base/location.h"
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 564 }
565 565
566 void AutofillAgent::OnFillFieldWithValue(const base::string16& value) { 566 void AutofillAgent::OnFillFieldWithValue(const base::string16& value) {
567 WebInputElement* input_element = toWebInputElement(&element_); 567 WebInputElement* input_element = toWebInputElement(&element_);
568 if (input_element) { 568 if (input_element) {
569 FillFieldWithValue(value, input_element); 569 FillFieldWithValue(value, input_element);
570 input_element->setAutofilled(true); 570 input_element->setAutofilled(true);
571 } 571 }
572 } 572 }
573 573
574 void AutofillAgent::OnPreviewFieldWithValue(const base::string16& value) { 574 void AutofillAgent::OnPreviewFieldWithValue(const base::string16& value,
575 int match_start) {
575 WebInputElement* input_element = toWebInputElement(&element_); 576 WebInputElement* input_element = toWebInputElement(&element_);
576 if (input_element) 577 if (input_element)
577 PreviewFieldWithValue(value, input_element); 578 PreviewFieldWithValue(value, input_element, match_start);
578 } 579 }
579 580
580 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) { 581 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) {
581 AcceptDataListSuggestion(value); 582 AcceptDataListSuggestion(value);
582 } 583 }
583 584
584 void AutofillAgent::OnFillPasswordSuggestion(const base::string16& username, 585 void AutofillAgent::OnFillPasswordSuggestion(const base::string16& username,
585 const base::string16& password) { 586 const base::string16& password) {
586 bool handled = password_autofill_agent_->FillSuggestion( 587 bool handled = password_autofill_agent_->FillSuggestion(
587 element_, 588 element_,
588 username, 589 username,
589 password); 590 password);
590 DCHECK(handled); 591 DCHECK(handled);
591 } 592 }
592 593
593 void AutofillAgent::OnPreviewPasswordSuggestion( 594 void AutofillAgent::OnPreviewPasswordSuggestion(const base::string16& username,
594 const base::string16& username, 595 const base::string16& password,
595 const base::string16& password) { 596 int start) {
596 bool handled = password_autofill_agent_->PreviewSuggestion( 597 bool handled = password_autofill_agent_->PreviewSuggestion(element_, username,
597 element_, 598 password, start);
598 username,
599 password);
600 DCHECK(handled); 599 DCHECK(handled);
601 } 600 }
602 601
603 void AutofillAgent::OnRequestAutocompleteResult( 602 void AutofillAgent::OnRequestAutocompleteResult(
604 WebFormElement::AutocompleteResult result, 603 WebFormElement::AutocompleteResult result,
605 const base::string16& message, 604 const base::string16& message,
606 const FormData& form_data) { 605 const FormData& form_data) {
607 if (in_flight_request_form_.isNull()) 606 if (in_flight_request_form_.isNull())
608 return; 607 return;
609 608
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 routing_id(), autofill_query_id_, form, field, bounding_box_scaled)); 728 routing_id(), autofill_query_id_, form, field, bounding_box_scaled));
730 } 729 }
731 730
732 void AutofillAgent::FillFieldWithValue(const base::string16& value, 731 void AutofillAgent::FillFieldWithValue(const base::string16& value,
733 WebInputElement* node) { 732 WebInputElement* node) {
734 base::AutoReset<bool> auto_reset(&ignore_text_changes_, true); 733 base::AutoReset<bool> auto_reset(&ignore_text_changes_, true);
735 node->setEditingValue(value.substr(0, node->maxLength())); 734 node->setEditingValue(value.substr(0, node->maxLength()));
736 } 735 }
737 736
738 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, 737 void AutofillAgent::PreviewFieldWithValue(const base::string16& value,
739 WebInputElement* node) { 738 WebInputElement* node,
739 int match_start) {
740 was_query_node_autofilled_ = element_.isAutofilled(); 740 was_query_node_autofilled_ = element_.isAutofilled();
741 node->setSuggestedValue(value.substr(0, node->maxLength())); 741 node->setSuggestedValue(value.substr(0, node->maxLength()));
742 node->setAutofilled(true); 742 node->setAutofilled(true);
743 node->setSelectionRange(node->value().length(), 743 node->setSelectionRange(std::min(match_start, node->maxLength()),
744 node->suggestedValue().length()); 744 node->suggestedValue().length());
745 } 745 }
746 746
747 void AutofillAgent::ProcessForms() { 747 void AutofillAgent::ProcessForms() {
748 // Record timestamp of when the forms are first seen. This is used to 748 // Record timestamp of when the forms are first seen. This is used to
749 // measure the overhead of the Autofill feature. 749 // measure the overhead of the Autofill feature.
750 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); 750 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now();
751 751
752 WebLocalFrame* frame = render_frame()->GetWebFrame(); 752 WebLocalFrame* frame = render_frame()->GetWebFrame();
753 std::vector<FormData> forms = form_cache_.ExtractNewForms(); 753 std::vector<FormData> forms = form_cache_.ExtractNewForms();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 805
806 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { 806 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
807 // No-op. Don't delete |this|. 807 // No-op. Don't delete |this|.
808 } 808 }
809 809
810 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { 810 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() {
811 agent_->FocusChangeComplete(); 811 agent_->FocusChangeComplete();
812 } 812 }
813 813
814 } // namespace autofill 814 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/autofill_agent.h ('k') | components/autofill/content/renderer/password_autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698