Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: components/payments/core/address_normalizer.h

Issue 2829903004: Reland: Normalize shipping address for merchant on Desktop. (Closed)
Patch Set: Original CL (crrev.com/2829503002) Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "third_party/libaddressinput/chromium/chrome_address_validator.h" 14 #include "third_party/libaddressinput/chromium/chrome_address_validator.h"
15 15
16 namespace autofill { 16 namespace autofill {
17 class AutofillProfile; 17 class AutofillProfile;
18 } 18 }
19 19
20 namespace i18n { 20 namespace i18n {
21 namespace libadderssinput { 21 namespace libadderssinput {
please use gerrit instead 2017/04/21 15:07:02 This was misspelled btw.
sebsg 2017/04/21 15:17:48 Done.
22 class Source; 22 class Source;
23 class Storage; 23 class Storage;
24 } 24 }
25 } 25 }
26 26
27 namespace payments { 27 namespace payments {
28 28
29 // A class used to normalize addresses. 29 // A class used to normalize addresses.
30 class AddressNormalizer : public autofill::LoadRulesListener { 30 class AddressNormalizer : public autofill::LoadRulesListener {
31 public: 31 public:
(...skipping 19 matching lines...) Expand all
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 bool AreRulesLoadedForRegion(const std::string& region_code); 61 virtual 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 void StartAddressNormalization(const autofill::AutofillProfile& profile, 71 virtual void StartAddressNormalization(
72 const std::string& region_code, 72 const autofill::AutofillProfile& profile,
73 int timeout_seconds, 73 const std::string& region_code,
74 Delegate* requester); 74 int timeout_seconds,
75 Delegate* requester);
75 76
76 private: 77 private:
77 // Called when the validation rules for the |region_code| have finished 78 // Called when the validation rules for the |region_code| have finished
78 // loading. Implementation of the LoadRulesListener interface. 79 // loading. Implementation of the LoadRulesListener interface.
79 void OnAddressValidationRulesLoaded(const std::string& region_code, 80 void OnAddressValidationRulesLoaded(const std::string& region_code,
80 bool success) override; 81 bool success) override;
81 82
82 // Map associating a region code to pending normalizations. 83 // Map associating a region code to pending normalizations.
83 std::map<std::string, std::vector<std::unique_ptr<Request>>> 84 std::map<std::string, std::vector<std::unique_ptr<Request>>>
84 pending_normalization_; 85 pending_normalization_;
85 86
86 // The address validator used to normalize addresses. 87 // The address validator used to normalize addresses.
87 autofill::AddressValidator address_validator_; 88 autofill::AddressValidator address_validator_;
88 89
89 DISALLOW_COPY_AND_ASSIGN(AddressNormalizer); 90 DISALLOW_COPY_AND_ASSIGN(AddressNormalizer);
90 }; 91 };
91 92
92 } // namespace payments 93 } // namespace payments
93 94
94 #endif // COMPONENTS_PAYMENTS_CORE_ADDRESS_NORMALIZER_H_ 95 #endif // COMPONENTS_PAYMENTS_CORE_ADDRESS_NORMALIZER_H_
OLDNEW
« no previous file with comments | « components/payments/content/payment_response_helper_unittest.cc ('k') | components/payments/core/payment_request_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698