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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/main/main_view_controller.mm
diff --git a/ios/chrome/browser/ui/main/main_view_controller.mm b/ios/chrome/browser/ui/main/main_view_controller.mm
new file mode 100644
index 0000000000000000000000000000000000000000..641b24568c1695c2bad673a3e44448e068750c3a
--- /dev/null
+++ b/ios/chrome/browser/ui/main/main_view_controller.mm
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/main/main_view_controller.h"
+
+#import "base/logging.h"
+
+@implementation MainViewController
+
+- (UIViewController*)activeViewController {
+ return [self.childViewControllers firstObject];
+}
+
+- (void)setActiveViewController:(UIViewController*)activeViewController {
+ DCHECK(activeViewController);
+ if (self.activeViewController == activeViewController)
+ return;
+
+ // TODO(crbug.com/546189): DCHECK here that there isn't a modal view
+ // controller showing once the known violations of that are fixed.
+
+ // Remove the current active view controller, if any.
+ if (self.activeViewController) {
+ [self.activeViewController willMoveToParentViewController:nil];
+ [self.activeViewController.view removeFromSuperview];
+ [self.activeViewController removeFromParentViewController];
+ }
+
+ DCHECK(self.activeViewController == nil);
+ DCHECK(self.view.subviews.count == 0);
+
+ // Add the new active view controller.
+ [self addChildViewController:activeViewController];
+ self.activeViewController.view.frame = self.view.bounds;
+ [self.view addSubview:self.activeViewController.view];
+ [activeViewController didMoveToParentViewController:self];
+
+ // Let the system know that the child has changed so appearance updates can
+ // be made.
+ [self setNeedsStatusBarAppearanceUpdate];
+
+ DCHECK(self.activeViewController == activeViewController);
+}
+
+#pragma mark - UIViewController methods
+
+- (void)presentViewController:(UIViewController*)viewControllerToPresent
+ animated:(BOOL)flag
+ completion:(void (^)())completion {
+ [self.activeViewController presentViewController:viewControllerToPresent
+ animated:flag
+ completion:completion];
+}
+
+- (void)dismissViewControllerAnimated:(BOOL)flag
+ completion:(void (^)())completion {
+ [self.activeViewController dismissViewControllerAnimated:flag
+ completion:completion];
+}
+
+- (UIViewController*)childViewControllerForStatusBarHidden {
+ return self.activeViewController;
+}
+
+- (UIViewController*)childViewControllerForStatusBarStyle {
+ return self.activeViewController;
+}
+
+- (BOOL)shouldAutorotate {
+ return self.activeViewController
+ ? [self.activeViewController shouldAutorotate]
+ : [super shouldAutorotate];
+}
+
+@end
« 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