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

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

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: Yank unrelated changes. 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" 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_release_properties.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 "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "components/autofill/core/browser/autofill_data_util.h" 13 #include "components/autofill/core/browser/autofill_data_util.h"
14 #include "components/autofill/core/browser/autofill_profile.h" 14 #include "components/autofill/core/browser/autofill_profile.h"
15 #include "components/autofill/core/browser/credit_card.h" 15 #include "components/autofill/core/browser/credit_card.h"
16 #include "components/autofill/core/browser/field_types.h" 16 #include "components/autofill/core/browser/field_types.h"
17 #include "components/autofill/core/browser/personal_data_manager.h" 17 #include "components/autofill/core/browser/personal_data_manager.h"
18 #include "components/payments/currency_formatter.h" 18 #include "components/payments/currency_formatter.h"
19 #include "components/strings/grit/components_strings.h" 19 #include "components/strings/grit/components_strings.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 base::scoped_nsobject<MDCFlatButton> _payButton; 77 base::scoped_nsobject<MDCFlatButton> _payButton;
78 78
79 // The PaymentRequest object owning an instance of web::PaymentRequest as 79 // The PaymentRequest object owning an instance of web::PaymentRequest as
80 // provided by the page invoking the Payment Request API. This is a weak 80 // provided by the page invoking the Payment Request API. This is a weak
81 // pointer and should outlive this class. 81 // pointer and should outlive this class.
82 PaymentRequest* _paymentRequest; 82 PaymentRequest* _paymentRequest;
83 83
84 PriceItem* _paymentSummaryItem; 84 PriceItem* _paymentSummaryItem;
85 ShippingAddressItem* _selectedShippingAddressItem; 85 ShippingAddressItem* _selectedShippingAddressItem;
86 CollectionViewTextItem* _selectedShippingOptionItem; 86 CollectionViewTextItem* _selectedShippingOptionItem;
87
88 base::mac::ObjCPropertyReleaser
89 _propertyReleaser_PaymentRequestViewController;
90 } 87 }
91 88
92 // Called when the user presses the cancel button. 89 // Called when the user presses the cancel button.
93 - (void)onCancel; 90 - (void)onCancel;
94 91
95 // Called when the user presses the confirm button. 92 // Called when the user presses the confirm button.
96 - (void)onConfirm; 93 - (void)onConfirm;
97 94
98 @end 95 @end
99 96
100 @implementation PaymentRequestViewController 97 @implementation PaymentRequestViewController
101 98
102 @synthesize pageFavicon = _pageFavicon; 99 @synthesize pageFavicon = _pageFavicon;
103 @synthesize pageTitle = _pageTitle; 100 @synthesize pageTitle = _pageTitle;
104 @synthesize pageHost = _pageHost; 101 @synthesize pageHost = _pageHost;
105 102
106 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { 103 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest {
107 DCHECK(paymentRequest); 104 DCHECK(paymentRequest);
108 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { 105 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) {
109 _propertyReleaser_PaymentRequestViewController.Init(
110 self, [PaymentRequestViewController class]);
111
112 [self setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_TITLE)]; 106 [self setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_TITLE)];
113 107
114 // Set up left (cancel) button. 108 // Set up left (cancel) button.
115 _cancelButton.reset([[UIBarButtonItem alloc] 109 _cancelButton.reset([[UIBarButtonItem alloc]
116 initWithTitle:l10n_util::GetNSString( 110 initWithTitle:l10n_util::GetNSString(
117 IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON) 111 IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON)
118 style:UIBarButtonItemStylePlain 112 style:UIBarButtonItemStylePlain
119 target:nil 113 target:nil
120 action:@selector(onCancel)]); 114 action:@selector(onCancel)]);
121 [_cancelButton setTitleTextAttributes:@{ 115 [_cancelButton setTitleTextAttributes:@{
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 157
164 UIBarButtonItem* payButtonItem = 158 UIBarButtonItem* payButtonItem =
165 [[[UIBarButtonItem alloc] initWithCustomView:buttonView] autorelease]; 159 [[[UIBarButtonItem alloc] initWithCustomView:buttonView] autorelease];
166 [self navigationItem].rightBarButtonItem = payButtonItem; 160 [self navigationItem].rightBarButtonItem = payButtonItem;
167 161
168 _paymentRequest = paymentRequest; 162 _paymentRequest = paymentRequest;
169 } 163 }
170 return self; 164 return self;
171 } 165 }
172 166
167 - (void)dealloc {
168 base::mac::ReleaseProperties(self);
169 [super dealloc];
170 }
171
173 - (id<PaymentRequestViewControllerDelegate>)delegate { 172 - (id<PaymentRequestViewControllerDelegate>)delegate {
174 return _delegate.get(); 173 return _delegate.get();
175 } 174 }
176 175
177 - (void)setDelegate:(id<PaymentRequestViewControllerDelegate>)delegate { 176 - (void)setDelegate:(id<PaymentRequestViewControllerDelegate>)delegate {
178 _delegate.reset(delegate); 177 _delegate.reset(delegate);
179 } 178 }
180 179
181 - (void)onCancel { 180 - (void)onCancel {
182 [_cancelButton setEnabled:NO]; 181 [_cancelButton setEnabled:NO];
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; 476 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
478 if (type == ItemTypeSummaryTotal && 477 if (type == ItemTypeSummaryTotal &&
479 _paymentRequest->payment_details().display_items.empty()) { 478 _paymentRequest->payment_details().display_items.empty()) {
480 return YES; 479 return YES;
481 } else { 480 } else {
482 return NO; 481 return NO;
483 } 482 }
484 } 483 }
485 484
486 @end 485 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698