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

Side by Side Diff: ios/clean/chrome/browser/ui/root/root_container_view_controller.mm

Issue 2800313002: [ios] RootCoordinator and view controller. (Closed)
Patch Set: More unittests and cleanup. Created 3 years, 8 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
(Empty)
1 // Copyright 2017 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 #import "ios/clean/chrome/browser/ui/root/root_container_view_controller.h"
6
7 #include "base/logging.h"
8
9 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support."
11 #endif
12
13 @implementation RootContainerViewController
14 @synthesize contentViewController = _contentViewController;
15
16 #pragma mark - UIViewController
17
18 - (void)viewDidLoad {
19 [super viewDidLoad];
20 self.view.backgroundColor = [UIColor blackColor];
21 [self attachChildViewController:self.contentViewController];
22 }
23
24 #pragma mark - Public properties
25
26 - (void)setContentViewController:(UIViewController*)contentViewController {
27 if (self.contentViewController == contentViewController)
28 return;
29 if ([self isViewLoaded]) {
30 [self detachChildViewController:self.contentViewController];
31 [self attachChildViewController:contentViewController];
32 }
33 _contentViewController = contentViewController;
34 }
35
36 #pragma mark - ChildViewController helper methods
37
38 - (void)attachChildViewController:(UIViewController*)viewController {
39 if (!viewController) {
40 return;
41 }
42 [self addChildViewController:viewController];
43 viewController.view.autoresizingMask =
44 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
45 viewController.view.frame = self.view.bounds;
46 [self.view addSubview:viewController.view];
47 [viewController didMoveToParentViewController:self];
48 }
49
50 - (void)detachChildViewController:(UIViewController*)viewController {
51 if (!viewController) {
52 return;
53 }
54 DCHECK_EQ(self, viewController.parentViewController);
55 [viewController willMoveToParentViewController:nil];
56 [viewController.view removeFromSuperview];
57 [viewController removeFromParentViewController];
58 }
59
60 #pragma mark - ZoomTransitionDelegate
61
62 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view {
63 if ([self.contentViewController
64 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) {
65 return [static_cast<id<ZoomTransitionDelegate>>(self.contentViewController)
66 rectForZoomWithKey:key
67 inView:view];
68 }
69 return CGRectNull;
70 }
71
72 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698