OLD | NEW |
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/ui/payments/payment_request_view_controller.h" | 5 #import "ios/chrome/browser/ui/payments/payment_request_view_controller.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 @end | 121 @end |
122 | 122 |
123 @implementation PaymentRequestViewController | 123 @implementation PaymentRequestViewController |
124 | 124 |
125 @synthesize pageFavicon = _pageFavicon; | 125 @synthesize pageFavicon = _pageFavicon; |
126 @synthesize pageTitle = _pageTitle; | 126 @synthesize pageTitle = _pageTitle; |
127 @synthesize pageHost = _pageHost; | 127 @synthesize pageHost = _pageHost; |
128 @synthesize pending = _pending; | 128 @synthesize pending = _pending; |
129 @synthesize delegate = _delegate; | 129 @synthesize delegate = _delegate; |
130 @synthesize showDataSource = _showDataSource; | 130 @synthesize showPaymentDataSource = _showPaymentDataSource; |
131 @synthesize authenticatedAccountName = _authenticatedAccountName; | 131 @synthesize dataSource = _dataSource; |
132 | 132 |
133 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { | 133 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { |
134 DCHECK(paymentRequest); | 134 DCHECK(paymentRequest); |
135 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { | 135 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { |
136 [self setTitle:l10n_util::GetNSString(IDS_PAYMENTS_TITLE)]; | 136 [self setTitle:l10n_util::GetNSString(IDS_PAYMENTS_TITLE)]; |
137 | 137 |
138 // Set up leading (cancel) button. | 138 // Set up leading (cancel) button. |
139 _cancelButton = [[UIBarButtonItem alloc] | 139 _cancelButton = [[UIBarButtonItem alloc] |
140 initWithTitle:l10n_util::GetNSString(IDS_CANCEL) | 140 initWithTitle:l10n_util::GetNSString(IDS_CANCEL) |
141 style:UIBarButtonItemStylePlain | 141 style:UIBarButtonItemStylePlain |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 [_payButton frame].size.width + kButtonEdgeInset; | 179 [_payButton frame].size.width + kButtonEdgeInset; |
180 buttonView.bounds = buttonViewBounds; | 180 buttonView.bounds = buttonViewBounds; |
181 | 181 |
182 UIBarButtonItem* payButtonItem = | 182 UIBarButtonItem* payButtonItem = |
183 [[UIBarButtonItem alloc] initWithCustomView:buttonView]; | 183 [[UIBarButtonItem alloc] initWithCustomView:buttonView]; |
184 [self navigationItem].rightBarButtonItem = payButtonItem; | 184 [self navigationItem].rightBarButtonItem = payButtonItem; |
185 | 185 |
186 _paymentRequest = paymentRequest; | 186 _paymentRequest = paymentRequest; |
187 | 187 |
188 // By default, data source is shown. | 188 // By default, data source is shown. |
189 _showDataSource = TRUE; | 189 _showPaymentDataSource = TRUE; |
190 } | 190 } |
191 return self; | 191 return self; |
192 } | 192 } |
193 | 193 |
194 - (void)onCancel { | 194 - (void)onCancel { |
195 [_delegate paymentRequestViewControllerDidCancel:self]; | 195 [_delegate paymentRequestViewControllerDidCancel:self]; |
196 } | 196 } |
197 | 197 |
198 - (void)onConfirm { | 198 - (void)onConfirm { |
199 [_delegate paymentRequestViewControllerDidConfirm:self]; | 199 [_delegate paymentRequestViewControllerDidConfirm:self]; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 uppercaseStringWithLocale:[NSLocale currentLocale]]; | 366 uppercaseStringWithLocale:[NSLocale currentLocale]]; |
367 addContactInfoItem.accessibilityTraits |= UIAccessibilityTraitButton; | 367 addContactInfoItem.accessibilityTraits |= UIAccessibilityTraitButton; |
368 } | 368 } |
369 [model addItem:contactInfoItem | 369 [model addItem:contactInfoItem |
370 toSectionWithIdentifier:SectionIdentifierContactInfo]; | 370 toSectionWithIdentifier:SectionIdentifierContactInfo]; |
371 | 371 |
372 // Footer Text section. | 372 // Footer Text section. |
373 [model addSectionWithIdentifier:SectionIdentifierFooter]; | 373 [model addSectionWithIdentifier:SectionIdentifierFooter]; |
374 CollectionViewFooterItem* footer = | 374 CollectionViewFooterItem* footer = |
375 [[CollectionViewFooterItem alloc] initWithType:ItemTypeFooterText]; | 375 [[CollectionViewFooterItem alloc] initWithType:ItemTypeFooterText]; |
376 if (!_showDataSource) { | 376 if (!_showPaymentDataSource) { |
377 footer.text = | 377 footer.text = |
378 l10n_util::GetNSString(IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS); | 378 l10n_util::GetNSString(IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS); |
379 } else if ([_authenticatedAccountName length]) { | 379 } else if ([[_dataSource authenticatedAccountName] length]) { |
380 const std::string unformattedString = l10n_util::GetStringUTF8( | 380 const std::string unformattedString = l10n_util::GetStringUTF8( |
381 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_IN); | 381 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_IN); |
382 const std::string accountName = | 382 const std::string accountName = |
383 base::SysNSStringToUTF8(_authenticatedAccountName); | 383 base::SysNSStringToUTF8([_dataSource authenticatedAccountName]); |
384 const std::string formattedString = | 384 const std::string formattedString = |
385 base::StringPrintf(unformattedString.c_str(), accountName.c_str()); | 385 base::StringPrintf(unformattedString.c_str(), accountName.c_str()); |
386 footer.text = base::SysUTF8ToNSString(formattedString); | 386 footer.text = base::SysUTF8ToNSString(formattedString); |
387 } else { | 387 } else { |
388 footer.text = l10n_util::GetNSString( | 388 footer.text = l10n_util::GetNSString( |
389 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_OUT); | 389 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_OUT); |
390 } | 390 } |
391 footer.linkURL = GURL(kSettingsURL); | 391 footer.linkURL = GURL(kSettingsURL); |
392 footer.linkDelegate = self; | 392 footer.linkDelegate = self; |
393 [model addItem:footer toSectionWithIdentifier:SectionIdentifierFooter]; | 393 [model addItem:footer toSectionWithIdentifier:SectionIdentifierFooter]; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 | 621 |
622 - (BOOL)collectionView:(UICollectionView*)collectionView | 622 - (BOOL)collectionView:(UICollectionView*)collectionView |
623 shouldHideItemBackgroundAtIndexPath:(NSIndexPath*)indexPath { | 623 shouldHideItemBackgroundAtIndexPath:(NSIndexPath*)indexPath { |
624 // No background on the footer text item. | 624 // No background on the footer text item. |
625 NSInteger sectionIdentifier = | 625 NSInteger sectionIdentifier = |
626 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; | 626 [self.collectionViewModel sectionIdentifierForSection:indexPath.section]; |
627 return sectionIdentifier == SectionIdentifierFooter ? YES : NO; | 627 return sectionIdentifier == SectionIdentifierFooter ? YES : NO; |
628 } | 628 } |
629 | 629 |
630 @end | 630 @end |
OLD | NEW |