| 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 #include "components/payments/address_normalizer.h" | 5 #include "components/payments/core/address_normalizer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" |
| 10 #include "base/cancelable_callback.h" | 12 #include "base/cancelable_callback.h" |
| 13 #include "base/location.h" |
| 14 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/threading/sequenced_task_runner_handle.h" | 17 #include "base/threading/sequenced_task_runner_handle.h" |
| 18 #include "base/time/time.h" |
| 14 #include "components/autofill/core/browser/address_i18n.h" | 19 #include "components/autofill/core/browser/address_i18n.h" |
| 20 #include "components/autofill/core/browser/autofill_profile.h" |
| 15 #include "third_party/libaddressinput/chromium/chrome_address_validator.h" | 21 #include "third_party/libaddressinput/chromium/chrome_address_validator.h" |
| 16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" | 22 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
| 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h" | 23 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h" |
| 18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h" | 24 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h" |
| 19 | 25 |
| 26 namespace payments { |
| 20 namespace { | 27 namespace { |
| 28 |
| 29 using ::autofill::AutofillProfile; |
| 21 using ::i18n::addressinput::Source; | 30 using ::i18n::addressinput::Source; |
| 22 using ::i18n::addressinput::Storage; | 31 using ::i18n::addressinput::Storage; |
| 23 } // namespace | |
| 24 | |
| 25 namespace payments { | |
| 26 | |
| 27 namespace { | |
| 28 | 32 |
| 29 class AddressNormalizationRequest : public AddressNormalizer::Request { | 33 class AddressNormalizationRequest : public AddressNormalizer::Request { |
| 30 public: | 34 public: |
| 31 // The |delegate| and |address_validator| need to outlive this Request. | 35 // The |delegate| and |address_validator| need to outlive this Request. |
| 32 AddressNormalizationRequest(const AutofillProfile& profile, | 36 AddressNormalizationRequest(const AutofillProfile& profile, |
| 33 const std::string& region_code, | 37 const std::string& region_code, |
| 34 int timeout_seconds, | 38 int timeout_seconds, |
| 35 AddressNormalizer::Delegate* delegate, | 39 AddressNormalizer::Delegate* delegate, |
| 36 autofill::AddressValidator* address_validator) | 40 autofill::AddressValidator* address_validator) |
| 37 : profile_(profile), | 41 : profile_(profile), |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 auto it = pending_normalization_.find(region_code); | 160 auto it = pending_normalization_.find(region_code); |
| 157 if (it != pending_normalization_.end()) { | 161 if (it != pending_normalization_.end()) { |
| 158 for (size_t i = 0; i < it->second.size(); ++i) { | 162 for (size_t i = 0; i < it->second.size(); ++i) { |
| 159 it->second[i]->OnRulesLoaded(success); | 163 it->second[i]->OnRulesLoaded(success); |
| 160 } | 164 } |
| 161 pending_normalization_.erase(it); | 165 pending_normalization_.erase(it); |
| 162 } | 166 } |
| 163 } | 167 } |
| 164 | 168 |
| 165 } // namespace payments | 169 } // namespace payments |
| OLD | NEW |