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/payment_request_data_util.h" | 5 #include "components/payments/core/payment_request_data_util.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 address.recipient = | 64 address.recipient = |
65 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), app_locale); | 65 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), app_locale); |
66 address.phone = profile.GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER); | 66 address.phone = profile.GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER); |
67 | 67 |
68 return address; | 68 return address; |
69 } | 69 } |
70 | 70 |
71 BasicCardResponse GetBasicCardResponseFromAutofillCreditCard( | 71 BasicCardResponse GetBasicCardResponseFromAutofillCreditCard( |
72 const autofill::CreditCard& card, | 72 const autofill::CreditCard& card, |
73 const base::string16& cvc, | 73 const base::string16& cvc, |
74 const std::vector<autofill::AutofillProfile*>& billing_profiles, | 74 const autofill::AutofillProfile& billing_profile, |
75 const std::string& app_locale) { | 75 const std::string& app_locale) { |
76 BasicCardResponse response; | 76 BasicCardResponse response; |
77 response.cardholder_name = card.GetRawInfo(autofill::CREDIT_CARD_NAME_FULL); | 77 response.cardholder_name = card.GetRawInfo(autofill::CREDIT_CARD_NAME_FULL); |
78 response.card_number = card.GetRawInfo(autofill::CREDIT_CARD_NUMBER); | 78 response.card_number = card.GetRawInfo(autofill::CREDIT_CARD_NUMBER); |
79 response.expiry_month = card.GetRawInfo(autofill::CREDIT_CARD_EXP_MONTH); | 79 response.expiry_month = card.GetRawInfo(autofill::CREDIT_CARD_EXP_MONTH); |
80 response.expiry_year = | 80 response.expiry_year = |
81 card.GetRawInfo(autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR); | 81 card.GetRawInfo(autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR); |
82 response.card_security_code = cvc; | 82 response.card_security_code = cvc; |
83 | 83 |
84 // TODO(crbug.com/602666): Ensure we reach here only if the card has a billing | 84 response.billing_address = |
85 // address. Then add DCHECK(!card->billing_address_id().empty()). | 85 GetPaymentAddressFromAutofillProfile(billing_profile, app_locale); |
86 if (!card.billing_address_id().empty()) { | |
87 const autofill::AutofillProfile* billing_address = | |
88 autofill::PersonalDataManager::GetProfileFromProfilesByGUID( | |
89 card.billing_address_id(), billing_profiles); | |
90 DCHECK(billing_address); | |
91 response.billing_address = | |
92 GetPaymentAddressFromAutofillProfile(*billing_address, app_locale); | |
93 } | |
94 | 86 |
95 return response; | 87 return response; |
96 } | 88 } |
97 | 89 |
98 void ParseBasicCardSupportedNetworks( | 90 void ParseBasicCardSupportedNetworks( |
99 const std::vector<PaymentMethodData>& method_data, | 91 const std::vector<PaymentMethodData>& method_data, |
100 std::vector<std::string>* out_supported_networks, | 92 std::vector<std::string>* out_supported_networks, |
101 std::set<std::string>* out_basic_card_specified_networks) { | 93 std::set<std::string>* out_basic_card_specified_networks) { |
102 DCHECK(out_supported_networks->empty()); | 94 DCHECK(out_supported_networks->empty()); |
103 DCHECK(out_basic_card_specified_networks->empty()); | 95 DCHECK(out_basic_card_specified_networks->empty()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 157 } |
166 | 158 |
167 std::string FormatPhoneForResponse(const std::string& phone_number, | 159 std::string FormatPhoneForResponse(const std::string& phone_number, |
168 const std::string& country_code) { | 160 const std::string& country_code) { |
169 return FormatPhoneNumber(phone_number, country_code, | 161 return FormatPhoneNumber(phone_number, country_code, |
170 PhoneNumberUtil::PhoneNumberFormat::E164); | 162 PhoneNumberUtil::PhoneNumberFormat::E164); |
171 } | 163 } |
172 | 164 |
173 } // namespace data_util | 165 } // namespace data_util |
174 } // namespace payments | 166 } // namespace payments |
OLD | NEW |