| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 COMPONENTS_PAYMENTS_CORE_ADDRESS_NORMALIZER_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CORE_ADDRESS_NORMALIZER_H_ |
| 6 #define COMPONENTS_PAYMENTS_CORE_ADDRESS_NORMALIZER_H_ | 6 #define COMPONENTS_PAYMENTS_CORE_ADDRESS_NORMALIZER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 AddressNormalizer(std::unique_ptr<::i18n::addressinput::Source> source, | 52 AddressNormalizer(std::unique_ptr<::i18n::addressinput::Source> source, |
| 53 std::unique_ptr<::i18n::addressinput::Storage> storage); | 53 std::unique_ptr<::i18n::addressinput::Storage> storage); |
| 54 ~AddressNormalizer() override; | 54 ~AddressNormalizer() override; |
| 55 | 55 |
| 56 // Start loading the validation rules for the specified |region_code|. | 56 // Start loading the validation rules for the specified |region_code|. |
| 57 virtual void LoadRulesForRegion(const std::string& region_code); | 57 virtual void LoadRulesForRegion(const std::string& region_code); |
| 58 | 58 |
| 59 // Returns whether the rules for the specified |region_code| have finished | 59 // Returns whether the rules for the specified |region_code| have finished |
| 60 // loading. | 60 // loading. |
| 61 virtual bool AreRulesLoadedForRegion(const std::string& region_code); | 61 bool AreRulesLoadedForRegion(const std::string& region_code); |
| 62 | 62 |
| 63 // Starts the normalization of the |profile| based on the |region_code|. The | 63 // Starts the normalization of the |profile| based on the |region_code|. The |
| 64 // normalized profile will be returned to the |requester| possibly | 64 // normalized profile will be returned to the |requester| possibly |
| 65 // asynchronously. If the normalization is not completed in |timeout_seconds| | 65 // asynchronously. If the normalization is not completed in |timeout_seconds| |
| 66 // the requester will be informed and the request cancelled. This value should | 66 // the requester will be informed and the request cancelled. This value should |
| 67 // be greater or equal to 0, for which it means that the normalization should | 67 // be greater or equal to 0, for which it means that the normalization should |
| 68 // happen synchronously, or not at all if the rules are not already loaded. | 68 // happen synchronously, or not at all if the rules are not already loaded. |
| 69 // Will start loading the rules for the |region_code| if they had not started | 69 // Will start loading the rules for the |region_code| if they had not started |
| 70 // loading. | 70 // loading. |
| 71 virtual void StartAddressNormalization( | 71 void StartAddressNormalization(const autofill::AutofillProfile& profile, |
| 72 const autofill::AutofillProfile& profile, | 72 const std::string& region_code, |
| 73 const std::string& region_code, | 73 int timeout_seconds, |
| 74 int timeout_seconds, | 74 Delegate* requester); |
| 75 Delegate* requester); | |
| 76 | 75 |
| 77 private: | 76 private: |
| 78 // Called when the validation rules for the |region_code| have finished | 77 // Called when the validation rules for the |region_code| have finished |
| 79 // loading. Implementation of the LoadRulesListener interface. | 78 // loading. Implementation of the LoadRulesListener interface. |
| 80 void OnAddressValidationRulesLoaded(const std::string& region_code, | 79 void OnAddressValidationRulesLoaded(const std::string& region_code, |
| 81 bool success) override; | 80 bool success) override; |
| 82 | 81 |
| 83 // Map associating a region code to pending normalizations. | 82 // Map associating a region code to pending normalizations. |
| 84 std::map<std::string, std::vector<std::unique_ptr<Request>>> | 83 std::map<std::string, std::vector<std::unique_ptr<Request>>> |
| 85 pending_normalization_; | 84 pending_normalization_; |
| 86 | 85 |
| 87 // The address validator used to normalize addresses. | 86 // The address validator used to normalize addresses. |
| 88 autofill::AddressValidator address_validator_; | 87 autofill::AddressValidator address_validator_; |
| 89 | 88 |
| 90 DISALLOW_COPY_AND_ASSIGN(AddressNormalizer); | 89 DISALLOW_COPY_AND_ASSIGN(AddressNormalizer); |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 } // namespace payments | 92 } // namespace payments |
| 94 | 93 |
| 95 #endif // COMPONENTS_PAYMENTS_CORE_ADDRESS_NORMALIZER_H_ | 94 #endif // COMPONENTS_PAYMENTS_CORE_ADDRESS_NORMALIZER_H_ |
| OLD | NEW |