| 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 "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h" | 9 #import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h" |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 [NSLayoutConstraint activateConstraints:[self subviewConstraints]]; | 90 [NSLayoutConstraint activateConstraints:[self subviewConstraints]]; |
| 91 } | 91 } |
| 92 | 92 |
| 93 #pragma mark - Public properties | 93 #pragma mark - Public properties |
| 94 | 94 |
| 95 - (void)setContentViewController:(UIViewController*)contentViewController { | 95 - (void)setContentViewController:(UIViewController*)contentViewController { |
| 96 if (self.contentViewController == contentViewController) | 96 if (self.contentViewController == contentViewController) |
| 97 return; | 97 return; |
| 98 if ([self isViewLoaded]) { | 98 if ([self isViewLoaded]) { |
| 99 [self removeChildViewController:self.contentViewController]; | 99 [self detachChildViewController:self.contentViewController]; |
| 100 [self addChildViewController:contentViewController | 100 [self addChildViewController:contentViewController |
| 101 toSubview:self.contentView]; | 101 toSubview:self.contentView]; |
| 102 } | 102 } |
| 103 _contentViewController = contentViewController; | 103 _contentViewController = contentViewController; |
| 104 } | 104 } |
| 105 | 105 |
| 106 - (void)setToolbarViewController:(UIViewController*)toolbarViewController { | 106 - (void)setToolbarViewController:(UIViewController*)toolbarViewController { |
| 107 if (self.toolbarViewController == toolbarViewController) | 107 if (self.toolbarViewController == toolbarViewController) |
| 108 return; | 108 return; |
| 109 if ([self isViewLoaded]) { | 109 if ([self isViewLoaded]) { |
| 110 [self removeChildViewController:self.toolbarViewController]; | 110 [self detachChildViewController:self.toolbarViewController]; |
| 111 [self addChildViewController:toolbarViewController | 111 [self addChildViewController:toolbarViewController |
| 112 toSubview:self.toolbarView]; | 112 toSubview:self.toolbarView]; |
| 113 } | 113 } |
| 114 _toolbarViewController = toolbarViewController; | 114 _toolbarViewController = toolbarViewController; |
| 115 } | 115 } |
| 116 | 116 |
| 117 - (void)setTabStripViewController:(UIViewController*)tabStripViewController { | 117 - (void)setTabStripViewController:(UIViewController*)tabStripViewController { |
| 118 if (self.tabStripViewController == tabStripViewController) | 118 if (self.tabStripViewController == tabStripViewController) |
| 119 return; | 119 return; |
| 120 if ([self isViewLoaded]) { | 120 if ([self isViewLoaded]) { |
| 121 [self removeChildViewController:self.tabStripViewController]; | 121 [self detachChildViewController:self.tabStripViewController]; |
| 122 [self addChildViewController:tabStripViewController | 122 [self addChildViewController:tabStripViewController |
| 123 toSubview:self.tabStripView]; | 123 toSubview:self.tabStripView]; |
| 124 } | 124 } |
| 125 _tabStripViewController = tabStripViewController; | 125 _tabStripViewController = tabStripViewController; |
| 126 } | 126 } |
| 127 | 127 |
| 128 #pragma mark - ChildViewController helper methods | 128 #pragma mark - ChildViewController helper methods |
| 129 | 129 |
| 130 - (void)addChildViewController:(UIViewController*)viewController | 130 - (void)addChildViewController:(UIViewController*)viewController |
| 131 toSubview:(UIView*)subview { | 131 toSubview:(UIView*)subview { |
| 132 if (!viewController || !subview) { | 132 if (!viewController || !subview) { |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 [self addChildViewController:viewController]; | 135 [self addChildViewController:viewController]; |
| 136 viewController.view.translatesAutoresizingMaskIntoConstraints = YES; | 136 viewController.view.translatesAutoresizingMaskIntoConstraints = YES; |
| 137 viewController.view.autoresizingMask = | 137 viewController.view.autoresizingMask = |
| 138 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 138 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
| 139 viewController.view.frame = subview.bounds; | 139 viewController.view.frame = subview.bounds; |
| 140 [subview addSubview:viewController.view]; | 140 [subview addSubview:viewController.view]; |
| 141 [viewController didMoveToParentViewController:self]; | 141 [viewController didMoveToParentViewController:self]; |
| 142 } | 142 } |
| 143 | 143 |
| 144 - (void)removeChildViewController:(UIViewController*)viewController { | 144 - (void)detachChildViewController:(UIViewController*)viewController { |
| 145 if (viewController.parentViewController != self) | 145 if (viewController.parentViewController != self) |
| 146 return; | 146 return; |
| 147 [viewController willMoveToParentViewController:nil]; | 147 [viewController willMoveToParentViewController:nil]; |
| 148 [viewController.view removeFromSuperview]; | 148 [viewController.view removeFromSuperview]; |
| 149 [viewController removeFromParentViewController]; | 149 [viewController removeFromParentViewController]; |
| 150 } | 150 } |
| 151 | 151 |
| 152 #pragma mark - MenuPresentationDelegate | 152 #pragma mark - MenuPresentationDelegate |
| 153 | 153 |
| 154 - (CGRect)frameForMenuPresentation:(UIPresentationController*)presentation { | 154 - (CGRect)frameForMenuPresentation:(UIPresentationController*)presentation { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 constraintEqualToAnchor:self.view.leadingAnchor], | 297 constraintEqualToAnchor:self.view.leadingAnchor], |
| 298 [self.toolbarView.trailingAnchor | 298 [self.toolbarView.trailingAnchor |
| 299 constraintEqualToAnchor:self.view.trailingAnchor], | 299 constraintEqualToAnchor:self.view.trailingAnchor], |
| 300 self.toolbarHeightConstraint, | 300 self.toolbarHeightConstraint, |
| 301 [self.toolbarView.bottomAnchor | 301 [self.toolbarView.bottomAnchor |
| 302 constraintEqualToAnchor:self.bottomLayoutGuide.topAnchor], | 302 constraintEqualToAnchor:self.bottomLayoutGuide.topAnchor], |
| 303 ]; | 303 ]; |
| 304 } | 304 } |
| 305 | 305 |
| 306 @end | 306 @end |
| OLD | NEW |