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 <memory> |
| 8 |
7 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 11 #include "base/values.h" |
10 #include "components/autofill/core/browser/autofill_data_util.h" | 12 #include "components/autofill/core/browser/autofill_data_util.h" |
11 #include "components/autofill/core/browser/autofill_type.h" | 13 #include "components/autofill/core/browser/autofill_type.h" |
12 #include "components/autofill/core/browser/field_types.h" | 14 #include "components/autofill/core/browser/field_types.h" |
13 #include "components/autofill/core/browser/validation.h" | 15 #include "components/autofill/core/browser/validation.h" |
14 #include "components/autofill/core/common/autofill_clock.h" | 16 #include "components/autofill/core/common/autofill_clock.h" |
15 #include "components/payments/core/basic_card_response.h" | 17 #include "components/payments/core/basic_card_response.h" |
16 #include "components/payments/core/payment_request_data_util.h" | 18 #include "components/payments/core/payment_request_data_util.h" |
17 #include "components/payments/core/payment_request_delegate.h" | 19 #include "components/payments/core/payment_request_delegate.h" |
18 | 20 |
19 namespace payments { | 21 namespace payments { |
20 | 22 |
21 AutofillPaymentInstrument::AutofillPaymentInstrument( | 23 AutofillPaymentInstrument::AutofillPaymentInstrument( |
22 const std::string& method_name, | 24 const std::string& method_name, |
23 const autofill::CreditCard& card, | 25 const autofill::CreditCard& card, |
24 const std::vector<autofill::AutofillProfile*>& billing_profiles, | 26 const std::vector<autofill::AutofillProfile*>& billing_profiles, |
25 const std::string& app_locale, | 27 const std::string& app_locale, |
26 PaymentRequestDelegate* payment_request_delegate) | 28 PaymentRequestDelegate* payment_request_delegate) |
27 : PaymentInstrument( | 29 : PaymentInstrument( |
28 method_name, | 30 method_name, |
29 /* label= */ card.TypeAndLastFourDigits(), | 31 /* label= */ card.NetworkAndLastFourDigits(), |
30 /* sublabel= */ | 32 /* sublabel= */ |
31 card.GetInfo(autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL), | 33 card.GetInfo(autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL), |
32 app_locale), | 34 app_locale), |
33 autofill::data_util::GetPaymentRequestData(card.type()) | 35 autofill::data_util::GetPaymentRequestData(card.network()) |
34 .icon_resource_id, | 36 .icon_resource_id, |
35 PaymentInstrument::Type::AUTOFILL), | 37 PaymentInstrument::Type::AUTOFILL), |
36 credit_card_(card), | 38 credit_card_(card), |
37 billing_profiles_(billing_profiles), | 39 billing_profiles_(billing_profiles), |
38 app_locale_(app_locale), | 40 app_locale_(app_locale), |
39 delegate_(nullptr), | 41 delegate_(nullptr), |
40 payment_request_delegate_(payment_request_delegate), | 42 payment_request_delegate_(payment_request_delegate), |
41 weak_ptr_factory_(this) {} | 43 weak_ptr_factory_(this) {} |
42 AutofillPaymentInstrument::~AutofillPaymentInstrument() {} | 44 AutofillPaymentInstrument::~AutofillPaymentInstrument() {} |
43 | 45 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); | 89 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); |
88 delegate_ = nullptr; | 90 delegate_ = nullptr; |
89 } | 91 } |
90 | 92 |
91 void AutofillPaymentInstrument::OnFullCardRequestFailed() { | 93 void AutofillPaymentInstrument::OnFullCardRequestFailed() { |
92 // TODO(anthonyvd): Do something with the error. | 94 // TODO(anthonyvd): Do something with the error. |
93 delegate_ = nullptr; | 95 delegate_ = nullptr; |
94 } | 96 } |
95 | 97 |
96 } // namespace payments | 98 } // namespace payments |
OLD | NEW |