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/autofill_payment_instrument.h" | 5 #include "components/payments/core/autofill_payment_instrument.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "components/autofill/core/browser/autofill_country.h" | 10 #include "components/autofill/core/browser/autofill_country.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 DCHECK(delegate_); | 106 DCHECK(delegate_); |
107 credit_card_ = card; | 107 credit_card_ = card; |
108 cvc_ = cvc; | 108 cvc_ = cvc; |
109 is_waiting_for_card_unmask_ = false; | 109 is_waiting_for_card_unmask_ = false; |
110 | 110 |
111 if (!is_waiting_for_billing_address_normalization_) | 111 if (!is_waiting_for_billing_address_normalization_) |
112 GenerateBasicCardResponse(); | 112 GenerateBasicCardResponse(); |
113 } | 113 } |
114 | 114 |
115 void AutofillPaymentInstrument::OnFullCardRequestFailed() { | 115 void AutofillPaymentInstrument::OnFullCardRequestFailed() { |
116 // TODO(anthonyvd): Do something with the error. | 116 // The user may have cancelled the unmask or something has gone wrong (e.g., |
| 117 // the network request failed). In all cases, reset the |delegate_| so another |
| 118 // request can start. |
117 delegate_ = nullptr; | 119 delegate_ = nullptr; |
118 } | 120 } |
119 | 121 |
120 void AutofillPaymentInstrument::OnAddressNormalized( | 122 void AutofillPaymentInstrument::OnAddressNormalized( |
121 const autofill::AutofillProfile& normalized_profile) { | 123 const autofill::AutofillProfile& normalized_profile) { |
122 DCHECK(is_waiting_for_billing_address_normalization_); | 124 DCHECK(is_waiting_for_billing_address_normalization_); |
123 | 125 |
124 billing_address_ = normalized_profile; | 126 billing_address_ = normalized_profile; |
125 is_waiting_for_billing_address_normalization_ = false; | 127 is_waiting_for_billing_address_normalization_ = false; |
126 | 128 |
(...skipping 19 matching lines...) Expand all Loading... |
146 .ToDictionaryValue(); | 148 .ToDictionaryValue(); |
147 std::string stringified_details; | 149 std::string stringified_details; |
148 base::JSONWriter::Write(*response_value, &stringified_details); | 150 base::JSONWriter::Write(*response_value, &stringified_details); |
149 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); | 151 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); |
150 | 152 |
151 delegate_ = nullptr; | 153 delegate_ = nullptr; |
152 cvc_ = base::UTF8ToUTF16(""); | 154 cvc_ = base::UTF8ToUTF16(""); |
153 } | 155 } |
154 | 156 |
155 } // namespace payments | 157 } // namespace payments |
OLD | NEW |