Chromium Code Reviews| 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_coordinator.h" | 9 #import "ios/clean/chrome/browser/ui/tab/tab_coordinator.h" |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #import "ios/clean/chrome/browser/browser_coordinator+internal.h" | 15 #import "ios/clean/chrome/browser/browser_coordinator+internal.h" |
| 16 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" | 16 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" |
| 17 #import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h" | 17 #import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h" |
| 18 #import "ios/clean/chrome/browser/ui/animators/zoom_transition_animator.h" | 18 #import "ios/clean/chrome/browser/ui/animators/zoom_transition_animator.h" |
| 19 #import "ios/clean/chrome/browser/ui/find_in_page/find_in_page_coordinator.h" | |
| 19 #import "ios/clean/chrome/browser/ui/ntp/new_tab_page_coordinator.h" | 20 #import "ios/clean/chrome/browser/ui/ntp/new_tab_page_coordinator.h" |
| 20 #import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h" | 21 #import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h" |
| 21 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_coordinator.h" | 22 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_coordinator.h" |
| 22 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" | 23 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" |
| 23 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" | 24 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" |
| 24 #import "ios/web/public/web_state/web_state.h" | 25 #import "ios/web/public/web_state/web_state.h" |
| 25 #import "ios/web/public/web_state/web_state_observer_bridge.h" | 26 #import "ios/web/public/web_state/web_state_observer_bridge.h" |
| 26 | 27 |
| 27 #if !defined(__has_feature) || !__has_feature(objc_arc) | 28 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 28 #error "This file requires ARC support." | 29 #error "This file requires ARC support." |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 | 65 |
| 65 ToolbarCoordinator* toolbarCoordinator = [[ToolbarCoordinator alloc] init]; | 66 ToolbarCoordinator* toolbarCoordinator = [[ToolbarCoordinator alloc] init]; |
| 66 toolbarCoordinator.webState = self.webState; | 67 toolbarCoordinator.webState = self.webState; |
| 67 [self addChildCoordinator:toolbarCoordinator]; | 68 [self addChildCoordinator:toolbarCoordinator]; |
| 68 | 69 |
| 69 // Unset the base view controller, so |toolbarCoordinator| doesn't present | 70 // Unset the base view controller, so |toolbarCoordinator| doesn't present |
| 70 // its view controller. | 71 // its view controller. |
| 71 toolbarCoordinator.context.baseViewController = nil; | 72 toolbarCoordinator.context.baseViewController = nil; |
| 72 [toolbarCoordinator start]; | 73 [toolbarCoordinator start]; |
| 73 | 74 |
| 75 // Create the FindInPage coordinator but do not start it. It will be started | |
| 76 // when a find in page operation is invoked. | |
| 77 FindInPageCoordinator* findInPageCoordinator = | |
| 78 [[FindInPageCoordinator alloc] init]; | |
| 79 [self addChildCoordinator:findInPageCoordinator]; | |
| 80 | |
| 74 // PLACEHOLDER: Replace this placeholder with an actual tab strip view | 81 // PLACEHOLDER: Replace this placeholder with an actual tab strip view |
| 75 // controller. | 82 // controller. |
| 76 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; | 83 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 77 [button addTarget:nil | 84 [button addTarget:nil |
| 78 action:@selector(hideTabStrip:) | 85 action:@selector(hideTabStrip:) |
| 79 forControlEvents:UIControlEventTouchUpInside]; | 86 forControlEvents:UIControlEventTouchUpInside]; |
| 80 [button setTitle:@"Hide Strip" forState:UIControlStateNormal]; | 87 [button setTitle:@"Hide Strip" forState:UIControlStateNormal]; |
| 81 button.frame = CGRectMake(10, 10, 100, 100); | 88 button.frame = CGRectMake(10, 10, 100, 100); |
| 82 | 89 |
| 83 UIViewController* tabStripViewController = [[UIViewController alloc] init]; | 90 UIViewController* tabStripViewController = [[UIViewController alloc] init]; |
| 84 tabStripViewController.view.backgroundColor = [UIColor blackColor]; | 91 tabStripViewController.view.backgroundColor = [UIColor blackColor]; |
| 85 [tabStripViewController.view addSubview:button]; | 92 [tabStripViewController.view addSubview:button]; |
| 86 self.viewController.tabStripViewController = tabStripViewController; | 93 self.viewController.tabStripViewController = tabStripViewController; |
| 87 | 94 |
| 88 [self.context.baseViewController presentViewController:self.viewController | 95 [self.context.baseViewController presentViewController:self.viewController |
| 89 animated:self.context.animated | 96 animated:self.context.animated |
| 90 completion:nil]; | 97 completion:nil]; |
| 91 [super start]; | 98 [super start]; |
| 92 } | 99 } |
| 93 | 100 |
| 94 - (void)stop { | 101 - (void)stop { |
| 95 [super stop]; | 102 [super stop]; |
| 96 [self.viewController.presentingViewController | 103 [self.viewController.presentingViewController |
| 97 dismissViewControllerAnimated:self.context.animated | 104 dismissViewControllerAnimated:self.context.animated |
| 98 completion:nil]; | 105 completion:nil]; |
| 99 _webStateObserver.reset(); | 106 _webStateObserver.reset(); |
| 100 } | 107 } |
| 101 | 108 |
| 102 - (void)childCoordinatorDidStart:(BrowserCoordinator*)coordinator { | 109 - (void)childCoordinatorDidStart:(BrowserCoordinator*)coordinator { |
| 103 if ([coordinator isKindOfClass:[ToolbarCoordinator class]]) { | 110 if ([coordinator isKindOfClass:[FindInPageCoordinator class]]) { |
| 111 self.viewController.findBarViewController = coordinator.viewController; | |
| 112 } else if ([coordinator isKindOfClass:[ToolbarCoordinator class]]) { | |
| 104 self.viewController.toolbarViewController = coordinator.viewController; | 113 self.viewController.toolbarViewController = coordinator.viewController; |
| 105 } else if ([coordinator isKindOfClass:[WebCoordinator class]]) { | 114 } else if ([coordinator isKindOfClass:[WebCoordinator class]]) { |
| 106 self.viewController.contentViewController = coordinator.viewController; | 115 self.viewController.contentViewController = coordinator.viewController; |
| 107 } | 116 } |
| 108 } | 117 } |
| 109 | 118 |
| 119 - (void)childCoordinatorWillStop:(BrowserCoordinator*)coordinator { | |
| 120 if ([coordinator isKindOfClass:[FindInPageCoordinator class]]) { | |
| 121 self.viewController.findBarViewController = nil; | |
|
rohitrao (ping after 24h)
2017/03/14 01:10:37
12) The FIP coordinator can be stopped and its UI
| |
| 122 } else { | |
| 123 // No other child coordinators should ever stop. | |
| 124 NOTREACHED(); | |
| 125 } | |
| 126 } | |
| 127 | |
| 110 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator { | 128 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator { |
| 111 // This coordinator will always accept overlay coordinators. | 129 // This coordinator will always accept overlay coordinators. |
| 112 return YES; | 130 return YES; |
| 113 } | 131 } |
| 114 | 132 |
| 115 #pragma mark - Experiment support | 133 #pragma mark - Experiment support |
| 116 | 134 |
| 117 // Create and return a new view controller for use as a tab container; | 135 // Create and return a new view controller for use as a tab container; |
| 118 // experimental configurations determine which subclass of | 136 // experimental configurations determine which subclass of |
| 119 // TabContainerViewController to return. | 137 // TabContainerViewController to return. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 - (id<UIViewControllerAnimatedTransitioning>) | 173 - (id<UIViewControllerAnimatedTransitioning>) |
| 156 animationControllerForDismissedController:(UIViewController*)dismissed { | 174 animationControllerForDismissedController:(UIViewController*)dismissed { |
| 157 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; | 175 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; |
| 158 animator.presenting = NO; | 176 animator.presenting = NO; |
| 159 animator.presentationKey = self.presentationKey; | 177 animator.presentationKey = self.presentationKey; |
| 160 [animator selectDelegate:@[ dismissed.presentingViewController ]]; | 178 [animator selectDelegate:@[ dismissed.presentingViewController ]]; |
| 161 return animator; | 179 return animator; |
| 162 } | 180 } |
| 163 | 181 |
| 164 @end | 182 @end |
| OLD | NEW |