OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browser/country_names.h" | 5 #include "components/autofill/core/browser/country_names.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "components/autofill/core/browser/country_data.h" | 17 #include "components/autofill/core/browser/country_data.h" |
18 #include "components/autofill/core/common/autofill_l10n_util.h" | 18 #include "components/autofill/core/common/autofill_l10n_util.h" |
19 #include "third_party/icu/source/common/unicode/unistr.h" | 19 #include "third_party/icu/source/common/unicode/unistr.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 | 21 |
22 namespace autofill { | 22 namespace autofill { |
23 namespace { | 23 namespace { |
24 | 24 |
25 // A copy of the application locale string, which should be ready for | 25 // A copy of the application locale string, which should be ready for |
26 // CountryName's construction. | 26 // CountryName's construction. |
27 static base::LazyInstance<std::string> g_application_locale = | 27 static base::LazyInstance<std::string>::DestructorAtExit g_application_locale = |
28 LAZY_INSTANCE_INITIALIZER; | 28 LAZY_INSTANCE_INITIALIZER; |
29 | 29 |
30 // Returns the ICU sort key corresponding to |str| for the given |collator|. | 30 // Returns the ICU sort key corresponding to |str| for the given |collator|. |
31 // Uses |buffer| as temporary storage, and might resize |buffer| as a side- | 31 // Uses |buffer| as temporary storage, and might resize |buffer| as a side- |
32 // effect. |buffer_size| should specify the |buffer|'s size, and is updated if | 32 // effect. |buffer_size| should specify the |buffer|'s size, and is updated if |
33 // the |buffer| is resized. | 33 // the |buffer| is resized. |
34 const std::string GetSortKey(const icu::Collator& collator, | 34 const std::string GetSortKey(const icu::Collator& collator, |
35 const base::string16& str, | 35 const base::string16& str, |
36 std::unique_ptr<uint8_t[]>* buffer, | 36 std::unique_ptr<uint8_t[]>* buffer, |
37 int32_t* buffer_size) { | 37 int32_t* buffer_size) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 auto result = localized_names.find(sort_key); | 207 auto result = localized_names.find(sort_key); |
208 | 208 |
209 if (result != localized_names.end()) | 209 if (result != localized_names.end()) |
210 return result->second; | 210 return result->second; |
211 | 211 |
212 return std::string(); | 212 return std::string(); |
213 } | 213 } |
214 | 214 |
215 } // namespace autofill | 215 } // namespace autofill |
OLD | NEW |