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

Side by Side Diff: ios/chrome/browser/ui/main/main_view_controller.mm

Issue 2590473002: Upstream Chrome on iOS source code [5/11]. (Closed)
Patch Set: Created 4 years 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 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 #import "ios/chrome/browser/ui/main/main_view_controller.h"
6
7 #import "base/logging.h"
8
9 @implementation MainViewController
10
11 - (UIViewController*)activeViewController {
12 return [self.childViewControllers firstObject];
13 }
14
15 - (void)setActiveViewController:(UIViewController*)activeViewController {
16 DCHECK(activeViewController);
17 if (self.activeViewController == activeViewController)
18 return;
19
20 // TODO(crbug.com/546189): DCHECK here that there isn't a modal view
21 // controller showing once the known violations of that are fixed.
22
23 // Remove the current active view controller, if any.
24 if (self.activeViewController) {
25 [self.activeViewController willMoveToParentViewController:nil];
26 [self.activeViewController.view removeFromSuperview];
27 [self.activeViewController removeFromParentViewController];
28 }
29
30 DCHECK(self.activeViewController == nil);
31 DCHECK(self.view.subviews.count == 0);
32
33 // Add the new active view controller.
34 [self addChildViewController:activeViewController];
35 self.activeViewController.view.frame = self.view.bounds;
36 [self.view addSubview:self.activeViewController.view];
37 [activeViewController didMoveToParentViewController:self];
38
39 // Let the system know that the child has changed so appearance updates can
40 // be made.
41 [self setNeedsStatusBarAppearanceUpdate];
42
43 DCHECK(self.activeViewController == activeViewController);
44 }
45
46 #pragma mark - UIViewController methods
47
48 - (void)presentViewController:(UIViewController*)viewControllerToPresent
49 animated:(BOOL)flag
50 completion:(void (^)())completion {
51 [self.activeViewController presentViewController:viewControllerToPresent
52 animated:flag
53 completion:completion];
54 }
55
56 - (void)dismissViewControllerAnimated:(BOOL)flag
57 completion:(void (^)())completion {
58 [self.activeViewController dismissViewControllerAnimated:flag
59 completion:completion];
60 }
61
62 - (UIViewController*)childViewControllerForStatusBarHidden {
63 return self.activeViewController;
64 }
65
66 - (UIViewController*)childViewControllerForStatusBarStyle {
67 return self.activeViewController;
68 }
69
70 - (BOOL)shouldAutorotate {
71 return self.activeViewController
72 ? [self.activeViewController shouldAutorotate]
73 : [super shouldAutorotate];
74 }
75
76 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/main/main_view_controller.h ('k') | ios/chrome/browser/ui/main/main_view_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698