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_CHROME_ADDRESS_VALIDATOR_H_ | 5 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_ADDRESS_VALIDATOR_H_ |
6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_ADDRESS_VALIDATOR_H_ | 6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_ADDRESS_VALIDATOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
| 13 #include <utility> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi
eld.h" | 19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi
eld.h" |
19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_va
lidator.h" | 20 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_va
lidator.h" |
20 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/callback.h
" | 21 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/callback.h
" |
21 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/preload_su
pplier.h" | 22 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/preload_su
pplier.h" |
22 | 23 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // has language-specific validation rules, then these are also loaded. | 89 // has language-specific validation rules, then these are also loaded. |
89 // | 90 // |
90 // Example rule: | 91 // Example rule: |
91 // https://i18napis.appspot.com/ssl-aggregate-address/data/US | 92 // https://i18napis.appspot.com/ssl-aggregate-address/data/US |
92 // | 93 // |
93 // If the rules are already in progress of being loaded, it does nothing. | 94 // If the rules are already in progress of being loaded, it does nothing. |
94 // Invokes |load_rules_listener| when the loading has finished. | 95 // Invokes |load_rules_listener| when the loading has finished. |
95 virtual void LoadRules(const std::string& region_code); | 96 virtual void LoadRules(const std::string& region_code); |
96 | 97 |
97 // Returns the list of sub-regions (recorded as sub-keys) of the region | 98 // Returns the list of sub-regions (recorded as sub-keys) of the region |
98 // (recorded as rule) indicated by |region_code|. So, if the |region_code| is | 99 // (recorded as rule) indicated by |region_code|, while the device language |
| 100 // is set to |language|. So, if the |region_code| is |
99 // a country code, sub-region means the country's admin area. | 101 // a country code, sub-region means the country's admin area. |
100 // This function should be called when the rules are loaded. | 102 // This function should be called when the rules are loaded. |
101 virtual std::vector<std::string> GetRegionSubKeys( | 103 virtual std::vector<std::pair<std::string, std::string>> GetRegionSubKeys( |
102 const std::string& region_code); | 104 const std::string& region_code, |
| 105 const std::string& language); |
103 | 106 |
104 // Validates the |address| and populates |problems| with the validation | 107 // Validates the |address| and populates |problems| with the validation |
105 // problems, filtered according to the |filter| parameter. | 108 // problems, filtered according to the |filter| parameter. |
106 // | 109 // |
107 // If the |filter| is empty, then all discovered validation problems are | 110 // If the |filter| is empty, then all discovered validation problems are |
108 // returned. If the |filter| contains problem elements, then only the problems | 111 // returned. If the |filter| contains problem elements, then only the problems |
109 // in the |filter| may be returned. | 112 // in the |filter| may be returned. |
110 virtual Status ValidateAddress( | 113 virtual Status ValidateAddress( |
111 const ::i18n::addressinput::AddressData& address, | 114 const ::i18n::addressinput::AddressData& address, |
112 const ::i18n::addressinput::FieldProblemMap* filter, | 115 const ::i18n::addressinput::FieldProblemMap* filter, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // any WeakPtrs to AddressValidator are invalidated before its members | 208 // any WeakPtrs to AddressValidator are invalidated before its members |
206 // variable's destructors are executed, rendering them invalid. | 209 // variable's destructors are executed, rendering them invalid. |
207 base::WeakPtrFactory<AddressValidator> weak_factory_; | 210 base::WeakPtrFactory<AddressValidator> weak_factory_; |
208 | 211 |
209 DISALLOW_COPY_AND_ASSIGN(AddressValidator); | 212 DISALLOW_COPY_AND_ASSIGN(AddressValidator); |
210 }; | 213 }; |
211 | 214 |
212 } // namespace autofill | 215 } // namespace autofill |
213 | 216 |
214 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_ADDRESS_VALIDATOR_H_ | 217 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_ADDRESS_VALIDATOR_H_ |
OLD | NEW |