| 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 // ====== New Architecture ===== | 5 // ====== New Architecture ===== |
| 6 // = This code is only used in the new iOS Chrome architecture. = | 6 // = This code is only used in the new iOS Chrome architecture. = |
| 7 // ============================================================================ | 7 // ============================================================================ |
| 8 | 8 |
| 9 #import "base/logging.h" | 9 #import "base/logging.h" |
| 10 #import "ios/clean/chrome/browser/browser_coordinator+internal.h" | 10 #import "ios/clean/chrome/browser/browser_coordinator+internal.h" |
| 11 #import "ios/clean/chrome/browser/browser_coordinator.h" | 11 #import "ios/clean/chrome/browser/browser_coordinator.h" |
| 12 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" | 12 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" |
| 13 | 13 |
| 14 #if !defined(__has_feature) || !__has_feature(objc_arc) | 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 15 #error "This file requires ARC support." | 15 #error "This file requires ARC support." |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 @interface BrowserCoordinator () | 18 @interface BrowserCoordinator () |
| 19 // Child coordinators owned by this object. | 19 // Child coordinators owned by this object. |
| 20 @property(nonatomic, strong) | 20 @property(nonatomic, strong) |
| 21 NSMutableSet<BrowserCoordinator*>* childCoordinators; | 21 NSMutableSet<BrowserCoordinator*>* childCoordinators; |
| 22 // Parent coordinator of this object, if any. | 22 // Parent coordinator of this object, if any. |
| 23 @property(nonatomic, readwrite, weak) BrowserCoordinator* parentCoordinator; | 23 @property(nonatomic, readwrite, weak) BrowserCoordinator* parentCoordinator; |
| 24 @property(nonatomic, readwrite) BOOL started; |
| 24 @property(nonatomic, readwrite) BOOL overlaying; | 25 @property(nonatomic, readwrite) BOOL overlaying; |
| 25 @end | 26 @end |
| 26 | 27 |
| 27 @implementation BrowserCoordinator | 28 @implementation BrowserCoordinator |
| 28 | 29 |
| 29 @synthesize context = _context; | 30 @synthesize context = _context; |
| 30 @synthesize browser = _browser; | 31 @synthesize browser = _browser; |
| 31 @synthesize childCoordinators = _childCoordinators; | 32 @synthesize childCoordinators = _childCoordinators; |
| 32 @synthesize parentCoordinator = _parentCoordinator; | 33 @synthesize parentCoordinator = _parentCoordinator; |
| 34 @synthesize started = _started; |
| 33 @synthesize overlaying = _overlaying; | 35 @synthesize overlaying = _overlaying; |
| 34 | 36 |
| 35 - (instancetype)init { | 37 - (instancetype)init { |
| 36 if (self = [super init]) { | 38 if (self = [super init]) { |
| 37 _context = [[CoordinatorContext alloc] init]; | 39 _context = [[CoordinatorContext alloc] init]; |
| 38 _childCoordinators = [NSMutableSet set]; | 40 _childCoordinators = [NSMutableSet set]; |
| 39 } | 41 } |
| 40 return self; | 42 return self; |
| 41 } | 43 } |
| 42 | 44 |
| 43 #pragma mark - Public API | 45 #pragma mark - Public API |
| 44 | 46 |
| 45 - (void)start { | 47 - (void)start { |
| 48 self.started = YES; |
| 46 [self.parentCoordinator childCoordinatorDidStart:self]; | 49 [self.parentCoordinator childCoordinatorDidStart:self]; |
| 47 } | 50 } |
| 48 | 51 |
| 49 - (void)stop { | 52 - (void)stop { |
| 50 [self.parentCoordinator childCoordinatorWillStop:self]; | 53 [self.parentCoordinator childCoordinatorWillStop:self]; |
| 54 self.started = NO; |
| 51 } | 55 } |
| 52 | 56 |
| 53 @end | 57 @end |
| 54 | 58 |
| 55 @implementation BrowserCoordinator (Internal) | 59 @implementation BrowserCoordinator (Internal) |
| 56 // Concrete implementations must implement a |viewController| property. | 60 // Concrete implementations must implement a |viewController| property. |
| 57 @dynamic viewController; | 61 @dynamic viewController; |
| 58 | 62 |
| 59 - (NSSet*)children { | 63 - (NSSet*)children { |
| 60 return [self.childCoordinators copy]; | 64 return [self.childCoordinators copy]; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 128 |
| 125 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { | 129 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { |
| 126 // Default implementation is a no-op. | 130 // Default implementation is a no-op. |
| 127 } | 131 } |
| 128 | 132 |
| 129 - (void)childCoordinatorWillStop:(BrowserCoordinator*)childCoordinator { | 133 - (void)childCoordinatorWillStop:(BrowserCoordinator*)childCoordinator { |
| 130 // Default implementation is a no-op. | 134 // Default implementation is a no-op. |
| 131 } | 135 } |
| 132 | 136 |
| 133 @end | 137 @end |
| OLD | NEW |