Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: ios/clean/chrome/browser/ui/tab/tab_coordinator.mm

Issue 2734333003: Child coordinators notify their parent upon -start and -stop. (Closed)
Patch Set: Feedback Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_coordinator.h" 9 #import "ios/clean/chrome/browser/ui/tab/tab_coordinator.h"
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 ToolbarCoordinator* toolbarCoordinator = [[ToolbarCoordinator alloc] init]; 65 ToolbarCoordinator* toolbarCoordinator = [[ToolbarCoordinator alloc] init];
66 toolbarCoordinator.webState = self.webState; 66 toolbarCoordinator.webState = self.webState;
67 [self addChildCoordinator:toolbarCoordinator]; 67 [self addChildCoordinator:toolbarCoordinator];
68 68
69 // Unset the base view controller, so |toolbarCoordinator| doesn't present 69 // Unset the base view controller, so |toolbarCoordinator| doesn't present
70 // its view controller. 70 // its view controller.
71 toolbarCoordinator.context.baseViewController = nil; 71 toolbarCoordinator.context.baseViewController = nil;
72 [toolbarCoordinator start]; 72 [toolbarCoordinator start];
73 73
74 self.viewController.toolbarViewController = toolbarCoordinator.viewController;
75 self.viewController.contentViewController = webCoordinator.viewController;
76
77 // PLACEHOLDER: Replace this placeholder with an actual tab strip view 74 // PLACEHOLDER: Replace this placeholder with an actual tab strip view
78 // controller. 75 // controller.
79 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; 76 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
80 [button addTarget:nil 77 [button addTarget:nil
81 action:@selector(hideTabStrip:) 78 action:@selector(hideTabStrip:)
82 forControlEvents:UIControlEventTouchUpInside]; 79 forControlEvents:UIControlEventTouchUpInside];
83 [button setTitle:@"Hide Strip" forState:UIControlStateNormal]; 80 [button setTitle:@"Hide Strip" forState:UIControlStateNormal];
84 button.frame = CGRectMake(10, 10, 100, 100); 81 button.frame = CGRectMake(10, 10, 100, 100);
85 82
86 UIViewController* tabStripViewController = [[UIViewController alloc] init]; 83 UIViewController* tabStripViewController = [[UIViewController alloc] init];
87 tabStripViewController.view.backgroundColor = [UIColor blackColor]; 84 tabStripViewController.view.backgroundColor = [UIColor blackColor];
88 [tabStripViewController.view addSubview:button]; 85 [tabStripViewController.view addSubview:button];
89 self.viewController.tabStripViewController = tabStripViewController; 86 self.viewController.tabStripViewController = tabStripViewController;
90 87
91 [self.context.baseViewController presentViewController:self.viewController 88 [self.context.baseViewController presentViewController:self.viewController
92 animated:self.context.animated 89 animated:self.context.animated
93 completion:nil]; 90 completion:nil];
91 [super start];
94 } 92 }
95 93
96 - (void)stop { 94 - (void)stop {
95 [super stop];
97 [self.viewController.presentingViewController 96 [self.viewController.presentingViewController
98 dismissViewControllerAnimated:self.context.animated 97 dismissViewControllerAnimated:self.context.animated
99 completion:nil]; 98 completion:nil];
100 _webStateObserver.reset(); 99 _webStateObserver.reset();
101 } 100 }
102 101
102 - (void)childCoordinatorDidStart:(BrowserCoordinator*)coordinator {
rohitrao (ping after 24h) 2017/03/08 19:01:45 Overall this lg. We can discuss whether to use is
103 if ([coordinator isKindOfClass:[ToolbarCoordinator class]]) {
104 self.viewController.toolbarViewController = coordinator.viewController;
105 } else if ([coordinator isKindOfClass:[WebCoordinator class]]) {
106 self.viewController.contentViewController = coordinator.viewController;
107 }
108 }
109
103 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator { 110 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator {
104 // This coordinator will always accept overlay coordinators. 111 // This coordinator will always accept overlay coordinators.
105 return YES; 112 return YES;
106 } 113 }
107 114
108 #pragma mark - Experiment support 115 #pragma mark - Experiment support
109 116
110 // Create and return a new view controller for use as a tab container; 117 // Create and return a new view controller for use as a tab container;
111 // experimental configurations determine which subclass of 118 // experimental configurations determine which subclass of
112 // TabContainerViewController to return. 119 // TabContainerViewController to return.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 - (id<UIViewControllerAnimatedTransitioning>) 155 - (id<UIViewControllerAnimatedTransitioning>)
149 animationControllerForDismissedController:(UIViewController*)dismissed { 156 animationControllerForDismissedController:(UIViewController*)dismissed {
150 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; 157 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init];
151 animator.presenting = NO; 158 animator.presenting = NO;
152 animator.presentationKey = self.presentationKey; 159 animator.presentationKey = self.presentationKey;
153 [animator selectDelegate:@[ dismissed.presentingViewController ]]; 160 [animator selectDelegate:@[ dismissed.presentingViewController ]];
154 return animator; 161 return animator;
155 } 162 }
156 163
157 @end 164 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698