Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: ios/chrome/browser/ui/payments/payment_method_selection_mediator.mm

Issue 2956453003: [Payment Request] Makes sure only complete credit cards can be selected (Closed)
Patch Set: Fixed unit test Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 _paymentRequest->credit_cards(); 85 _paymentRequest->credit_cards();
86 _items = [NSMutableArray arrayWithCapacity:paymentMethods.size()]; 86 _items = [NSMutableArray arrayWithCapacity:paymentMethods.size()];
87 for (size_t index = 0; index < paymentMethods.size(); ++index) { 87 for (size_t index = 0; index < paymentMethods.size(); ++index) {
88 autofill::CreditCard* paymentMethod = paymentMethods[index]; 88 autofill::CreditCard* paymentMethod = paymentMethods[index];
89 DCHECK(paymentMethod); 89 DCHECK(paymentMethod);
90 PaymentMethodItem* item = [[PaymentMethodItem alloc] init]; 90 PaymentMethodItem* item = [[PaymentMethodItem alloc] init];
91 item.methodID = 91 item.methodID =
92 base::SysUTF16ToNSString(paymentMethod->NetworkAndLastFourDigits()); 92 base::SysUTF16ToNSString(paymentMethod->NetworkAndLastFourDigits());
93 item.methodDetail = base::SysUTF16ToNSString( 93 item.methodDetail = base::SysUTF16ToNSString(
94 paymentMethod->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL)); 94 paymentMethod->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL));
95 item.notification =
96 payment_request_util::GetPaymentMethodNotificationLabelFromCreditCard(
97 *paymentMethod, _paymentRequest->billing_profiles());
98 item.complete = payment_request_util::IsCreditCardCompleteForPayment(
99 *paymentMethod, _paymentRequest->billing_profiles());
95 100
96 autofill::AutofillProfile* billingAddress = 101 autofill::AutofillProfile* billingAddress =
97 autofill::PersonalDataManager::GetProfileFromProfilesByGUID( 102 autofill::PersonalDataManager::GetProfileFromProfilesByGUID(
98 paymentMethod->billing_address_id(), 103 paymentMethod->billing_address_id(),
99 _paymentRequest->billing_profiles()); 104 _paymentRequest->billing_profiles());
100 if (billingAddress) { 105 if (billingAddress) {
101 item.methodAddress = 106 item.methodAddress =
102 GetBillingAddressLabelFromAutofillProfile(*billingAddress); 107 GetBillingAddressLabelFromAutofillProfile(*billingAddress);
103 } 108 }
104 109
105 int methodTypeIconID = 110 int methodTypeIconID =
106 autofill::data_util::GetPaymentRequestData(paymentMethod->network()) 111 autofill::data_util::GetPaymentRequestData(paymentMethod->network())
107 .icon_resource_id; 112 .icon_resource_id;
108 item.methodTypeIcon = NativeImage(methodTypeIconID); 113 item.methodTypeIcon = NativeImage(methodTypeIconID);
109 114
110 item.reserveRoomForAccessoryType = YES; 115 item.reserveRoomForAccessoryType = YES;
111 if (_paymentRequest->selected_credit_card() == paymentMethod) 116 if (_paymentRequest->selected_credit_card() == paymentMethod)
112 _selectedItemIndex = index; 117 _selectedItemIndex = index;
113 118
114 [_items addObject:item]; 119 [_items addObject:item];
115 } 120 }
116 } 121 }
117 122
118 @end 123 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698