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

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

Issue 2708013002: [ios clean] Creates ToolbarWebState Mediator (Closed)
Patch Set: Renaming feedback Created 3 years, 10 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
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/animators/zoom_transition_animator.h" 16 #import "ios/clean/chrome/browser/ui/animators/zoom_transition_animator.h"
17 #import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h" 17 #import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h"
18 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_coordinator.h" 18 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_coordinator.h"
19 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" 19 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h"
20 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" 20 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h"
21 #import "ios/web/public/web_state/web_state_observer_bridge.h"
22 21
23 #if !defined(__has_feature) || !__has_feature(objc_arc) 22 #if !defined(__has_feature) || !__has_feature(objc_arc)
24 #error "This file requires ARC support." 23 #error "This file requires ARC support."
25 #endif 24 #endif
26 25
27 namespace { 26 namespace {
28 // Placeholder "experiment" flag. Change this to YES to have the toolbar at the 27 // Placeholder "experiment" flag. Change this to YES to have the toolbar at the
29 // bottom. 28 // bottom.
30 const BOOL kUseBottomToolbar = NO; 29 const BOOL kUseBottomToolbar = NO;
31 } // namespace 30 } // namespace
32 31
33 @interface TabCoordinator ()<UIViewControllerTransitioningDelegate> 32 @interface TabCoordinator ()<UIViewControllerTransitioningDelegate>
34 @property(nonatomic, strong) TabContainerViewController* viewController; 33 @property(nonatomic, strong) TabContainerViewController* viewController;
35 @end 34 @end
36 35
37 @implementation TabCoordinator { 36 @implementation TabCoordinator
38 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver;
39 }
40
41 @synthesize presentationKey = _presentationKey; 37 @synthesize presentationKey = _presentationKey;
42 @synthesize viewController = _viewController; 38 @synthesize viewController = _viewController;
43 @synthesize webState = _webState; 39 @synthesize webState = _webState;
44 40
45 - (void)start { 41 - (void)start {
46 self.viewController = [self newTabContainer]; 42 self.viewController = [self newTabContainer];
47 self.viewController.transitioningDelegate = self; 43 self.viewController.transitioningDelegate = self;
48 self.viewController.modalPresentationStyle = UIModalPresentationCustom; 44 self.viewController.modalPresentationStyle = UIModalPresentationCustom;
49 45
50 WebCoordinator* webCoordinator = [[WebCoordinator alloc] init]; 46 WebCoordinator* webCoordinator = [[WebCoordinator alloc] init];
51 webCoordinator.webState = self.webState; 47 webCoordinator.webState = self.webState;
52 [self addChildCoordinator:webCoordinator]; 48 [self addChildCoordinator:webCoordinator];
53 // Unset the base view controller, so |webCoordinator| doesn't present its 49 // Unset the base view controller, so |webCoordinator| doesn't present its
54 // view controller. 50 // view controller.
55 webCoordinator.context.baseViewController = nil; 51 webCoordinator.context.baseViewController = nil;
56 [webCoordinator start]; 52 [webCoordinator start];
57 53
58 ToolbarCoordinator* toolbarCoordinator = [[ToolbarCoordinator alloc] init]; 54 ToolbarCoordinator* toolbarCoordinator = [[ToolbarCoordinator alloc] init];
55 toolbarCoordinator.webState = self.webState;
59 [self addChildCoordinator:toolbarCoordinator]; 56 [self addChildCoordinator:toolbarCoordinator];
60 // PLACEHOLDER : Pass the WebState into the toolbar coordinator and let it 57
61 // create a mediator (or whatever) that observes the webState.
62 _webStateObserver = base::MakeUnique<web::WebStateObserverBridge>(
63 self.webState, toolbarCoordinator);
64 // Unset the base view controller, so |toolbarCoordinator| doesn't present 58 // Unset the base view controller, so |toolbarCoordinator| doesn't present
65 // its view controller. 59 // its view controller.
66 toolbarCoordinator.context.baseViewController = nil; 60 toolbarCoordinator.context.baseViewController = nil;
67 [toolbarCoordinator start]; 61 [toolbarCoordinator start];
68 62
69 self.viewController.toolbarViewController = toolbarCoordinator.viewController; 63 self.viewController.toolbarViewController = toolbarCoordinator.viewController;
70 self.viewController.contentViewController = webCoordinator.viewController; 64 self.viewController.contentViewController = webCoordinator.viewController;
71 65
72 [self.context.baseViewController presentViewController:self.viewController 66 [self.context.baseViewController presentViewController:self.viewController
73 animated:self.context.animated 67 animated:self.context.animated
74 completion:nil]; 68 completion:nil];
75 } 69 }
76 70
77 - (void)stop { 71 - (void)stop {
78 [self.viewController.presentingViewController 72 [self.viewController.presentingViewController
79 dismissViewControllerAnimated:self.context.animated 73 dismissViewControllerAnimated:self.context.animated
80 completion:nil]; 74 completion:nil];
81 _webStateObserver.reset();
82 } 75 }
83 76
84 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator { 77 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator {
85 // This coordinator will always accept overlay coordinators. 78 // This coordinator will always accept overlay coordinators.
86 return YES; 79 return YES;
87 } 80 }
88 81
89 #pragma mark - Experiment support 82 #pragma mark - Experiment support
90 83
91 // Create and return a new view controller for use as a tab container; 84 // Create and return a new view controller for use as a tab container;
(...skipping 22 matching lines...) Expand all
114 - (id<UIViewControllerAnimatedTransitioning>) 107 - (id<UIViewControllerAnimatedTransitioning>)
115 animationControllerForDismissedController:(UIViewController*)dismissed { 108 animationControllerForDismissedController:(UIViewController*)dismissed {
116 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; 109 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init];
117 animator.presenting = NO; 110 animator.presenting = NO;
118 animator.presentationKey = self.presentationKey; 111 animator.presentationKey = self.presentationKey;
119 [animator selectDelegate:@[ dismissed.presentingViewController ]]; 112 [animator selectDelegate:@[ dismissed.presentingViewController ]];
120 return animator; 113 return animator;
121 } 114 }
122 115
123 @end 116 @end
OLDNEW
« no previous file with comments | « no previous file | ios/clean/chrome/browser/ui/toolbar/BUILD.gn » ('j') | ios/clean/chrome/browser/ui/toolbar/toolbar_coordinator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698