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/core/subkey_requester.h" | 5 #include "components/payments/core/subkey_requester.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 ~SubKeyRequest() override {} | 46 ~SubKeyRequest() override {} |
47 | 47 |
48 void OnRulesLoaded() override { | 48 void OnRulesLoaded() override { |
49 on_timeout_.Cancel(); | 49 on_timeout_.Cancel(); |
50 // Check if the timeout happened before the rules were loaded. | 50 // Check if the timeout happened before the rules were loaded. |
51 if (has_responded_) | 51 if (has_responded_) |
52 return; | 52 return; |
53 has_responded_ = true; | 53 has_responded_ = true; |
54 | 54 |
55 std::move(on_subkeys_received_) | 55 auto subkeys = address_validator_->GetRegionSubKeys(region_code_); |
56 .Run(address_validator_->GetRegionSubKeys(region_code_)); | 56 std::vector<std::string> subkeys_codes; |
| 57 std::vector<std::string> subkeys_names; |
| 58 for (auto s : subkeys) { |
| 59 subkeys_codes.push_back(s.first); |
| 60 subkeys_names.push_back(s.second); |
| 61 } |
| 62 std::move(on_subkeys_received_).Run(subkeys_codes, subkeys_names); |
57 } | 63 } |
58 | 64 |
59 private: | 65 private: |
60 std::string region_code_; | 66 std::string region_code_; |
61 // Not owned. Never null. Outlive this object. | 67 // Not owned. Never null. Outlive this object. |
62 autofill::AddressValidator* address_validator_; | 68 autofill::AddressValidator* address_validator_; |
63 | 69 |
64 SubKeyReceiverCallback on_subkeys_received_; | 70 SubKeyReceiverCallback on_subkeys_received_; |
65 | 71 |
66 bool has_responded_; | 72 bool has_responded_; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 pending_subkey_region_code_.clear(); | 126 pending_subkey_region_code_.clear(); |
121 pending_subkey_request_.reset(); | 127 pending_subkey_request_.reset(); |
122 } | 128 } |
123 | 129 |
124 void SubKeyRequester::CancelPendingGetSubKeys() { | 130 void SubKeyRequester::CancelPendingGetSubKeys() { |
125 pending_subkey_region_code_.clear(); | 131 pending_subkey_region_code_.clear(); |
126 pending_subkey_request_.reset(); | 132 pending_subkey_request_.reset(); |
127 } | 133 } |
128 | 134 |
129 } // namespace payments | 135 } // namespace payments |
OLD | NEW |