| 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/animators/zoom_transition_animator.h" | 17 #import "ios/clean/chrome/browser/ui/animators/zoom_transition_animator.h" |
| 17 #import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h" | 18 #import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h" |
| 18 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_coordinator.h" | 19 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_coordinator.h" |
| 19 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" | 20 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" |
| 20 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" | 21 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" |
| 21 #import "ios/web/public/web_state/web_state_observer_bridge.h" | 22 #import "ios/web/public/web_state/web_state_observer_bridge.h" |
| 22 | 23 |
| 23 #if !defined(__has_feature) || !__has_feature(objc_arc) | 24 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 24 #error "This file requires ARC support." | 25 #error "This file requires ARC support." |
| 25 #endif | 26 #endif |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 _webStateObserver = base::MakeUnique<web::WebStateObserverBridge>( | 63 _webStateObserver = base::MakeUnique<web::WebStateObserverBridge>( |
| 63 self.webState, toolbarCoordinator); | 64 self.webState, toolbarCoordinator); |
| 64 // Unset the base view controller, so |toolbarCoordinator| doesn't present | 65 // Unset the base view controller, so |toolbarCoordinator| doesn't present |
| 65 // its view controller. | 66 // its view controller. |
| 66 toolbarCoordinator.context.baseViewController = nil; | 67 toolbarCoordinator.context.baseViewController = nil; |
| 67 [toolbarCoordinator start]; | 68 [toolbarCoordinator start]; |
| 68 | 69 |
| 69 self.viewController.toolbarViewController = toolbarCoordinator.viewController; | 70 self.viewController.toolbarViewController = toolbarCoordinator.viewController; |
| 70 self.viewController.contentViewController = webCoordinator.viewController; | 71 self.viewController.contentViewController = webCoordinator.viewController; |
| 71 | 72 |
| 73 // PLACEHOLDER: Replace this placeholder with an actual tab strip view |
| 74 // controller. |
| 75 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 76 [button addTarget:nil |
| 77 action:@selector(showTabGrid:) |
| 78 forControlEvents:UIControlEventTouchUpInside]; |
| 79 [button setTitle:@"Tab grid" forState:UIControlStateNormal]; |
| 80 button.frame = CGRectMake(10, 10, 100, 100); |
| 81 |
| 82 UIViewController* tabStripViewController = [[UIViewController alloc] init]; |
| 83 tabStripViewController.view.backgroundColor = [UIColor blackColor]; |
| 84 [tabStripViewController.view addSubview:button]; |
| 85 self.viewController.tabStripViewController = tabStripViewController; |
| 86 |
| 72 [self.context.baseViewController presentViewController:self.viewController | 87 [self.context.baseViewController presentViewController:self.viewController |
| 73 animated:self.context.animated | 88 animated:self.context.animated |
| 74 completion:nil]; | 89 completion:nil]; |
| 75 } | 90 } |
| 76 | 91 |
| 77 - (void)stop { | 92 - (void)stop { |
| 78 [self.viewController.presentingViewController | 93 [self.viewController.presentingViewController |
| 79 dismissViewControllerAnimated:self.context.animated | 94 dismissViewControllerAnimated:self.context.animated |
| 80 completion:nil]; | 95 completion:nil]; |
| 81 _webStateObserver.reset(); | 96 _webStateObserver.reset(); |
| 82 } | 97 } |
| 83 | 98 |
| 84 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator { | 99 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator { |
| 85 // This coordinator will always accept overlay coordinators. | 100 // This coordinator will always accept overlay coordinators. |
| 86 return YES; | 101 return YES; |
| 87 } | 102 } |
| 88 | 103 |
| 89 #pragma mark - Experiment support | 104 #pragma mark - Experiment support |
| 90 | 105 |
| 91 // Create and return a new view controller for use as a tab container; | 106 // Create and return a new view controller for use as a tab container; |
| 92 // experimental configurations determine which subclass of | 107 // experimental configurations determine which subclass of |
| 93 // TabContainerViewController to return. | 108 // TabContainerViewController to return. |
| 94 - (TabContainerViewController*)newTabContainer { | 109 - (TabContainerViewController*)newTabContainer { |
| 95 if (kUseBottomToolbar) { | 110 if (kUseBottomToolbar) { |
| 96 return [[BottomToolbarTabViewController alloc] init]; | 111 return [[BottomToolbarTabViewController alloc] init]; |
| 97 } | 112 } |
| 98 return [[TopToolbarTabViewController alloc] init]; | 113 return [[TabContainerViewController alloc] init]; |
| 99 } | 114 } |
| 100 | 115 |
| 101 #pragma mark - UIViewControllerTransitioningDelegate | 116 #pragma mark - UIViewControllerTransitioningDelegate |
| 102 | 117 |
| 103 - (id<UIViewControllerAnimatedTransitioning>) | 118 - (id<UIViewControllerAnimatedTransitioning>) |
| 104 animationControllerForPresentedController:(UIViewController*)presented | 119 animationControllerForPresentedController:(UIViewController*)presented |
| 105 presentingController:(UIViewController*)presenting | 120 presentingController:(UIViewController*)presenting |
| 106 sourceController:(UIViewController*)source { | 121 sourceController:(UIViewController*)source { |
| 107 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; | 122 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; |
| 108 animator.presenting = YES; | 123 animator.presenting = YES; |
| 109 animator.presentationKey = self.presentationKey; | 124 animator.presentationKey = self.presentationKey; |
| 110 [animator selectDelegate:@[ source, presenting ]]; | 125 [animator selectDelegate:@[ source, presenting ]]; |
| 111 return animator; | 126 return animator; |
| 112 } | 127 } |
| 113 | 128 |
| 114 - (id<UIViewControllerAnimatedTransitioning>) | 129 - (id<UIViewControllerAnimatedTransitioning>) |
| 115 animationControllerForDismissedController:(UIViewController*)dismissed { | 130 animationControllerForDismissedController:(UIViewController*)dismissed { |
| 116 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; | 131 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; |
| 117 animator.presenting = NO; | 132 animator.presenting = NO; |
| 118 animator.presentationKey = self.presentationKey; | 133 animator.presentationKey = self.presentationKey; |
| 119 [animator selectDelegate:@[ dismissed.presentingViewController ]]; | 134 [animator selectDelegate:@[ dismissed.presentingViewController ]]; |
| 120 return animator; | 135 return animator; |
| 121 } | 136 } |
| 122 | 137 |
| 123 @end | 138 @end |
| OLD | NEW |