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

Side by Side Diff: ios/chrome/browser/payments/payment_method_selection_view_controller.mm

Issue 2635983002: Revert of EarlGrey tests for Payment Request (base CL) (Closed)
Patch Set: Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "ios/chrome/browser/payments/payment_method_selection_view_controller.h" 5 #import "ios/chrome/browser/payments/payment_method_selection_view_controller.h"
6 6
7 #import "base/ios/weak_nsobject.h" 7 #import "base/ios/weak_nsobject.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 - (instancetype)init { 56 - (instancetype)init {
57 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { 57 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) {
58 [self setTitle:l10n_util::GetNSString( 58 [self setTitle:l10n_util::GetNSString(
59 IDS_IOS_PAYMENT_REQUEST_METHOD_SELECTION_TITLE)]; 59 IDS_IOS_PAYMENT_REQUEST_METHOD_SELECTION_TITLE)];
60 60
61 UIBarButtonItem* returnButton = 61 UIBarButtonItem* returnButton =
62 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] 62 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon]
63 target:nil 63 target:nil
64 action:@selector(onReturn)]; 64 action:@selector(onReturn)];
65 returnButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_BACK);
66 [self navigationItem].leftBarButtonItem = returnButton; 65 [self navigationItem].leftBarButtonItem = returnButton;
67 } 66 }
68 return self; 67 return self;
69 } 68 }
70 69
71 - (id<PaymentMethodSelectionViewControllerDelegate>)delegate { 70 - (id<PaymentMethodSelectionViewControllerDelegate>)delegate {
72 return _delegate.get(); 71 return _delegate.get();
73 } 72 }
74 73
75 - (void)setDelegate:(id<PaymentMethodSelectionViewControllerDelegate>)delegate { 74 - (void)setDelegate:(id<PaymentMethodSelectionViewControllerDelegate>)delegate {
76 _delegate.reset(delegate); 75 _delegate.reset(delegate);
77 } 76 }
78 77
79 - (void)onReturn { 78 - (void)onReturn {
80 [_delegate paymentMethodSelectionViewControllerDidReturn:self]; 79 [_delegate paymentMethodSelectionViewControllerDidReturn:self];
81 } 80 }
82 81
83 #pragma mark - CollectionViewController methods 82 #pragma mark - CollectionViewController methods
84 83
85 - (void)loadModel { 84 - (void)loadModel {
86 [super loadModel]; 85 [super loadModel];
87 CollectionViewModel* model = self.collectionViewModel; 86 CollectionViewModel* model = self.collectionViewModel;
88 87
89 [model addSectionWithIdentifier:SectionIdentifierPayment]; 88 [model addSectionWithIdentifier:SectionIdentifierPayment];
90 89
91 for (size_t i = 0; i < _paymentMethods.size(); ++i) { 90 for (size_t i = 0; i < _paymentMethods.size(); ++i) {
92 autofill::CreditCard* paymentMethod = _paymentMethods[i]; 91 autofill::CreditCard* paymentMethod = _paymentMethods[i];
93 PaymentMethodItem* paymentMethodItem = [[[PaymentMethodItem alloc] 92 PaymentMethodItem* paymentMethodItem = [[[PaymentMethodItem alloc]
94 initWithType:ItemTypePaymentMethod] autorelease]; 93 initWithType:ItemTypePaymentMethod] autorelease];
95 paymentMethodItem.accessibilityTraits |= UIAccessibilityTraitButton;
96 paymentMethodItem.methodID = 94 paymentMethodItem.methodID =
97 base::SysUTF16ToNSString(paymentMethod->TypeAndLastFourDigits()); 95 base::SysUTF16ToNSString(paymentMethod->TypeAndLastFourDigits());
98 paymentMethodItem.methodDetail = base::SysUTF16ToNSString( 96 paymentMethodItem.methodDetail = base::SysUTF16ToNSString(
99 paymentMethod->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL)); 97 paymentMethod->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL));
100 98
101 int methodTypeIconID = 99 int methodTypeIconID =
102 autofill::data_util::GetPaymentRequestData(paymentMethod->type()) 100 autofill::data_util::GetPaymentRequestData(paymentMethod->type())
103 .icon_resource_id; 101 .icon_resource_id;
104 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 102 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
105 paymentMethodItem.methodTypeIcon = 103 paymentMethodItem.methodTypeIcon =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 - (CGFloat)collectionView:(UICollectionView*)collectionView 152 - (CGFloat)collectionView:(UICollectionView*)collectionView
155 cellHeightAtIndexPath:(NSIndexPath*)indexPath { 153 cellHeightAtIndexPath:(NSIndexPath*)indexPath {
156 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; 154 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
157 if (type == ItemTypeAddMethod) 155 if (type == ItemTypeAddMethod)
158 return MDCCellDefaultOneLineHeight; 156 return MDCCellDefaultOneLineHeight;
159 else 157 else
160 return MDCCellDefaultTwoLineHeight; 158 return MDCCellDefaultTwoLineHeight;
161 } 159 }
162 160
163 @end 161 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698