| 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/chrome_coordinator.h" | 5 #import "ios/chrome/browser/chrome_coordinator.h" |
| 6 | 6 |
| 7 #include "base/ios/weak_nsobject.h" | |
| 8 #include "base/logging.h" | 7 #include "base/logging.h" |
| 9 #import "base/mac/scoped_nsobject.h" | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
| 10 | 12 |
| 11 @interface ChromeCoordinator () { | 13 @interface ChromeCoordinator () { |
| 12 base::WeakNSObject<UIViewController> _baseViewController; | 14 __weak UIViewController* _baseViewController; |
| 13 base::scoped_nsobject<MutableCoordinatorArray> _childCoordinators; | 15 MutableCoordinatorArray* _childCoordinators; |
| 14 } | 16 } |
| 15 @end | 17 @end |
| 16 | 18 |
| 17 @implementation ChromeCoordinator | 19 @implementation ChromeCoordinator |
| 18 | 20 |
| 19 - (nullable instancetype)initWithBaseViewController: | 21 - (nullable instancetype)initWithBaseViewController: |
| 20 (UIViewController*)viewController { | 22 (UIViewController*)viewController { |
| 21 if (self = [super init]) { | 23 if (self = [super init]) { |
| 22 _baseViewController.reset(viewController); | 24 _baseViewController = viewController; |
| 23 _childCoordinators.reset([[MutableCoordinatorArray array] retain]); | 25 _childCoordinators = [MutableCoordinatorArray array]; |
| 24 } | 26 } |
| 25 return self; | 27 return self; |
| 26 } | 28 } |
| 27 | 29 |
| 28 - (nullable instancetype)init { | 30 - (nullable instancetype)init { |
| 29 NOTREACHED(); | 31 NOTREACHED(); |
| 30 return nil; | 32 return nil; |
| 31 } | 33 } |
| 32 | 34 |
| 33 - (void)dealloc { | 35 - (void)dealloc { |
| 34 [self stop]; | 36 [self stop]; |
| 35 [super dealloc]; | |
| 36 } | 37 } |
| 37 | 38 |
| 38 - (MutableCoordinatorArray*)childCoordinators { | 39 - (MutableCoordinatorArray*)childCoordinators { |
| 39 return _childCoordinators; | 40 return _childCoordinators; |
| 40 } | 41 } |
| 41 | 42 |
| 42 - (ChromeCoordinator*)activeChildCoordinator { | 43 - (ChromeCoordinator*)activeChildCoordinator { |
| 43 // By default the active child is the one most recently added to the child | 44 // By default the active child is the one most recently added to the child |
| 44 // array, but subclasses can override this. | 45 // array, but subclasses can override this. |
| 45 return self.childCoordinators.lastObject; | 46 return self.childCoordinators.lastObject; |
| 46 } | 47 } |
| 47 | 48 |
| 48 - (nullable UIViewController*)baseViewController { | 49 - (nullable UIViewController*)baseViewController { |
| 49 return _baseViewController; | 50 return _baseViewController; |
| 50 } | 51 } |
| 51 | 52 |
| 52 - (void)start { | 53 - (void)start { |
| 53 // Default implementation does nothing. | 54 // Default implementation does nothing. |
| 54 } | 55 } |
| 55 | 56 |
| 56 - (void)stop { | 57 - (void)stop { |
| 57 // Default implementation does nothing. | 58 // Default implementation does nothing. |
| 58 } | 59 } |
| 59 | 60 |
| 60 @end | 61 @end |
| OLD | NEW |