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

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

Issue 2710493006: [ObjC ARC] Converts ios/chrome/browser/payments:payments to ARC. (Closed)
Patch Set: rebase? Created 3 years, 10 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_request_view_controller.h" 5 #import "ios/chrome/browser/payments/payment_request_view_controller.h"
6 6
7 #import "base/ios/weak_nsobject.h"
8 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
9 #include "base/mac/objc_property_releaser.h" 8
10 #include "base/mac/scoped_nsobject.h"
11 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
13 #include "components/autofill/core/browser/autofill_data_util.h" 11 #include "components/autofill/core/browser/autofill_data_util.h"
14 #include "components/autofill/core/browser/autofill_profile.h" 12 #include "components/autofill/core/browser/autofill_profile.h"
15 #include "components/autofill/core/browser/credit_card.h" 13 #include "components/autofill/core/browser/credit_card.h"
16 #include "components/autofill/core/browser/field_types.h" 14 #include "components/autofill/core/browser/field_types.h"
17 #include "components/autofill/core/browser/personal_data_manager.h" 15 #include "components/autofill/core/browser/personal_data_manager.h"
18 #include "components/payments/currency_formatter.h" 16 #include "components/payments/currency_formatter.h"
19 #include "components/strings/grit/components_strings.h" 17 #include "components/strings/grit/components_strings.h"
20 #import "ios/chrome/browser/payments/cells/page_info_item.h" 18 #import "ios/chrome/browser/payments/cells/page_info_item.h"
(...skipping 10 matching lines...) Expand all
31 #include "ios/chrome/browser/ui/rtl_geometry.h" 29 #include "ios/chrome/browser/ui/rtl_geometry.h"
32 #include "ios/chrome/browser/ui/uikit_ui_util.h" 30 #include "ios/chrome/browser/ui/uikit_ui_util.h"
33 #include "ios/chrome/grit/ios_strings.h" 31 #include "ios/chrome/grit/ios_strings.h"
34 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" 32 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h"
35 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h" 33 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h"
36 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 34 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
37 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 35 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
38 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
39 #include "ui/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
40 38
39 #if !defined(__has_feature) || !__has_feature(objc_arc)
40 #error "This file requires ARC support."
41 #endif
42
41 using payment_request_util::NameLabelFromAutofillProfile; 43 using payment_request_util::NameLabelFromAutofillProfile;
42 using payment_request_util::AddressLabelFromAutofillProfile; 44 using payment_request_util::AddressLabelFromAutofillProfile;
43 using payment_request_util::PhoneNumberLabelFromAutofillProfile; 45 using payment_request_util::PhoneNumberLabelFromAutofillProfile;
44 46
45 NSString* const kPaymentRequestCollectionViewId = 47 NSString* const kPaymentRequestCollectionViewId =
46 @"kPaymentRequestCollectionViewId"; 48 @"kPaymentRequestCollectionViewId";
47 49
48 namespace { 50 namespace {
49 51
50 const CGFloat kButtonEdgeInset = 9; 52 const CGFloat kButtonEdgeInset = 9;
(...skipping 15 matching lines...) Expand all
66 ItemTypeShippingOption, 68 ItemTypeShippingOption,
67 ItemTypeSelectShippingOption, 69 ItemTypeSelectShippingOption,
68 ItemTypePaymentTitle, 70 ItemTypePaymentTitle,
69 ItemTypePaymentMethod, 71 ItemTypePaymentMethod,
70 ItemTypeAddPaymentMethod, 72 ItemTypeAddPaymentMethod,
71 }; 73 };
72 74
73 } // namespace 75 } // namespace
74 76
75 @interface PaymentRequestViewController () { 77 @interface PaymentRequestViewController () {
76 base::WeakNSProtocol<id<PaymentRequestViewControllerDelegate>> _delegate; 78 UIBarButtonItem* _cancelButton;
77 base::scoped_nsobject<UIBarButtonItem> _cancelButton; 79 MDCFlatButton* _payButton;
78 base::scoped_nsobject<MDCFlatButton> _payButton;
79 80
80 // The PaymentRequest object owning an instance of web::PaymentRequest as 81 // The PaymentRequest object owning an instance of web::PaymentRequest as
81 // provided by the page invoking the Payment Request API. This is a weak 82 // provided by the page invoking the Payment Request API. This is a weak
82 // pointer and should outlive this class. 83 // pointer and should outlive this class.
83 PaymentRequest* _paymentRequest; 84 PaymentRequest* _paymentRequest;
84 85
85 PriceItem* _paymentSummaryItem; 86 PriceItem* _paymentSummaryItem;
86 ShippingAddressItem* _selectedShippingAddressItem; 87 ShippingAddressItem* _selectedShippingAddressItem;
87 CollectionViewTextItem* _selectedShippingOptionItem; 88 CollectionViewTextItem* _selectedShippingOptionItem;
88 PaymentMethodItem* _selectedPaymentMethodItem; 89 PaymentMethodItem* _selectedPaymentMethodItem;
89
90 base::mac::ObjCPropertyReleaser
91 _propertyReleaser_PaymentRequestViewController;
92 } 90 }
93 91
94 // Called when the user presses the cancel button. 92 // Called when the user presses the cancel button.
95 - (void)onCancel; 93 - (void)onCancel;
96 94
97 // Called when the user presses the confirm button. 95 // Called when the user presses the confirm button.
98 - (void)onConfirm; 96 - (void)onConfirm;
99 97
100 @end 98 @end
101 99
102 @implementation PaymentRequestViewController 100 @implementation PaymentRequestViewController
103 101
104 @synthesize pageFavicon = _pageFavicon; 102 @synthesize pageFavicon = _pageFavicon;
105 @synthesize pageTitle = _pageTitle; 103 @synthesize pageTitle = _pageTitle;
106 @synthesize pageHost = _pageHost; 104 @synthesize pageHost = _pageHost;
105 @synthesize delegate = _delegate;
107 106
108 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { 107 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest {
109 DCHECK(paymentRequest); 108 DCHECK(paymentRequest);
110 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { 109 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) {
111 _propertyReleaser_PaymentRequestViewController.Init(
112 self, [PaymentRequestViewController class]);
113
114 [self setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_TITLE)]; 110 [self setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_TITLE)];
115 111
116 // Set up left (cancel) button. 112 // Set up left (cancel) button.
117 _cancelButton.reset([[UIBarButtonItem alloc] 113 _cancelButton = [[UIBarButtonItem alloc]
118 initWithTitle:l10n_util::GetNSString( 114 initWithTitle:l10n_util::GetNSString(
119 IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON) 115 IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON)
120 style:UIBarButtonItemStylePlain 116 style:UIBarButtonItemStylePlain
121 target:nil 117 target:nil
122 action:@selector(onCancel)]); 118 action:@selector(onCancel)];
123 [_cancelButton setTitleTextAttributes:@{ 119 [_cancelButton setTitleTextAttributes:@{
124 NSForegroundColorAttributeName : [UIColor lightGrayColor] 120 NSForegroundColorAttributeName : [UIColor lightGrayColor]
125 } 121 }
126 forState:UIControlStateDisabled]; 122 forState:UIControlStateDisabled];
127 [_cancelButton 123 [_cancelButton
128 setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_CANCEL)]; 124 setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_CANCEL)];
129 [self navigationItem].leftBarButtonItem = _cancelButton; 125 [self navigationItem].leftBarButtonItem = _cancelButton;
130 126
131 // Set up right (pay) button. 127 // Set up right (pay) button.
132 _payButton.reset([[MDCFlatButton alloc] init]); 128 _payButton = [[MDCFlatButton alloc] init];
133 [_payButton 129 [_payButton
134 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON) 130 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON)
135 forState:UIControlStateNormal]; 131 forState:UIControlStateNormal];
136 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] 132 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500]
137 forState:UIControlStateNormal]; 133 forState:UIControlStateNormal];
138 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]]; 134 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]];
139 [_payButton setBackgroundColor:[UIColor grayColor] 135 [_payButton setBackgroundColor:[UIColor grayColor]
140 forState:UIControlStateDisabled]; 136 forState:UIControlStateDisabled];
141 [_payButton addTarget:nil 137 [_payButton addTarget:nil
142 action:@selector(onConfirm) 138 action:@selector(onConfirm)
143 forControlEvents:UIControlEventTouchUpInside]; 139 forControlEvents:UIControlEventTouchUpInside];
144 [_payButton sizeToFit]; 140 [_payButton sizeToFit];
145 [_payButton setEnabled:(paymentRequest->selected_credit_card() != nil)]; 141 [_payButton setEnabled:(paymentRequest->selected_credit_card() != nil)];
146 [_payButton setAutoresizingMask:UIViewAutoresizingFlexibleTrailingMargin() | 142 [_payButton setAutoresizingMask:UIViewAutoresizingFlexibleTrailingMargin() |
147 UIViewAutoresizingFlexibleTopMargin | 143 UIViewAutoresizingFlexibleTopMargin |
148 UIViewAutoresizingFlexibleBottomMargin]; 144 UIViewAutoresizingFlexibleBottomMargin];
149 145
150 // The navigation bar will set the rightBarButtonItem's height to the full 146 // The navigation bar will set the rightBarButtonItem's height to the full
151 // height of the bar. We don't want that for the button so we use a UIView 147 // height of the bar. We don't want that for the button so we use a UIView
152 // here to contain the button instead and the button is vertically centered 148 // here to contain the button instead and the button is vertically centered
153 // inside the full bar height. 149 // inside the full bar height.
154 UIView* buttonView = 150 UIView* buttonView = [[UIView alloc] initWithFrame:CGRectZero];
155 [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
156 [buttonView addSubview:_payButton]; 151 [buttonView addSubview:_payButton];
157 // Navigation bar button items are aligned with the trailing edge of the 152 // Navigation bar button items are aligned with the trailing edge of the
158 // screen. Make the enclosing view larger here. The pay button will be 153 // screen. Make the enclosing view larger here. The pay button will be
159 // aligned with the leading edge of the enclosing view leaving an inset on 154 // aligned with the leading edge of the enclosing view leaving an inset on
160 // the trailing edge. 155 // the trailing edge.
161 CGRect buttonViewBounds = buttonView.bounds; 156 CGRect buttonViewBounds = buttonView.bounds;
162 buttonViewBounds.size.width = 157 buttonViewBounds.size.width =
163 [_payButton frame].size.width + kButtonEdgeInset; 158 [_payButton frame].size.width + kButtonEdgeInset;
164 buttonView.bounds = buttonViewBounds; 159 buttonView.bounds = buttonViewBounds;
165 160
166 UIBarButtonItem* payButtonItem = 161 UIBarButtonItem* payButtonItem =
167 [[[UIBarButtonItem alloc] initWithCustomView:buttonView] autorelease]; 162 [[UIBarButtonItem alloc] initWithCustomView:buttonView];
168 [self navigationItem].rightBarButtonItem = payButtonItem; 163 [self navigationItem].rightBarButtonItem = payButtonItem;
169 164
170 _paymentRequest = paymentRequest; 165 _paymentRequest = paymentRequest;
171 } 166 }
172 return self; 167 return self;
173 } 168 }
174 169
175 - (id<PaymentRequestViewControllerDelegate>)delegate {
176 return _delegate.get();
177 }
178
179 - (void)setDelegate:(id<PaymentRequestViewControllerDelegate>)delegate {
180 _delegate.reset(delegate);
181 }
182
183 - (void)onCancel { 170 - (void)onCancel {
184 [_delegate paymentRequestViewControllerDidCancel:self]; 171 [_delegate paymentRequestViewControllerDidCancel:self];
185 } 172 }
186 173
187 - (void)onConfirm { 174 - (void)onConfirm {
188 [_delegate paymentRequestViewControllerDidConfirm:self]; 175 [_delegate paymentRequestViewControllerDidConfirm:self];
189 } 176 }
190 177
191 #pragma mark - CollectionViewController methods 178 #pragma mark - CollectionViewController methods
192 179
193 - (void)loadModel { 180 - (void)loadModel {
194 [super loadModel]; 181 [super loadModel];
195 CollectionViewModel* model = self.collectionViewModel; 182 CollectionViewModel* model = self.collectionViewModel;
196 183
197 // Summary section. 184 // Summary section.
198 [model addSectionWithIdentifier:SectionIdentifierSummary]; 185 [model addSectionWithIdentifier:SectionIdentifierSummary];
199 186
200 PageInfoItem* pageInfo = 187 PageInfoItem* pageInfo =
201 [[[PageInfoItem alloc] initWithType:ItemTypeSummaryPageInfo] autorelease]; 188 [[PageInfoItem alloc] initWithType:ItemTypeSummaryPageInfo];
202 pageInfo.pageFavicon = _pageFavicon; 189 pageInfo.pageFavicon = _pageFavicon;
203 pageInfo.pageTitle = _pageTitle; 190 pageInfo.pageTitle = _pageTitle;
204 pageInfo.pageHost = _pageHost; 191 pageInfo.pageHost = _pageHost;
205 [model setHeader:pageInfo forSectionWithIdentifier:SectionIdentifierSummary]; 192 [model setHeader:pageInfo forSectionWithIdentifier:SectionIdentifierSummary];
206 193
207 _paymentSummaryItem = 194 _paymentSummaryItem = [[PriceItem alloc] initWithType:ItemTypeSummaryTotal];
208 [[[PriceItem alloc] initWithType:ItemTypeSummaryTotal] autorelease];
209 [self fillPaymentSummaryItem:_paymentSummaryItem 195 [self fillPaymentSummaryItem:_paymentSummaryItem
210 withPaymentItem:_paymentRequest->payment_details().total 196 withPaymentItem:_paymentRequest->payment_details().total
211 withTotalValueChanged:NO]; 197 withTotalValueChanged:NO];
212 if (!_paymentRequest->payment_details().display_items.empty()) { 198 if (!_paymentRequest->payment_details().display_items.empty()) {
213 _paymentSummaryItem.accessoryType = 199 _paymentSummaryItem.accessoryType =
214 MDCCollectionViewCellAccessoryDisclosureIndicator; 200 MDCCollectionViewCellAccessoryDisclosureIndicator;
215 _paymentSummaryItem.accessibilityTraits |= UIAccessibilityTraitButton; 201 _paymentSummaryItem.accessibilityTraits |= UIAccessibilityTraitButton;
216 } 202 }
217 [model addItem:_paymentSummaryItem 203 [model addItem:_paymentSummaryItem
218 toSectionWithIdentifier:SectionIdentifierSummary]; 204 toSectionWithIdentifier:SectionIdentifierSummary];
219 205
220 // Shipping section. 206 // Shipping section.
221 [model addSectionWithIdentifier:SectionIdentifierShipping]; 207 [model addSectionWithIdentifier:SectionIdentifierShipping];
222 208
223 CollectionViewTextItem* shippingTitle = [[[CollectionViewTextItem alloc] 209 CollectionViewTextItem* shippingTitle =
224 initWithType:ItemTypeShippingTitle] autorelease]; 210 [[CollectionViewTextItem alloc] initWithType:ItemTypeShippingTitle];
225 shippingTitle.text = 211 shippingTitle.text =
226 payment_request_util::GetShippingSectionTitle(_paymentRequest); 212 payment_request_util::GetShippingSectionTitle(_paymentRequest);
227 [model setHeader:shippingTitle 213 [model setHeader:shippingTitle
228 forSectionWithIdentifier:SectionIdentifierShipping]; 214 forSectionWithIdentifier:SectionIdentifierShipping];
229 215
230 CollectionViewItem* shippingAddressItem = nil; 216 CollectionViewItem* shippingAddressItem = nil;
231 if (_paymentRequest->selected_shipping_profile()) { 217 if (_paymentRequest->selected_shipping_profile()) {
232 _selectedShippingAddressItem = [[[ShippingAddressItem alloc] 218 _selectedShippingAddressItem =
233 initWithType:ItemTypeShippingAddress] autorelease]; 219 [[ShippingAddressItem alloc] initWithType:ItemTypeShippingAddress];
234 shippingAddressItem = _selectedShippingAddressItem; 220 shippingAddressItem = _selectedShippingAddressItem;
235 [self fillShippingAddressItem:_selectedShippingAddressItem 221 [self fillShippingAddressItem:_selectedShippingAddressItem
236 withAddress:_paymentRequest->selected_shipping_profile()]; 222 withAddress:_paymentRequest->selected_shipping_profile()];
237 _selectedShippingAddressItem.accessoryType = 223 _selectedShippingAddressItem.accessoryType =
238 MDCCollectionViewCellAccessoryDisclosureIndicator; 224 MDCCollectionViewCellAccessoryDisclosureIndicator;
239 225
240 } else { 226 } else {
241 CollectionViewDetailItem* addAddressItem = 227 CollectionViewDetailItem* addAddressItem = [[CollectionViewDetailItem alloc]
242 [[[CollectionViewDetailItem alloc] 228 initWithType:ItemTypeAddShippingAddress];
243 initWithType:ItemTypeAddShippingAddress] autorelease];
244 shippingAddressItem = addAddressItem; 229 shippingAddressItem = addAddressItem;
245 addAddressItem.text = 230 addAddressItem.text =
246 payment_request_util::GetShippingAddressSelectorTitle(_paymentRequest); 231 payment_request_util::GetShippingAddressSelectorTitle(_paymentRequest);
247 addAddressItem.detailText = [l10n_util::GetNSString( 232 addAddressItem.detailText = [l10n_util::GetNSString(
248 IDS_IOS_PAYMENT_REQUEST_ADD_SHIPPING_ADDRESS_BUTTON) 233 IDS_IOS_PAYMENT_REQUEST_ADD_SHIPPING_ADDRESS_BUTTON)
249 uppercaseStringWithLocale:[NSLocale currentLocale]]; 234 uppercaseStringWithLocale:[NSLocale currentLocale]];
250 } 235 }
251 shippingAddressItem.accessibilityTraits |= UIAccessibilityTraitButton; 236 shippingAddressItem.accessibilityTraits |= UIAccessibilityTraitButton;
252 [model addItem:shippingAddressItem 237 [model addItem:shippingAddressItem
253 toSectionWithIdentifier:SectionIdentifierShipping]; 238 toSectionWithIdentifier:SectionIdentifierShipping];
254 239
255 CollectionViewItem* shippingOptionItem = nil; 240 CollectionViewItem* shippingOptionItem = nil;
256 if (_paymentRequest->selected_shipping_option()) { 241 if (_paymentRequest->selected_shipping_option()) {
257 _selectedShippingOptionItem = [[[CollectionViewTextItem alloc] 242 _selectedShippingOptionItem =
258 initWithType:ItemTypeShippingOption] autorelease]; 243 [[CollectionViewTextItem alloc] initWithType:ItemTypeShippingOption];
259 shippingOptionItem = _selectedShippingOptionItem; 244 shippingOptionItem = _selectedShippingOptionItem;
260 [self fillShippingOptionItem:_selectedShippingOptionItem 245 [self fillShippingOptionItem:_selectedShippingOptionItem
261 withOption:_paymentRequest->selected_shipping_option()]; 246 withOption:_paymentRequest->selected_shipping_option()];
262 _selectedShippingOptionItem.accessoryType = 247 _selectedShippingOptionItem.accessoryType =
263 MDCCollectionViewCellAccessoryDisclosureIndicator; 248 MDCCollectionViewCellAccessoryDisclosureIndicator;
264 } else { 249 } else {
265 CollectionViewDetailItem* selectShippingOptionItem = 250 CollectionViewDetailItem* selectShippingOptionItem =
266 [[[CollectionViewDetailItem alloc] 251 [[CollectionViewDetailItem alloc]
267 initWithType:ItemTypeSelectShippingOption] autorelease]; 252 initWithType:ItemTypeSelectShippingOption];
268 shippingOptionItem = selectShippingOptionItem; 253 shippingOptionItem = selectShippingOptionItem;
269 selectShippingOptionItem.text = 254 selectShippingOptionItem.text =
270 payment_request_util::GetShippingOptionSelectorTitle(_paymentRequest); 255 payment_request_util::GetShippingOptionSelectorTitle(_paymentRequest);
271 selectShippingOptionItem.accessoryType = 256 selectShippingOptionItem.accessoryType =
272 MDCCollectionViewCellAccessoryDisclosureIndicator; 257 MDCCollectionViewCellAccessoryDisclosureIndicator;
273 } 258 }
274 shippingOptionItem.accessibilityTraits |= UIAccessibilityTraitButton; 259 shippingOptionItem.accessibilityTraits |= UIAccessibilityTraitButton;
275 [model addItem:shippingOptionItem 260 [model addItem:shippingOptionItem
276 toSectionWithIdentifier:SectionIdentifierShipping]; 261 toSectionWithIdentifier:SectionIdentifierShipping];
277 262
278 // Payment method section. 263 // Payment method section.
279 [model addSectionWithIdentifier:SectionIdentifierPayment]; 264 [model addSectionWithIdentifier:SectionIdentifierPayment];
280 265
281 CollectionViewItem* paymentMethodItem = nil; 266 CollectionViewItem* paymentMethodItem = nil;
282 if (_paymentRequest->selected_credit_card()) { 267 if (_paymentRequest->selected_credit_card()) {
283 CollectionViewTextItem* paymentTitle = [[[CollectionViewTextItem alloc] 268 CollectionViewTextItem* paymentTitle =
284 initWithType:ItemTypePaymentTitle] autorelease]; 269 [[CollectionViewTextItem alloc] initWithType:ItemTypePaymentTitle];
285 paymentTitle.text = 270 paymentTitle.text =
286 l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAYMENT_METHOD_HEADER); 271 l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAYMENT_METHOD_HEADER);
287 [model setHeader:paymentTitle 272 [model setHeader:paymentTitle
288 forSectionWithIdentifier:SectionIdentifierPayment]; 273 forSectionWithIdentifier:SectionIdentifierPayment];
289 274
290 _selectedPaymentMethodItem = [[[PaymentMethodItem alloc] 275 _selectedPaymentMethodItem =
291 initWithType:ItemTypePaymentMethod] autorelease]; 276 [[PaymentMethodItem alloc] initWithType:ItemTypePaymentMethod];
292 paymentMethodItem = _selectedPaymentMethodItem; 277 paymentMethodItem = _selectedPaymentMethodItem;
293 [self fillPaymentMethodItem:_selectedPaymentMethodItem 278 [self fillPaymentMethodItem:_selectedPaymentMethodItem
294 withPaymentMethod:_paymentRequest->selected_credit_card()]; 279 withPaymentMethod:_paymentRequest->selected_credit_card()];
295 _selectedPaymentMethodItem.accessoryType = 280 _selectedPaymentMethodItem.accessoryType =
296 MDCCollectionViewCellAccessoryDisclosureIndicator; 281 MDCCollectionViewCellAccessoryDisclosureIndicator;
297 } else { 282 } else {
298 CollectionViewDetailItem* addPaymentMethodItem = 283 CollectionViewDetailItem* addPaymentMethodItem = [
299 [[[CollectionViewDetailItem alloc] 284 [CollectionViewDetailItem alloc] initWithType:ItemTypeAddPaymentMethod];
300 initWithType:ItemTypeAddPaymentMethod] autorelease];
301 paymentMethodItem = addPaymentMethodItem; 285 paymentMethodItem = addPaymentMethodItem;
302 addPaymentMethodItem.text = 286 addPaymentMethodItem.text =
303 l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAYMENT_METHOD_HEADER); 287 l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAYMENT_METHOD_HEADER);
304 addPaymentMethodItem.detailText = [l10n_util::GetNSString( 288 addPaymentMethodItem.detailText = [l10n_util::GetNSString(
305 IDS_IOS_PAYMENT_REQUEST_ADD_SHIPPING_ADDRESS_BUTTON) 289 IDS_IOS_PAYMENT_REQUEST_ADD_SHIPPING_ADDRESS_BUTTON)
306 uppercaseStringWithLocale:[NSLocale currentLocale]]; 290 uppercaseStringWithLocale:[NSLocale currentLocale]];
307 } 291 }
308 paymentMethodItem.accessibilityTraits |= UIAccessibilityTraitButton; 292 paymentMethodItem.accessibilityTraits |= UIAccessibilityTraitButton;
309 [model addItem:paymentMethodItem 293 [model addItem:paymentMethodItem
310 toSectionWithIdentifier:SectionIdentifierPayment]; 294 toSectionWithIdentifier:SectionIdentifierPayment];
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; 486 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
503 if (type == ItemTypeSummaryTotal && 487 if (type == ItemTypeSummaryTotal &&
504 _paymentRequest->payment_details().display_items.empty()) { 488 _paymentRequest->payment_details().display_items.empty()) {
505 return YES; 489 return YES;
506 } else { 490 } else {
507 return NO; 491 return NO;
508 } 492 }
509 } 493 }
510 494
511 @end 495 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698