Chromium Code Reviews| Index: components/autofill/core/browser/autofill_profile.cc |
| diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc |
| index 0f69602a9265b7a33035cbcbb7552847a1b150ad..fe62770b51c5f28e0b354ae71a60aba30b0d2a47 100644 |
| --- a/components/autofill/core/browser/autofill_profile.cc |
| +++ b/components/autofill/core/browser/autofill_profile.cc |
| @@ -36,6 +36,8 @@ |
| #include "components/autofill/core/common/form_field_data.h" |
| #include "grit/components_strings.h" |
| #include "third_party/icu/source/common/unicode/uchar.h" |
| +#include "third_party/icu/source/common/unicode/utypes.h" |
| +#include "third_party/icu/source/i18n/unicode/translit.h" |
| #include "third_party/libaddressinput/chromium/addressinput_util.h" |
| #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_data.h" |
| #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_formatter.h" |
| @@ -235,6 +237,26 @@ class FindByPhone { |
| std::string app_locale_; |
| }; |
| +base::string16 NormalizeForComparison(const base::string16& text) { |
| + using icu::UnicodeString; |
| + using icu::Transliterator; |
| + |
| + // Remove diacritics and fold case. |
|
Mathieu
2016/05/27 17:47:13
extra space before comment
Roger McFarlane (Chromium)
2016/05/27 20:20:42
Done.
|
| + UErrorCode status = U_ZERO_ERROR; |
| + std::unique_ptr<Transliterator> transliterator(Transliterator::createInstance( |
| + "NFD; [:Nonspacing Mark:] Remove; Lower; NFC", UTRANS_FORWARD, status)); |
|
Mathieu
2016/05/27 17:47:13
Can we put an explanation (or a link to the explan
Roger McFarlane (Chromium)
2016/05/27 20:20:43
Done.
|
| + if (U_FAILURE(status)) { |
| + // This should not happen. Log the error and fall back. |
| + LOG(ERROR) << "normalization failed: " << u_errorName(status); |
|
Mathieu
2016/05/27 17:47:13
Let's capitalize the comment and make it more expl
Roger McFarlane (Chromium)
2016/05/27 20:20:43
Done.
|
| + return text; |
| + } |
| + |
| + UnicodeString value = UnicodeString(text.data(), text.length()); |
| + transliterator->transliterate(value); |
|
Mathieu
2016/05/27 17:47:13
can we check "if (transliterator)" here? ICU has a
Roger McFarlane (Chromium)
2016/05/27 20:20:43
Done.
|
| + |
| + return base::string16(value.getBuffer(), value.length()); |
| +} |
| + |
| } // namespace |
| AutofillProfile::AutofillProfile(const std::string& guid, |
| @@ -846,7 +868,7 @@ base::string16 AutofillProfile::CanonicalizeProfileString( |
| if (previous_was_whitespace) |
| ret.resize(ret.size() - 1); |
| - return ret; |
| + return NormalizeForComparison(ret); |
| } |
| // static |