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

Side by Side Diff: ios/chrome/browser/payments/payment_request_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_request_view_controller.h" 5 #import "ios/chrome/browser/payments/payment_request_view_controller.h"
6 6
7 #import "base/ios/weak_nsobject.h" 7 #import "base/ios/weak_nsobject.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/mac/objc_property_releaser.h" 9 #include "base/mac/objc_property_releaser.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "components/autofill/core/browser/autofill_data_util.h" 12 #include "components/autofill/core/browser/autofill_data_util.h"
13 #include "components/autofill/core/browser/autofill_profile.h" 13 #include "components/autofill/core/browser/autofill_profile.h"
14 #include "components/autofill/core/browser/credit_card.h" 14 #include "components/autofill/core/browser/credit_card.h"
15 #include "components/autofill/core/browser/field_types.h" 15 #include "components/autofill/core/browser/field_types.h"
16 #include "components/autofill/core/browser/personal_data_manager.h" 16 #include "components/autofill/core/browser/personal_data_manager.h"
17 #include "components/strings/grit/components_strings.h"
18 #include "ios/chrome/browser/application_context.h" 17 #include "ios/chrome/browser/application_context.h"
19 #import "ios/chrome/browser/payments/cells/page_info_item.h" 18 #import "ios/chrome/browser/payments/cells/page_info_item.h"
20 #import "ios/chrome/browser/payments/cells/payment_method_item.h" 19 #import "ios/chrome/browser/payments/cells/payment_method_item.h"
21 #import "ios/chrome/browser/payments/cells/shipping_address_item.h" 20 #import "ios/chrome/browser/payments/cells/shipping_address_item.h"
22 #import "ios/chrome/browser/payments/payment_request_utils.h" 21 #import "ios/chrome/browser/payments/payment_request_utils.h"
23 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h" 22 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h"
24 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" 23 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
25 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h " 24 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
26 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" 25 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h"
27 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 26 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
28 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 27 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
29 #include "ios/chrome/browser/ui/rtl_geometry.h" 28 #include "ios/chrome/browser/ui/rtl_geometry.h"
30 #include "ios/chrome/grit/ios_strings.h" 29 #include "ios/chrome/grit/ios_strings.h"
31 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" 30 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h"
32 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h" 31 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h"
33 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 32 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
34 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 33 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
35 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
36 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
37 36
38 using payment_request_utils::NameLabelFromAutofillProfile;
39 using payment_request_utils::AddressLabelFromAutofillProfile;
40 using payment_request_utils::PhoneNumberLabelFromAutofillProfile;
41
42 NSString* const kPaymentRequestCollectionViewId = 37 NSString* const kPaymentRequestCollectionViewId =
43 @"kPaymentRequestCollectionViewId"; 38 @"kPaymentRequestCollectionViewId";
44 39
45 namespace { 40 namespace {
46 41
47 const CGFloat kButtonEdgeInset = 9; 42 const CGFloat kButtonEdgeInset = 9;
48 const CGFloat kSeparatorEdgeInset = 14; 43 const CGFloat kSeparatorEdgeInset = 14;
49 44
50 typedef NS_ENUM(NSInteger, SectionIdentifier) { 45 typedef NS_ENUM(NSInteger, SectionIdentifier) {
51 SectionIdentifierSummary = kSectionIdentifierEnumZero, 46 SectionIdentifierSummary = kSectionIdentifierEnumZero,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 _cancelButton.reset([[UIBarButtonItem alloc] 104 _cancelButton.reset([[UIBarButtonItem alloc]
110 initWithTitle:l10n_util::GetNSString( 105 initWithTitle:l10n_util::GetNSString(
111 IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON) 106 IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON)
112 style:UIBarButtonItemStylePlain 107 style:UIBarButtonItemStylePlain
113 target:nil 108 target:nil
114 action:@selector(onCancel)]); 109 action:@selector(onCancel)]);
115 [_cancelButton setTitleTextAttributes:@{ 110 [_cancelButton setTitleTextAttributes:@{
116 NSForegroundColorAttributeName : [UIColor lightGrayColor] 111 NSForegroundColorAttributeName : [UIColor lightGrayColor]
117 } 112 }
118 forState:UIControlStateDisabled]; 113 forState:UIControlStateDisabled];
119 [_cancelButton
120 setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_CANCEL)];
121 [self navigationItem].leftBarButtonItem = _cancelButton; 114 [self navigationItem].leftBarButtonItem = _cancelButton;
122 115
123 // Set up right (pay) button. 116 // Set up right (pay) button.
124 _payButton.reset([[MDCFlatButton alloc] init]); 117 _payButton.reset([[MDCFlatButton alloc] init]);
125 [_payButton 118 [_payButton
126 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON) 119 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON)
127 forState:UIControlStateNormal]; 120 forState:UIControlStateNormal];
128 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] 121 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500]
129 forState:UIControlStateNormal]; 122 forState:UIControlStateNormal];
130 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]]; 123 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]];
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 NSIndexPath* indexPath = 341 NSIndexPath* indexPath =
349 [self.collectionViewModel indexPathForItem:_selectedShippingOptionItem 342 [self.collectionViewModel indexPathForItem:_selectedShippingOptionItem
350 inSectionWithIdentifier:SectionIdentifierShipping]; 343 inSectionWithIdentifier:SectionIdentifierShipping];
351 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; 344 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]];
352 } 345 }
353 346
354 #pragma mark - Helper methods 347 #pragma mark - Helper methods
355 348
356 - (void)fillShippingAddressItem:(ShippingAddressItem*)item 349 - (void)fillShippingAddressItem:(ShippingAddressItem*)item
357 withAddress:(autofill::AutofillProfile*)address { 350 withAddress:(autofill::AutofillProfile*)address {
358 item.name = NameLabelFromAutofillProfile(address); 351 item.name =
359 item.address = AddressLabelFromAutofillProfile(address); 352 base::SysUTF16ToNSString(address->GetRawInfo(autofill::NAME_FULL));
360 item.phoneNumber = PhoneNumberLabelFromAutofillProfile(address); 353 item.address =
354 payment_request_utils::AddressLabelFromAutofillProfile(address);
355 item.phoneNumber = base::SysUTF16ToNSString(
356 address->GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER));
361 } 357 }
362 358
363 - (void)fillShippingOptionItem:(CollectionViewTextItem*)item 359 - (void)fillShippingOptionItem:(CollectionViewTextItem*)item
364 withOption:(web::PaymentShippingOption*)option { 360 withOption:(web::PaymentShippingOption*)option {
365 item.text = base::SysUTF16ToNSString(option->label); 361 item.text = base::SysUTF16ToNSString(option->label);
366 NSString* currencyCode = base::SysUTF16ToNSString(option->amount.currency); 362 NSString* currencyCode = base::SysUTF16ToNSString(option->amount.currency);
367 NSDecimalNumber* value = [NSDecimalNumber 363 NSDecimalNumber* value = [NSDecimalNumber
368 decimalNumberWithString:SysUTF16ToNSString(option->amount.value)]; 364 decimalNumberWithString:SysUTF16ToNSString(option->amount.value)];
369 item.detailText = 365 item.detailText =
370 payment_request_utils::FormattedCurrencyString(value, currencyCode); 366 payment_request_utils::FormattedCurrencyString(value, currencyCode);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; 455 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
460 if (type == ItemTypeSummaryTotal && 456 if (type == ItemTypeSummaryTotal &&
461 _paymentRequest.details.display_items.empty()) { 457 _paymentRequest.details.display_items.empty()) {
462 return YES; 458 return YES;
463 } else { 459 } else {
464 return NO; 460 return NO;
465 } 461 }
466 } 462 }
467 463
468 @end 464 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698