| 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 overlaying; | 24 @property(nonatomic, readwrite) BOOL overlaying; |
| 25 @end | 25 @end |
| 26 | 26 |
| 27 @implementation BrowserCoordinator | 27 @implementation BrowserCoordinator |
| 28 | 28 |
| 29 @synthesize context = _context; | 29 @synthesize context = _context; |
| 30 @synthesize browserState = _browserState; | 30 @synthesize browser = _browser; |
| 31 @synthesize childCoordinators = _childCoordinators; | 31 @synthesize childCoordinators = _childCoordinators; |
| 32 @synthesize parentCoordinator = _parentCoordinator; | 32 @synthesize parentCoordinator = _parentCoordinator; |
| 33 @synthesize overlaying = _overlaying; | 33 @synthesize overlaying = _overlaying; |
| 34 | 34 |
| 35 - (instancetype)init { | 35 - (instancetype)init { |
| 36 if (self = [super init]) { | 36 if (self = [super init]) { |
| 37 _context = [[CoordinatorContext alloc] init]; | 37 _context = [[CoordinatorContext alloc] init]; |
| 38 _childCoordinators = [NSMutableSet set]; | 38 _childCoordinators = [NSMutableSet set]; |
| 39 } | 39 } |
| 40 return self; | 40 return self; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 59 - (NSSet*)children { | 59 - (NSSet*)children { |
| 60 return [self.childCoordinators copy]; | 60 return [self.childCoordinators copy]; |
| 61 } | 61 } |
| 62 | 62 |
| 63 - (void)addChildCoordinator:(BrowserCoordinator*)coordinator { | 63 - (void)addChildCoordinator:(BrowserCoordinator*)coordinator { |
| 64 CHECK([self respondsToSelector:@selector(viewController)]) | 64 CHECK([self respondsToSelector:@selector(viewController)]) |
| 65 << "BrowserCoordinator implementations must provide a viewController " | 65 << "BrowserCoordinator implementations must provide a viewController " |
| 66 "property."; | 66 "property."; |
| 67 [self.childCoordinators addObject:coordinator]; | 67 [self.childCoordinators addObject:coordinator]; |
| 68 coordinator.parentCoordinator = self; | 68 coordinator.parentCoordinator = self; |
| 69 coordinator.browserState = self.browserState; | 69 coordinator.browser = self.browser; |
| 70 coordinator.context.baseViewController = self.viewController; | 70 coordinator.context.baseViewController = self.viewController; |
| 71 } | 71 } |
| 72 | 72 |
| 73 - (BrowserCoordinator*)overlayCoordinator { | 73 - (BrowserCoordinator*)overlayCoordinator { |
| 74 if (self.overlaying) | 74 if (self.overlaying) |
| 75 return self; | 75 return self; |
| 76 for (BrowserCoordinator* child in self.children) { | 76 for (BrowserCoordinator* child in self.children) { |
| 77 BrowserCoordinator* overlay = child.overlayCoordinator; | 77 BrowserCoordinator* overlay = child.overlayCoordinator; |
| 78 if (overlay) | 78 if (overlay) |
| 79 return overlay; | 79 return overlay; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 - (void)removeChildCoordinator:(BrowserCoordinator*)coordinator { | 118 - (void)removeChildCoordinator:(BrowserCoordinator*)coordinator { |
| 119 if (![self.childCoordinators containsObject:coordinator]) | 119 if (![self.childCoordinators containsObject:coordinator]) |
| 120 return; | 120 return; |
| 121 [self.childCoordinators removeObject:coordinator]; | 121 [self.childCoordinators removeObject:coordinator]; |
| 122 coordinator.parentCoordinator = nil; | 122 coordinator.parentCoordinator = nil; |
| 123 } | 123 } |
| 124 | 124 |
| 125 @end | 125 @end |
| OLD | NEW |