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

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: Unittests, showcase, and clean up. 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 DCHECK_NE(self, viewController.parentViewController);
52 [viewController willMoveToParentViewController:nil];
53 [viewController.view removeFromSuperview];
54 [viewController removeFromParentViewController];
55 }
56
57 #pragma mark - ZoomTransitionDelegate
58
59 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view {
60 if ([self.contentViewController
61 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) {
62 return [static_cast<id<ZoomTransitionDelegate>>(self.contentViewController)
63 rectForZoomWithKey:key
64 inView:view];
65 }
66 return CGRectNull;
67 }
68
69 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698