Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_CORE_SUBKEY_REQUESTER_H_ | |
| 6 #define COMPONENTS_PAYMENTS_CORE_SUBKEY_REQUESTER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "components/autofill/core/browser/autofill_profile.h" | |
|
sebsg
2017/05/18 17:50:51
needed?
Parastoo
2017/05/18 20:59:45
Done.
| |
| 10 #include "third_party/libaddressinput/chromium/chrome_address_validator.h" | |
| 11 | |
| 12 using autofill::AutofillProfile; | |
|
sebsg
2017/05/18 17:50:51
needed?
Parastoo
2017/05/18 20:59:45
Done.
| |
| 13 | |
| 14 namespace payments { | |
| 15 | |
| 16 // SubKeyRequester Load Rules from the server and extracts the subkeys. | |
|
sebsg
2017/05/18 17:50:51
Can you give a short description of what a subkey
Parastoo
2017/05/18 20:59:46
Done.
| |
| 17 class SubKeyRequester : public autofill::LoadRulesListener { | |
| 18 public: | |
| 19 // The interface for the subkey request delegates. | |
| 20 class Delegate { | |
| 21 public: | |
| 22 virtual void OnSubKeysReceived(std::vector<std::string> sub_keys) = 0; | |
| 23 virtual ~Delegate() {} | |
| 24 }; | |
| 25 | |
| 26 // The interface for the subkey request. | |
| 27 class Request { | |
| 28 public: | |
| 29 virtual void OnRulesLoaded() = 0; | |
| 30 virtual ~Request() {} | |
| 31 }; | |
| 32 | |
| 33 SubKeyRequester(std::unique_ptr<i18n::addressinput::Source> source, | |
| 34 std::unique_ptr<i18n::addressinput::Storage> storage); | |
| 35 ~SubKeyRequester() override; | |
| 36 | |
| 37 void StartRegionSubKeysRequest(const std::string& region_code, | |
|
sebsg
2017/05/18 17:50:51
Could you please add a short comment?
For exampl
Parastoo
2017/05/18 20:59:45
Done.
| |
| 38 int timeout_seconds, | |
| 39 Delegate* requester); | |
| 40 | |
| 41 // Returns whether the rules for the specified |region_code| have finished | |
| 42 // loading. | |
| 43 bool AreRulesLoadedForRegion(const std::string& region_code); | |
| 44 | |
| 45 // Start loading the rules for the specified |region_code|. | |
| 46 virtual void LoadRulesForRegion(const std::string& region_code); | |
| 47 | |
| 48 // Cancels the pending subkey request task. | |
| 49 void CancelPendingGetSubKeys(); | |
| 50 | |
| 51 private: | |
| 52 // Called when the address rules for the |region_code| have finished | |
| 53 // loading. Implementation of the LoadRulesListener interface. | |
| 54 void OnAddressValidationRulesLoaded(const std::string& region_code, | |
| 55 bool success) override; | |
| 56 | |
| 57 // The region code and the request for the pending subkey request. | |
| 58 std::unique_ptr<Request> pending_subkey_request_; | |
| 59 std::string pending_subkey_region_code_; | |
| 60 | |
| 61 // The address validator used to load subkeys. | |
| 62 autofill::AddressValidator address_validator_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(SubKeyRequester); | |
| 65 }; | |
| 66 | |
| 67 } // namespace payments | |
| 68 | |
| 69 #endif // COMPONENTS_PAYMENTS_CORE_SUBKEY_REQUESTER_H_ | |
| OLD | NEW |