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 <vector> | 5 #include <vector> |
6 | 6 |
7 #import "ios/chrome/browser/ui/payments/payment_method_selection_mediator.h" | 7 #import "ios/chrome/browser/ui/payments/payment_method_selection_mediator.h" |
8 | 8 |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "components/autofill/core/browser/autofill_data_util.h" | 10 #include "components/autofill/core/browser/autofill_data_util.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 - (NSArray<PaymentMethodItem*>*)createItems { | 84 - (NSArray<PaymentMethodItem*>*)createItems { |
85 const std::vector<autofill::CreditCard*>& paymentMethods = | 85 const std::vector<autofill::CreditCard*>& paymentMethods = |
86 _paymentRequest->credit_cards(); | 86 _paymentRequest->credit_cards(); |
87 NSMutableArray<PaymentMethodItem*>* items = | 87 NSMutableArray<PaymentMethodItem*>* items = |
88 [NSMutableArray arrayWithCapacity:paymentMethods.size()]; | 88 [NSMutableArray arrayWithCapacity:paymentMethods.size()]; |
89 for (size_t index = 0; index < paymentMethods.size(); ++index) { | 89 for (size_t index = 0; index < paymentMethods.size(); ++index) { |
90 autofill::CreditCard* paymentMethod = paymentMethods[index]; | 90 autofill::CreditCard* paymentMethod = paymentMethods[index]; |
91 DCHECK(paymentMethod); | 91 DCHECK(paymentMethod); |
92 PaymentMethodItem* item = [[PaymentMethodItem alloc] init]; | 92 PaymentMethodItem* item = [[PaymentMethodItem alloc] init]; |
93 item.methodID = | 93 item.methodID = |
94 base::SysUTF16ToNSString(paymentMethod->TypeAndLastFourDigits()); | 94 base::SysUTF16ToNSString(paymentMethod->NetworkAndLastFourDigits()); |
95 item.methodDetail = base::SysUTF16ToNSString( | 95 item.methodDetail = base::SysUTF16ToNSString( |
96 paymentMethod->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL)); | 96 paymentMethod->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL)); |
97 | 97 |
98 autofill::AutofillProfile* billingAddress = | 98 autofill::AutofillProfile* billingAddress = |
99 autofill::PersonalDataManager::GetProfileFromProfilesByGUID( | 99 autofill::PersonalDataManager::GetProfileFromProfilesByGUID( |
100 paymentMethod->billing_address_id(), | 100 paymentMethod->billing_address_id(), |
101 _paymentRequest->billing_profiles()); | 101 _paymentRequest->billing_profiles()); |
102 if (billingAddress) { | 102 if (billingAddress) { |
103 item.methodAddress = | 103 item.methodAddress = |
104 GetBillingAddressLabelFromAutofillProfile(*billingAddress); | 104 GetBillingAddressLabelFromAutofillProfile(*billingAddress); |
105 } | 105 } |
106 | 106 |
107 int methodTypeIconID = | 107 int methodTypeIconID = |
108 autofill::data_util::GetPaymentRequestData(paymentMethod->type()) | 108 autofill::data_util::GetPaymentRequestData(paymentMethod->network()) |
109 .icon_resource_id; | 109 .icon_resource_id; |
110 item.methodTypeIcon = NativeImage(methodTypeIconID); | 110 item.methodTypeIcon = NativeImage(methodTypeIconID); |
111 | 111 |
112 item.reserveRoomForAccessoryType = YES; | 112 item.reserveRoomForAccessoryType = YES; |
113 if (_paymentRequest->selected_credit_card() == paymentMethod) | 113 if (_paymentRequest->selected_credit_card() == paymentMethod) |
114 _selectedItemIndex = index; | 114 _selectedItemIndex = index; |
115 | 115 |
116 [items addObject:item]; | 116 [items addObject:item]; |
117 } | 117 } |
118 return items; | 118 return items; |
119 } | 119 } |
120 | 120 |
121 @end | 121 @end |
OLD | NEW |