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

Side by Side Diff: components/autofill/content/renderer/password_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/password_autofill_agent.h" 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 6
7 #include <algorithm>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
12 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
14 #include "components/autofill/content/common/autofill_messages.h" 16 #include "components/autofill/content/common/autofill_messages.h"
15 #include "components/autofill/content/renderer/form_autofill_util.h" 17 #include "components/autofill/content/renderer/form_autofill_util.h"
16 #include "components/autofill/content/renderer/password_form_conversion_utils.h" 18 #include "components/autofill/content/renderer/password_form_conversion_utils.h"
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 773
772 password_info->password_field.setValue(password, true); 774 password_info->password_field.setValue(password, true);
773 password_info->password_field.setAutofilled(true); 775 password_info->password_field.setAutofilled(true);
774 776
775 filled_element.setSelectionRange(filled_element.value().length(), 777 filled_element.setSelectionRange(filled_element.value().length(),
776 filled_element.value().length()); 778 filled_element.value().length());
777 779
778 return true; 780 return true;
779 } 781 }
780 782
781 bool PasswordAutofillAgent::PreviewSuggestion( 783 bool PasswordAutofillAgent::PreviewSuggestion(const blink::WebNode& node,
782 const blink::WebNode& node, 784 const blink::WebString& username,
783 const blink::WebString& username, 785 const blink::WebString& password,
784 const blink::WebString& password) { 786 int match_start) {
785 blink::WebInputElement username_element; 787 blink::WebInputElement username_element;
786 PasswordInfo* password_info; 788 PasswordInfo* password_info;
787 789
788 if (!FindLoginInfo(node, &username_element, &password_info) || 790 if (!FindLoginInfo(node, &username_element, &password_info) ||
789 !IsElementAutocompletable(username_element) || 791 !IsElementAutocompletable(username_element) ||
790 !IsElementAutocompletable(password_info->password_field)) { 792 !IsElementAutocompletable(password_info->password_field)) {
791 return false; 793 return false;
792 } 794 }
793 795
794 was_username_autofilled_ = username_element.isAutofilled(); 796 was_username_autofilled_ = username_element.isAutofilled();
795 username_selection_start_ = username_element.selectionStart(); 797 username_selection_start_ =
798 std::min(match_start, username_element.maxLength());
796 username_element.setSuggestedValue(username); 799 username_element.setSuggestedValue(username);
797 username_element.setAutofilled(true); 800 username_element.setAutofilled(true);
798 username_element.setSelectionRange( 801 username_element.setSelectionRange(
799 username_selection_start_, 802 username_selection_start_,
800 username_element.suggestedValue().length()); 803 username_element.suggestedValue().length());
801 804
802 was_password_autofilled_ = password_info->password_field.isAutofilled(); 805 was_password_autofilled_ = password_info->password_field.isAutofilled();
803 password_info->password_field.setSuggestedValue(password); 806 password_info->password_field.setSuggestedValue(password);
804 password_info->password_field.setAutofilled(true); 807 password_info->password_field.setAutofilled(true);
805 808
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { 1493 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() {
1491 agent_->DidStopLoading(); 1494 agent_->DidStopLoading();
1492 } 1495 }
1493 1496
1494 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: 1497 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::
1495 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { 1498 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) {
1496 agent_->LegacyDidStartProvisionalLoad(navigated_frame); 1499 agent_->LegacyDidStartProvisionalLoad(navigated_frame);
1497 } 1500 }
1498 1501
1499 } // namespace autofill 1502 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698