Chromium Code Reviews| 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..251522fe9cd0ab5548debb183d62dbef6db8f69b 100644 |
| --- a/components/autofill/core/common/autofill_util.cc |
| +++ b/components/autofill/core/common/autofill_util.cc |
| @@ -115,6 +115,23 @@ bool FieldIsSuggestionSubstringStartingOnTokenBoundary( |
| base::string16::npos; |
| } |
| +bool IsPrefixOfEmailEndingAtSign(const base::string16& full_string, |
| + const base::string16& prefix) { |
| + auto at_sign = std::find(full_string.begin(), full_string.end(), '@'); |
| + auto e = full_string.end(); |
| + // weak check if |full_string| is a valid email address. |
|
vabr (Chromium)
2017/06/19 12:54:15
nit: weak -> A weak
Or maybe better "An incomplete
melandory
2017/06/21 12:00:42
Done.
|
| + bool is_email = |
|
vabr (Chromium)
2017/06/19 12:54:15
Well, actually, hinting at e-mail, but only doing
melandory
2017/06/21 12:00:42
In this case "ab@cd@g", "ab@cd" will result in mat
vabr (Chromium)
2017/06/21 12:28:07
I think it is fine. From usability perspective I d
|
| + (at_sign != e // there is @ |
| + && std::find(at_sign, e, '.') != e // there is . and it's after @ |
| + && std::find(++at_sign, e, '@') == e); // there is at most 1 @ |
| + if (is_email && |
| + 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) { |