Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / components / omnibox / browser / autocomplete_i18n.h
blob9733e179033aefa7789107f0445be47386f65339
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_I18N_H_
6 #define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_I18N_H_
8 #include "base/strings/string16.h"
9 #include "third_party/icu/source/common/unicode/uchar.h"
11 // Functor for a simple 16-bit Unicode case-insensitive comparison. This is
12 // designed for the autocomplete system where we would rather get prefix lenths
13 // correct than handle all possible case sensitivity issues.
15 // Any time this is used the result will be incorrect in some cases that
16 // certain users will be able to discern. Ideally, this class would be deleted
17 // and we would do full Unicode case-sensitivity mappings using
18 // base::i18n::ToLower. However, ToLower can change the lenghts of strings,
19 // making computations of offsets or prefix lengths difficult. Getting all
20 // edge cases correct will require careful implementation and testing. In the
21 // mean time, we use this simpler approach.
23 // This comparator will not handle combining accents properly since it compares
24 // 16-bit values in isolation. If the two strings use the same sequence of
25 // combining accents (this is the normal case) in both strings, it will work.
27 // Additionally, this comparator does not decode UTF sequences which is why it
28 // is called "UCS2". UTF-16 surrogates will be compared literally (i.e. "case-
29 // sensitively").
31 // There are also a few cases where the lower-case version of a character
32 // expands to more than one code point that will not be handled properly. Such
33 // characters will be compared case-sensitively.
34 struct SimpleCaseInsensitiveCompareUCS2 {
35 public:
36 bool operator()(base::char16 x, base::char16 y) const {
37 return u_tolower(x) == u_tolower(y);
41 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_I18N_H_