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

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

Issue 2963163002: [Payment Request] Displays accepted card types (credit, debit, etc) in iOS (Closed)
Patch Set: Addressed comment 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
« no previous file with comments | « ios/chrome/browser/ui/payments/credit_card_edit_mediator.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/string16.h"
9 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
10 #include "components/autofill/core/browser/autofill_data_util.h" 11 #include "components/autofill/core/browser/autofill_data_util.h"
11 #include "components/autofill/core/browser/autofill_profile.h" 12 #include "components/autofill/core/browser/autofill_profile.h"
12 #include "components/autofill/core/browser/credit_card.h" 13 #include "components/autofill/core/browser/credit_card.h"
13 #include "components/autofill/core/browser/personal_data_manager.h" 14 #include "components/autofill/core/browser/personal_data_manager.h"
15 #include "components/payments/core/strings_util.h"
14 #include "components/strings/grit/components_strings.h" 16 #include "components/strings/grit/components_strings.h"
15 #include "ios/chrome/browser/payments/payment_request.h" 17 #include "ios/chrome/browser/payments/payment_request.h"
16 #include "ios/chrome/browser/payments/payment_request_util.h" 18 #include "ios/chrome/browser/payments/payment_request_util.h"
17 #import "ios/chrome/browser/ui/payments/cells/payment_method_item.h" 19 #import "ios/chrome/browser/ui/payments/cells/payment_method_item.h"
18 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h" 20 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h"
19 #include "ios/chrome/browser/ui/uikit_ui_util.h" 21 #include "ios/chrome/browser/ui/uikit_ui_util.h"
20 #include "ios/chrome/grit/ios_theme_resources.h" 22 #include "ios/chrome/grit/ios_theme_resources.h"
21 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
22 24
23 #if !defined(__has_feature) || !__has_feature(objc_arc) 25 #if !defined(__has_feature) || !__has_feature(objc_arc)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return self; 59 return self;
58 } 60 }
59 61
60 #pragma mark - PaymentRequestSelectorViewControllerDataSource 62 #pragma mark - PaymentRequestSelectorViewControllerDataSource
61 63
62 - (BOOL)allowsEditMode { 64 - (BOOL)allowsEditMode {
63 return YES; 65 return YES;
64 } 66 }
65 67
66 - (CollectionViewItem*)headerItem { 68 - (CollectionViewItem*)headerItem {
67 return nil; 69 base::string16 headerText = payments::GetCardTypesAreAcceptedText(
70 _paymentRequest->supported_card_types_set());
71 if (headerText.empty())
72 return nil;
73
74 PaymentsTextItem* headerItem = [[PaymentsTextItem alloc] init];
75 headerItem.text = base::SysUTF16ToNSString(headerText);
76 return headerItem;
68 } 77 }
69 78
70 - (NSArray<CollectionViewItem*>*)selectableItems { 79 - (NSArray<CollectionViewItem*>*)selectableItems {
71 return self.items; 80 return self.items;
72 } 81 }
73 82
74 - (CollectionViewItem*)addButtonItem { 83 - (CollectionViewItem*)addButtonItem {
75 PaymentsTextItem* addButtonItem = [[PaymentsTextItem alloc] init]; 84 PaymentsTextItem* addButtonItem = [[PaymentsTextItem alloc] init];
76 addButtonItem.text = l10n_util::GetNSString(IDS_PAYMENTS_ADD_CARD); 85 addButtonItem.text = l10n_util::GetNSString(IDS_PAYMENTS_ADD_CARD);
77 addButtonItem.image = NativeImage(IDR_IOS_PAYMENTS_ADD); 86 addButtonItem.image = NativeImage(IDR_IOS_PAYMENTS_ADD);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 123
115 item.reserveRoomForAccessoryType = YES; 124 item.reserveRoomForAccessoryType = YES;
116 if (_paymentRequest->selected_credit_card() == paymentMethod) 125 if (_paymentRequest->selected_credit_card() == paymentMethod)
117 _selectedItemIndex = index; 126 _selectedItemIndex = index;
118 127
119 [_items addObject:item]; 128 [_items addObject:item];
120 } 129 }
121 } 130 }
122 131
123 @end 132 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/payments/credit_card_edit_mediator.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698