Chromium Code Reviews| Index: ios/chrome/browser/payments/payment_method_selection_coordinator.mm |
| diff --git a/ios/chrome/browser/payments/payment_method_selection_coordinator.mm b/ios/chrome/browser/payments/payment_method_selection_coordinator.mm |
| index 6cf1de3c3d0bc93f2f886281b7a32edd9750a110..4d32e858aca49319783b1c2e8099f0b2e8ff54b2 100644 |
| --- a/ios/chrome/browser/payments/payment_method_selection_coordinator.mm |
| +++ b/ios/chrome/browser/payments/payment_method_selection_coordinator.mm |
| @@ -4,15 +4,16 @@ |
| #import "ios/chrome/browser/payments/payment_method_selection_coordinator.h" |
| -#import "base/ios/weak_nsobject.h" |
| -#include "base/mac/scoped_nsobject.h" |
| #include "components/autofill/core/browser/credit_card.h" |
| #include "ios/chrome/browser/payments/payment_request.h" |
| -@interface PaymentMethodSelectionCoordinator () { |
| - base::WeakNSProtocol<id<PaymentMethodSelectionCoordinatorDelegate>> _delegate; |
| - base::scoped_nsobject<PaymentMethodSelectionViewController> _viewController; |
| -} |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +@interface PaymentMethodSelectionCoordinator () |
| +@property(nonatomic, strong) |
| + PaymentMethodSelectionViewController* viewController; |
| // Called when the user selects a payment method. The cell is checked, the |
| // UI is locked so that the user can't interact with it, then the delegate is |
| @@ -23,20 +24,13 @@ |
| @end |
| @implementation PaymentMethodSelectionCoordinator |
| - |
| @synthesize paymentRequest = _paymentRequest; |
| - |
| -- (id<PaymentMethodSelectionCoordinatorDelegate>)delegate { |
| - return _delegate.get(); |
| -} |
| - |
| -- (void)setDelegate:(id<PaymentMethodSelectionCoordinatorDelegate>)delegate { |
| - _delegate.reset(delegate); |
| -} |
| +@synthesize delegate = _delegate; |
| +@synthesize viewController = _viewController; |
| - (void)start { |
| - _viewController.reset([[PaymentMethodSelectionViewController alloc] |
| - initWithPaymentRequest:_paymentRequest]); |
| + _viewController = [[PaymentMethodSelectionViewController alloc] |
| + initWithPaymentRequest:_paymentRequest]; |
| [_viewController setDelegate:self]; |
| [_viewController loadModel]; |
| @@ -49,7 +43,7 @@ |
| - (void)stop { |
| [[self baseViewController].navigationController |
| popViewControllerAnimated:YES]; |
| - _viewController.reset(); |
| + _viewController = nil; |
| } |
| #pragma mark - PaymentMethodSelectionViewControllerDelegate |
| @@ -67,22 +61,21 @@ |
| } |
| - (void)delayedNotifyDelegateOfSelection:(autofill::CreditCard*)paymentMethod { |
| - _viewController.get().view.userInteractionEnabled = NO; |
| - base::WeakNSObject<PaymentMethodSelectionCoordinator> weakSelf(self); |
| - dispatch_after( |
| - dispatch_time(DISPATCH_TIME_NOW, |
| - static_cast<int64_t>(0.2 * NSEC_PER_SEC)), |
| - dispatch_get_main_queue(), ^{ |
| - base::scoped_nsobject<PaymentMethodSelectionCoordinator> strongSelf( |
| - [weakSelf retain]); |
| - // Early return if the coordinator has been deallocated. |
| - if (!strongSelf) |
| - return; |
| - |
| - _viewController.get().view.userInteractionEnabled = YES; |
| - [_delegate paymentMethodSelectionCoordinator:self |
| - didSelectPaymentMethod:paymentMethod]; |
| - }); |
| + _viewController.view.userInteractionEnabled = NO; |
| + __weak PaymentMethodSelectionCoordinator* weakSelf = self; |
| + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, |
| + static_cast<int64_t>(0.2 * NSEC_PER_SEC)), |
| + dispatch_get_main_queue(), ^{ |
| + PaymentMethodSelectionCoordinator* strongSelf = weakSelf; |
| + // Early return if the coordinator has been deallocated. |
| + if (!strongSelf) |
|
marq (ping after 24h)
2017/02/22 11:55:58
Nit: No need to early return here.
stkhapugin
2017/02/22 17:47:06
Done.
|
| + return; |
| + |
| + strongSelf.viewController.view.userInteractionEnabled = YES; |
| + [strongSelf.delegate |
| + paymentMethodSelectionCoordinator:strongSelf |
| + didSelectPaymentMethod:paymentMethod]; |
| + }); |
| } |
| @end |