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

Side by Side Diff: components/payments/address_validator_helper.h

Issue 2686613003: [Payments] Move address normalization code from android to native. (Closed)
Patch Set: Created 3 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_PAYMENTS_ADDRESS_VALIDATOR_HELPER_H_
6 #define COMPONENTS_PAYMENTS_ADDRESS_VALIDATOR_HELPER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "components/autofill/core/browser/autofill_profile.h"
11 #include "third_party/libaddressinput/chromium/chrome_address_validator.h"
12
13 using autofill::AutofillProfile;
14
15 namespace payments {
16
17 // The interface for the normalization requesters.
18 class AddressNormalizationRequester {
please use gerrit instead 2017/02/14 21:31:09 nit: AddressNormalizer::Delegate
sebsg 2017/02/15 16:18:31 Done.
19 public:
please use gerrit instead 2017/02/14 21:31:08 Need a virtual destructor with empty body.
sebsg 2017/02/15 16:18:31 Done.
20 virtual void OnAddressNormalized(
21 autofill::AutofillProfile normalized_profile) = 0;
22 };
23
24 // The interface for the normalization request.
25 class NormalizationRequest {
please use gerrit instead 2017/02/14 21:31:09 nit: AddressNormalizer::Request
sebsg 2017/02/15 16:18:31 Done.
26 public:
27 virtual void OnRulesSuccessfullyLoaded() = 0;
28 virtual ~NormalizationRequest() {}
29 };
30
31 // A helper class to help with address validation and normalization.
32 class AddressValidatorHelper
please use gerrit instead 2017/02/14 21:31:09 nit: AddressNormalizer, because it does not valida
sebsg 2017/02/15 16:18:31 Done.
33 : public autofill::LoadRulesListener,
34 public base::SupportsWeakPtr<AddressValidatorHelper> {
35 public:
36 AddressValidatorHelper(std::unique_ptr<i18n::addressinput::Source> source,
37 std::unique_ptr<i18n::addressinput::Storage> storage);
38 ~AddressValidatorHelper() override;
39
40 // Start loading the validation rules for the specified |region_code|.
41 void LoadRulesForRegion(const std::string& region_code);
42
43 // Returns whether the rules for the specified |region_code| have finished
44 // loading.
45 bool AreRulesLoadedForRegion(const std::string& region_code);
46
47 // Starts the normalization of the |profile| based on the |region_code|. The
48 // normalized profile will be returned to the |requester|. Returns true if the
49 // normalization will happen asynchronously.
50 bool StartAddressNormalization(autofill::AutofillProfile profile,
please use gerrit instead 2017/02/14 21:31:09 const-ref for profile You seem to have changed th
sebsg 2017/02/15 16:18:31 Done.
51 const std::string region_code,
please use gerrit instead 2017/02/14 21:31:09 const-ref for region_code
sebsg 2017/02/15 16:18:30 Done.
52 AddressNormalizationRequester* requester);
53
54 private:
55 void OnAddressValidationRulesLoaded(const std::string& region_code,
please use gerrit instead 2017/02/14 21:31:09 Specify the interface being implemented.
sebsg 2017/02/15 16:18:31 Done.
56 bool success) override;
57
58 // Map associating a region code to pending normalizations.
59 std::map<std::string, std::vector<std::unique_ptr<NormalizationRequest>>>
60 pending_normalization_;
61
62 // The address validator used to normalize addresses.
63 autofill::AddressValidator address_validator_;
64 };
please use gerrit instead 2017/02/14 21:31:09 DISALLOW_COPY_AND_ASSIGN
sebsg 2017/02/15 16:18:31 Done.
65
66 } // namespace payments
67
68 #endif // COMPONENTS_PAYMENTS_ADDRESS_VALIDATOR_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698