Index: components/payments/core/subkey_requester.h |
diff --git a/components/payments/core/subkey_requester.h b/components/payments/core/subkey_requester.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..75b99c0db5b181a693292d5a0a189738430b5387 |
--- /dev/null |
+++ b/components/payments/core/subkey_requester.h |
@@ -0,0 +1,69 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_PAYMENTS_CORE_SUBKEY_REQUESTER_H_ |
+#define COMPONENTS_PAYMENTS_CORE_SUBKEY_REQUESTER_H_ |
+ |
+#include "base/macros.h" |
+#include "components/autofill/core/browser/autofill_profile.h" |
sebsg
2017/05/18 17:50:51
needed?
Parastoo
2017/05/18 20:59:45
Done.
|
+#include "third_party/libaddressinput/chromium/chrome_address_validator.h" |
+ |
+using autofill::AutofillProfile; |
sebsg
2017/05/18 17:50:51
needed?
Parastoo
2017/05/18 20:59:45
Done.
|
+ |
+namespace payments { |
+ |
+// 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.
|
+class SubKeyRequester : public autofill::LoadRulesListener { |
+ public: |
+ // The interface for the subkey request delegates. |
+ class Delegate { |
+ public: |
+ virtual void OnSubKeysReceived(std::vector<std::string> sub_keys) = 0; |
+ virtual ~Delegate() {} |
+ }; |
+ |
+ // The interface for the subkey request. |
+ class Request { |
+ public: |
+ virtual void OnRulesLoaded() = 0; |
+ virtual ~Request() {} |
+ }; |
+ |
+ SubKeyRequester(std::unique_ptr<i18n::addressinput::Source> source, |
+ std::unique_ptr<i18n::addressinput::Storage> storage); |
+ ~SubKeyRequester() override; |
+ |
+ 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.
|
+ int timeout_seconds, |
+ Delegate* requester); |
+ |
+ // Returns whether the rules for the specified |region_code| have finished |
+ // loading. |
+ bool AreRulesLoadedForRegion(const std::string& region_code); |
+ |
+ // Start loading the rules for the specified |region_code|. |
+ virtual void LoadRulesForRegion(const std::string& region_code); |
+ |
+ // Cancels the pending subkey request task. |
+ void CancelPendingGetSubKeys(); |
+ |
+ private: |
+ // Called when the address rules for the |region_code| have finished |
+ // loading. Implementation of the LoadRulesListener interface. |
+ void OnAddressValidationRulesLoaded(const std::string& region_code, |
+ bool success) override; |
+ |
+ // The region code and the request for the pending subkey request. |
+ std::unique_ptr<Request> pending_subkey_request_; |
+ std::string pending_subkey_region_code_; |
+ |
+ // The address validator used to load subkeys. |
+ autofill::AddressValidator address_validator_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SubKeyRequester); |
+}; |
+ |
+} // namespace payments |
+ |
+#endif // COMPONENTS_PAYMENTS_CORE_SUBKEY_REQUESTER_H_ |