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

Unified Diff: ios/chrome/browser/payments/credit_card_edit_mediator.mm

Issue 2825143002: [Payment Request] Accepted credit card type icons in the credit card editor (Closed)
Patch Set: Initial Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/payments/credit_card_edit_mediator.mm
diff --git a/ios/chrome/browser/payments/credit_card_edit_mediator.mm b/ios/chrome/browser/payments/credit_card_edit_mediator.mm
index 9a9bdb994608ff2d80832f2dad44547d46de3eb3..53c059383fce0dba57d50aa33aec7f3b25a1329c 100644
--- a/ios/chrome/browser/payments/credit_card_edit_mediator.mm
+++ b/ios/chrome/browser/payments/credit_card_edit_mediator.mm
@@ -12,6 +12,7 @@
#import "components/autofill/ios/browser/credit_card_util.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/application_context.h"
+#import "ios/chrome/browser/payments/cells/accepted_payment_methods_item.h"
#import "ios/chrome/browser/payments/cells/payment_method_item.h"
#include "ios/chrome/browser/payments/payment_request.h"
#import "ios/chrome/browser/payments/payment_request_editor_field.h"
@@ -27,6 +28,8 @@
namespace {
using ::AutofillUITypeFromAutofillType;
+using ::autofill::data_util::GetCardTypeForBasicCardPaymentType;
+using ::autofill::data_util::GetPaymentRequestData;
using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile;
const CGFloat kCardTypeIconDimension = 25.0;
@@ -81,6 +84,31 @@ const CGFloat kCardTypeIconDimension = 25.0;
return cardSummaryItem;
}
+- (CollectionViewItem*)acceptedPaymentMethodsItem {
+ if (_creditCard && !autofill::IsCreditCardLocal(*_creditCard))
+ return nil;
+
+ NSMutableArray* cardTypeIcons = [NSMutableArray array];
+ for (const auto& supportedNetwork :
+ _paymentRequest->supported_card_networks()) {
+ const std::string cardType =
+ GetCardTypeForBasicCardPaymentType(supportedNetwork);
+ int resourceID = GetPaymentRequestData(cardType).icon_resource_id;
+ UIImage* cardTypeIcon =
+ ResizeImage(NativeImage(resourceID),
+ CGSizeMake(kCardTypeIconDimension, kCardTypeIconDimension),
+ ProjectionMode::kAspectFillNoClipping);
+ [cardTypeIcons addObject:cardTypeIcon];
+ }
+
+ AcceptedPaymentMethodsItem* acceptedMethodsItem =
+ [[AcceptedPaymentMethodsItem alloc] init];
+ acceptedMethodsItem.message =
+ l10n_util::GetNSString(IDS_PAYMENTS_ACCEPTED_CARDS_LABEL);
+ acceptedMethodsItem.methodTypeIcons = cardTypeIcons;
+ return acceptedMethodsItem;
+}
+
- (NSString*)billingAddressLabelForProfileWithGUID:(NSString*)profileGUID {
DCHECK(profileGUID);
autofill::AutofillProfile* profile =

Powered by Google App Engine
This is Rietveld 408576698