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

Unified Diff: components/autofill/core/common/autofill_util.cc

Issue 2906383003: Teach PasswordAutofillAgent sometimes match prefixes of usernames (Closed)
Patch Set: dvadym@ comments 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/common/autofill_util.cc
diff --git a/components/autofill/core/common/autofill_util.cc b/components/autofill/core/common/autofill_util.cc
index 50e50176d8c336e700bef8af1c7e6bfd865250fd..b1c86d36203a6ac4dab6ab4a646a7dec92c66f54 100644
--- a/components/autofill/core/common/autofill_util.cc
+++ b/components/autofill/core/common/autofill_util.cc
@@ -99,10 +99,9 @@ bool IsHintEnabledInKeyboardAccessory() {
#endif
}
-bool FieldIsSuggestionSubstringStartingOnTokenBoundary(
- const base::string16& suggestion,
- const base::string16& field_contents,
- bool case_sensitive) {
+bool IsSubstringStartingOnTokenBoundary(const base::string16& suggestion,
+ const base::string16& field_contents,
+ bool case_sensitive) {
if (!IsFeatureSubstringMatchEnabled()) {
return base::StartsWith(suggestion, field_contents,
case_sensitive
@@ -115,6 +114,15 @@ bool FieldIsSuggestionSubstringStartingOnTokenBoundary(
base::string16::npos;
}
+bool IsPrefixEndingOnTokenBoundary(const base::string16& full_string,
+ const base::string16& prefix) {
+ if (base::StartsWith(full_string, prefix, base::CompareCase::SENSITIVE)) {
+ return (full_string.size() > prefix.size() &&
+ full_string[prefix.size()] == '@');
+ }
+ return false;
+}
+
size_t GetTextSelectionStart(const base::string16& suggestion,
const base::string16& field_contents,
bool case_sensitive) {

Powered by Google App Engine
This is Rietveld 408576698