Chromium Code Reviews| Index: ios/chrome/browser/payments/shipping_option_selection_coordinator.mm |
| diff --git a/ios/chrome/browser/payments/shipping_option_selection_coordinator.mm b/ios/chrome/browser/payments/shipping_option_selection_coordinator.mm |
| index 5645a2a390cbf1af59e59575f9cf31f239892acf..f7ded922ab3e184c9451c383f20aa620abdcd66a 100644 |
| --- a/ios/chrome/browser/payments/shipping_option_selection_coordinator.mm |
| +++ b/ios/chrome/browser/payments/shipping_option_selection_coordinator.mm |
| @@ -4,15 +4,16 @@ |
| #import "ios/chrome/browser/payments/shipping_option_selection_coordinator.h" |
| -#import "base/ios/weak_nsobject.h" |
| -#include "base/mac/scoped_nsobject.h" |
| #include "base/strings/sys_string_conversions.h" |
| -@interface ShippingOptionSelectionCoordinator () { |
| - base::WeakNSProtocol<id<ShippingOptionSelectionCoordinatorDelegate>> |
| - _delegate; |
| - base::scoped_nsobject<ShippingOptionSelectionViewController> _viewController; |
| -} |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +@interface ShippingOptionSelectionCoordinator () |
| + |
| +@property(nonatomic, strong) |
| + ShippingOptionSelectionViewController* viewController; |
| // Called when the user selects a shipping option. The cell is checked, the |
| // UI is locked so that the user can't interact with it, then the delegate is |
| @@ -26,18 +27,12 @@ |
| @implementation ShippingOptionSelectionCoordinator |
| @synthesize paymentRequest = _paymentRequest; |
| - |
| -- (id<ShippingOptionSelectionCoordinatorDelegate>)delegate { |
| - return _delegate.get(); |
| -} |
| - |
| -- (void)setDelegate:(id<ShippingOptionSelectionCoordinatorDelegate>)delegate { |
| - _delegate.reset(delegate); |
| -} |
| +@synthesize delegate = _delegate; |
| +@synthesize viewController = _viewController; |
| - (void)start { |
| - _viewController.reset([[ShippingOptionSelectionViewController alloc] |
| - initWithPaymentRequest:_paymentRequest]); |
| + _viewController = [[ShippingOptionSelectionViewController alloc] |
| + initWithPaymentRequest:_paymentRequest]; |
| [_viewController setDelegate:self]; |
| [_viewController loadModel]; |
| @@ -49,13 +44,13 @@ |
| - (void)stop { |
| [self.baseViewController.navigationController popViewControllerAnimated:YES]; |
| - _viewController.reset(); |
| + _viewController = nil; |
| } |
| - (void)stopSpinnerAndDisplayError { |
| // Re-enable user interactions that were disabled earlier in |
| // delayedNotifyDelegateOfSelection. |
| - _viewController.get().view.userInteractionEnabled = YES; |
| + _viewController.view.userInteractionEnabled = YES; |
| [_viewController setIsLoading:NO]; |
| [_viewController |
| @@ -81,24 +76,23 @@ |
| - (void)delayedNotifyDelegateOfSelection: |
| (web::PaymentShippingOption*)shippingOption { |
| - _viewController.get().view.userInteractionEnabled = NO; |
| - base::WeakNSObject<ShippingOptionSelectionCoordinator> 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<ShippingOptionSelectionCoordinator> strongSelf( |
| - [weakSelf retain]); |
| - // Early return if the coordinator has been deallocated. |
| - if (!strongSelf) |
| - return; |
| - [_viewController setIsLoading:YES]; |
| - [_viewController loadModel]; |
| - [[_viewController collectionView] reloadData]; |
| - |
| - [_delegate shippingOptionSelectionCoordinator:self |
| - didSelectShippingOption:shippingOption]; |
| - }); |
| + _viewController.view.userInteractionEnabled = NO; |
| + __weak ShippingOptionSelectionCoordinator* weakSelf = self; |
| + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, |
| + static_cast<int64_t>(0.2 * NSEC_PER_SEC)), |
| + dispatch_get_main_queue(), ^{ |
| + ShippingOptionSelectionCoordinator* 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 setIsLoading:YES]; |
| + [strongSelf.viewController loadModel]; |
| + [[strongSelf.viewController collectionView] reloadData]; |
| + |
| + [strongSelf.delegate |
| + shippingOptionSelectionCoordinator:strongSelf |
| + didSelectShippingOption:shippingOption]; |
| + }); |
| } |
| @end |