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> |
(...skipping 28 matching lines...) Expand all Loading... | |
39 public: | 39 public: |
40 virtual ~LoadRulesListener() {} | 40 virtual ~LoadRulesListener() {} |
41 | 41 |
42 // Called when the validation rules for the |region_code| have been loaded. | 42 // Called when the validation rules for the |region_code| have been loaded. |
43 // The validation rules include the generic rules for the |region_code| and | 43 // The validation rules include the generic rules for the |region_code| and |
44 // specific rules for the country's administrative areas, localities, and | 44 // specific rules for the country's administrative areas, localities, and |
45 // dependent localities. If a country has language-specific validation rules, | 45 // dependent localities. If a country has language-specific validation rules, |
46 // then these are also loaded. | 46 // then these are also loaded. |
47 // | 47 // |
48 // The |success| parameter is true when the rules were loaded successfully. | 48 // The |success| parameter is true when the rules were loaded successfully. |
49 virtual void OnAddressValidationRulesLoaded(const std::string& region_code, | 49 virtual void OnAddressRulesLoaded(const std::string& region_code, |
50 bool success) = 0; | 50 bool success) = 0; |
51 }; | 51 }; |
52 | 52 |
53 // Interface to the libaddressinput AddressValidator for Chromium Autofill. The | 53 // Interface to the libaddressinput AddressValidator for Chromium Autofill. The |
54 // class is named AddressValidator to simplify switching between libaddressinput | 54 // class is named AddressValidator to simplify switching between libaddressinput |
55 // and this version. | 55 // and this version. |
56 // | 56 // |
57 // It's not possible to name this file address_validator.h because some | 57 // It's not possible to name this file address_validator.h because some |
58 // compilers do not handle multiple files with the same name (although in | 58 // compilers do not handle multiple files with the same name (although in |
59 // different directories) gracefully. This class is a shim between upstream | 59 // different directories) gracefully. This class is a shim between upstream |
60 // libaddressinput API and the API that Chrome expects, hence the file name | 60 // libaddressinput API and the API that Chrome expects, hence the file name |
(...skipping 26 matching lines...) Expand all Loading... | |
87 // localities. A typical data size is 10KB. The largest is 250KB. If a region | 87 // localities. A typical data size is 10KB. The largest is 250KB. If a region |
88 // has language-specific validation rules, then these are also loaded. | 88 // has language-specific validation rules, then these are also loaded. |
89 // | 89 // |
90 // Example rule: | 90 // Example rule: |
91 // https://i18napis.appspot.com/ssl-aggregate-address/data/US | 91 // https://i18napis.appspot.com/ssl-aggregate-address/data/US |
92 // | 92 // |
93 // If the rules are already in progress of being loaded, it does nothing. | 93 // If the rules are already in progress of being loaded, it does nothing. |
94 // Invokes |load_rules_listener| when the loading has finished. | 94 // Invokes |load_rules_listener| when the loading has finished. |
95 virtual void LoadRules(const std::string& region_code); | 95 virtual void LoadRules(const std::string& region_code); |
96 | 96 |
97 // 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 // a country code, sub-region means the country's admin area. | |
100 // This function is called when the rules are ready. | |
sebsg
2017/03/21 15:29:52
nit: "This function should be called when the rule
Parastoo
2017/03/21 20:05:52
Done.
| |
101 virtual std::vector<std::string> GetRegionSubKeys( | |
102 const std::string& region_code); | |
103 | |
97 // Validates the |address| and populates |problems| with the validation | 104 // Validates the |address| and populates |problems| with the validation |
98 // problems, filtered according to the |filter| parameter. | 105 // problems, filtered according to the |filter| parameter. |
99 // | 106 // |
100 // If the |filter| is empty, then all discovered validation problems are | 107 // If the |filter| is empty, then all discovered validation problems are |
101 // returned. If the |filter| contains problem elements, then only the problems | 108 // returned. If the |filter| contains problem elements, then only the problems |
102 // in the |filter| may be returned. | 109 // in the |filter| may be returned. |
103 virtual Status ValidateAddress( | 110 virtual Status ValidateAddress( |
104 const ::i18n::addressinput::AddressData& address, | 111 const ::i18n::addressinput::AddressData& address, |
105 const ::i18n::addressinput::FieldProblemMap* filter, | 112 const ::i18n::addressinput::FieldProblemMap* filter, |
106 ::i18n::addressinput::FieldProblemMap* problems) const; | 113 ::i18n::addressinput::FieldProblemMap* problems) const; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 // any WeakPtrs to AddressValidator are invalidated before its members | 205 // any WeakPtrs to AddressValidator are invalidated before its members |
199 // variable's destructors are executed, rendering them invalid. | 206 // variable's destructors are executed, rendering them invalid. |
200 base::WeakPtrFactory<AddressValidator> weak_factory_; | 207 base::WeakPtrFactory<AddressValidator> weak_factory_; |
201 | 208 |
202 DISALLOW_COPY_AND_ASSIGN(AddressValidator); | 209 DISALLOW_COPY_AND_ASSIGN(AddressValidator); |
203 }; | 210 }; |
204 | 211 |
205 } // namespace autofill | 212 } // namespace autofill |
206 | 213 |
207 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_ADDRESS_VALIDATOR_H_ | 214 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_ADDRESS_VALIDATOR_H_ |
OLD | NEW |