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

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

Issue 2592983003: [Clean Skeleton] Migrate code to clean/ (Closed)
Patch Set: Rebased Created 3 years, 11 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
« no previous file with comments | « ios/chrome/browser/ui/tab/tab_coordinator.h ('k') | ios/chrome/browser/ui/tab_grid/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // ====== New Architecture =====
6 // = This code is only used in the new iOS Chrome architecture. =
7 // ============================================================================
8
9 #import "ios/chrome/browser/ui/tab/tab_coordinator.h"
10
11 #include <memory>
12
13 #include "base/mac/foundation_util.h"
14 #include "base/memory/ptr_util.h"
15 #import "ios/chrome/browser/browser_coordinator+internal.h"
16 #import "ios/chrome/browser/ui/animators/zoom_transition_animator.h"
17 #import "ios/chrome/browser/ui/tab/tab_container_view_controller.h"
18 #import "ios/chrome/browser/ui/toolbar/toolbar_coordinator.h"
19 #import "ios/chrome/browser/ui/web_contents/web_coordinator.h"
20 #import "ios/web/public/web_state/web_state_observer_bridge.h"
21
22 #if !defined(__has_feature) || !__has_feature(objc_arc)
23 #error "This file requires ARC support."
24 #endif
25
26 namespace {
27 // Placeholder "experiment" flag. Change this to YES to have the toolbar at the
28 // bottom.
29 const BOOL kUseBottomToolbar = NO;
30 } // namespace
31
32 @interface TabCoordinator ()<UIViewControllerTransitioningDelegate>
33 @property(nonatomic, strong) TabContainerViewController* viewController;
34 @end
35
36 @implementation TabCoordinator {
37 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver;
38 }
39
40 @synthesize webState = _webState;
41 @synthesize presentationKey = _presentationKey;
42 @synthesize viewController = _viewController;
43
44 - (void)start {
45 self.viewController = [self newTabContainer];
46 self.viewController.transitioningDelegate = self;
47 self.viewController.modalPresentationStyle = UIModalPresentationCustom;
48
49 WebCoordinator* webCoordinator = [[WebCoordinator alloc] init];
50 webCoordinator.webState = self.webState;
51 [self addChildCoordinator:webCoordinator];
52 // Unset the root view controller, so |webCoordinator| doesn't present its
53 // view controller.
54 webCoordinator.rootViewController = nil;
55 [webCoordinator start];
56
57 ToolbarCoordinator* toolbarCoordinator = [[ToolbarCoordinator alloc] init];
58 [self addChildCoordinator:toolbarCoordinator];
59 // TODO: Instead of this, let WebMediator maintain a set of webStateObservers
60 // and just provide -addObserver and -stopObserving methods.
61 _webStateObserver = base::MakeUnique<web::WebStateObserverBridge>(
62 self.webState, toolbarCoordinator);
63 // Unset the .base view controller, so |toolbarCoordinator| doesn't present
64 // its view controller.
65 toolbarCoordinator.rootViewController = nil;
66 [toolbarCoordinator start];
67
68 self.viewController.toolbarViewController = toolbarCoordinator.viewController;
69 self.viewController.contentViewController = webCoordinator.viewController;
70
71 [self.rootViewController presentViewController:self.viewController
72 animated:YES
73 completion:nil];
74 }
75
76 - (void)stop {
77 [self.viewController dismissViewControllerAnimated:YES completion:nil];
78 _webStateObserver.reset();
79 }
80
81 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator {
82 // This coordinator will always accept overlay coordinators.
83 return YES;
84 }
85
86 #pragma mark - Experiment support
87
88 // Create and return a new view controller for use as a tab container;
89 // experimental configurations determine which subclass of
90 // TabContainerViewController to return.
91 - (TabContainerViewController*)newTabContainer {
92 if (kUseBottomToolbar) {
93 return [[BottomToolbarTabViewController alloc] init];
94 }
95 return [[TopToolbarTabViewController alloc] init];
96 }
97
98 #pragma mark - UIViewControllerTransitioningDelegate
99
100 - (id<UIViewControllerAnimatedTransitioning>)
101 animationControllerForPresentedController:(UIViewController*)presented
102 presentingController:(UIViewController*)presenting
103 sourceController:(UIViewController*)source {
104 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init];
105 animator.presenting = YES;
106 animator.presentationKey = self.presentationKey;
107 [animator selectDelegate:@[ source, presenting ]];
108 return animator;
109 }
110
111 - (id<UIViewControllerAnimatedTransitioning>)
112 animationControllerForDismissedController:(UIViewController*)dismissed {
113 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init];
114 animator.presenting = NO;
115 animator.presentationKey = self.presentationKey;
116 [animator selectDelegate:@[ dismissed.presentingViewController ]];
117 return animator;
118 }
119
120 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/tab/tab_coordinator.h ('k') | ios/chrome/browser/ui/tab_grid/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698