OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_ | 5 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_ |
6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_ | 6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "third_party/icu/source/i18n/unicode/coll.h" | 16 #include "third_party/icu/source/i18n/unicode/coll.h" |
17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi
eld.h" | 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi
eld.h" |
18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_in
put_helper.h" | 18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_in
put_helper.h" |
19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_va
lidator.h" | 19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_va
lidator.h" |
20 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/region_dat
a_builder.h" | 20 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/region_dat
a_builder.h" |
21 | 21 |
22 namespace i18n { | 22 namespace i18n { |
23 namespace addressinput { | 23 namespace addressinput { |
24 class PreloadSupplier; | 24 class PreloadSupplier; |
25 class RegionData; | 25 class RegionData; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // The output is not human-readable. | 89 // The output is not human-readable. |
90 // Canonicalize("Texas") != "Texas"; | 90 // Canonicalize("Texas") != "Texas"; |
91 // | 91 // |
92 // The |original| parameter should not be empty. | 92 // The |original| parameter should not be empty. |
93 const std::vector<uint8_t>& Canonicalize(const std::string& original) const; | 93 const std::vector<uint8_t>& Canonicalize(const std::string& original) const; |
94 | 94 |
95 private: | 95 private: |
96 int32_t buffer_size() const; | 96 int32_t buffer_size() const; |
97 | 97 |
98 mutable std::vector<uint8_t> buffer_; | 98 mutable std::vector<uint8_t> buffer_; |
99 scoped_ptr<icu::Collator> collator_; | 99 std::unique_ptr<icu::Collator> collator_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(StringCanonicalizer); | 101 DISALLOW_COPY_AND_ASSIGN(StringCanonicalizer); |
102 }; | 102 }; |
103 | 103 |
104 // The method to be invoked by |validated_| callback. | 104 // The method to be invoked by |validated_| callback. |
105 void Validated(bool success, | 105 void Validated(bool success, |
106 const ::i18n::addressinput::AddressData&, | 106 const ::i18n::addressinput::AddressData&, |
107 const ::i18n::addressinput::FieldProblemMap&); | 107 const ::i18n::addressinput::FieldProblemMap&); |
108 | 108 |
109 // Data source for region data. | 109 // Data source for region data. |
110 ::i18n::addressinput::RegionDataBuilder region_data_builder_; | 110 ::i18n::addressinput::RegionDataBuilder region_data_builder_; |
111 | 111 |
112 // Suggests sub-regions based on postal code. | 112 // Suggests sub-regions based on postal code. |
113 const ::i18n::addressinput::AddressInputHelper input_helper_; | 113 const ::i18n::addressinput::AddressInputHelper input_helper_; |
114 | 114 |
115 // Verifies that suggested sub-regions match the postal code. | 115 // Verifies that suggested sub-regions match the postal code. |
116 ::i18n::addressinput::AddressValidator validator_; | 116 ::i18n::addressinput::AddressValidator validator_; |
117 | 117 |
118 // The callback for |validator_| to invoke when validation finishes. | 118 // The callback for |validator_| to invoke when validation finishes. |
119 const scoped_ptr<const ::i18n::addressinput::AddressValidator::Callback> | 119 const std::unique_ptr<const ::i18n::addressinput::AddressValidator::Callback> |
120 validated_; | 120 validated_; |
121 | 121 |
122 // A mapping from a COUNTRY level region to a collection of all of its | 122 // A mapping from a COUNTRY level region to a collection of all of its |
123 // sub-regions along with metadata used to construct suggestions. | 123 // sub-regions along with metadata used to construct suggestions. |
124 std::map<const ::i18n::addressinput::RegionData*, SubRegionData> sub_regions_; | 124 std::map<const ::i18n::addressinput::RegionData*, SubRegionData> sub_regions_; |
125 | 125 |
126 // Canonicalizes strings for case and diacritic insensitive search of | 126 // Canonicalizes strings for case and diacritic insensitive search of |
127 // sub-region names. | 127 // sub-region names. |
128 StringCanonicalizer canonicalizer_; | 128 StringCanonicalizer canonicalizer_; |
129 | 129 |
130 DISALLOW_COPY_AND_ASSIGN(InputSuggester); | 130 DISALLOW_COPY_AND_ASSIGN(InputSuggester); |
131 }; | 131 }; |
132 | 132 |
133 } // namespace autofill | 133 } // namespace autofill |
134 | 134 |
135 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_ | 135 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_ |
OLD | NEW |