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

Side by Side Diff: components/autofill/core/common/autofill_util.cc

Issue 2906383003: Teach PasswordAutofillAgent sometimes match prefixes of usernames (Closed)
Patch Set: . Created 3 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/core/common/autofill_util.h" 5 #include "components/autofill/core/common/autofill_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 case_sensitive 108 case_sensitive
109 ? base::CompareCase::SENSITIVE 109 ? base::CompareCase::SENSITIVE
110 : base::CompareCase::INSENSITIVE_ASCII); 110 : base::CompareCase::INSENSITIVE_ASCII);
111 } 111 }
112 112
113 return suggestion.length() >= field_contents.length() && 113 return suggestion.length() >= field_contents.length() &&
114 GetTextSelectionStart(suggestion, field_contents, case_sensitive) != 114 GetTextSelectionStart(suggestion, field_contents, case_sensitive) !=
115 base::string16::npos; 115 base::string16::npos;
116 } 116 }
117 117
118 bool IsPrefixOfEmailEndingWithAtSign(const base::string16& full_string,
119 const base::string16& prefix) {
120 return base::StartsWith(full_string, prefix + base::UTF8ToUTF16(""),
vabr (Chromium) 2017/06/21 12:28:07 "" -> "@"
121 base::CompareCase::SENSITIVE);
122 }
123
118 size_t GetTextSelectionStart(const base::string16& suggestion, 124 size_t GetTextSelectionStart(const base::string16& suggestion,
119 const base::string16& field_contents, 125 const base::string16& field_contents,
120 bool case_sensitive) { 126 bool case_sensitive) {
121 const base::string16 kSplitChars = base::ASCIIToUTF16(kSplitCharacters); 127 const base::string16 kSplitChars = base::ASCIIToUTF16(kSplitCharacters);
122 128
123 // Loop until we find either the |field_contents| is a prefix of |suggestion| 129 // Loop until we find either the |field_contents| is a prefix of |suggestion|
124 // or character right before the match is one of the splitting characters. 130 // or character right before the match is one of the splitting characters.
125 for (base::string16::const_iterator it = suggestion.begin(); 131 for (base::string16::const_iterator it = suggestion.begin();
126 (it = std::search( 132 (it = std::search(
127 it, suggestion.end(), field_contents.begin(), field_contents.end(), 133 it, suggestion.end(), field_contents.begin(), field_contents.end(),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 182 }
177 183
178 std::vector<std::string> LowercaseAndTokenizeAttributeString( 184 std::vector<std::string> LowercaseAndTokenizeAttributeString(
179 const std::string& attribute) { 185 const std::string& attribute) {
180 return base::SplitString(base::ToLowerASCII(attribute), 186 return base::SplitString(base::ToLowerASCII(attribute),
181 base::kWhitespaceASCII, base::TRIM_WHITESPACE, 187 base::kWhitespaceASCII, base::TRIM_WHITESPACE,
182 base::SPLIT_WANT_NONEMPTY); 188 base::SPLIT_WANT_NONEMPTY);
183 } 189 }
184 190
185 } // namespace autofill 191 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698