OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
7 #endif | 7 #endif |
8 | 8 |
9 #import "remoting/ios/app/app_view_controller.h" | 9 #import "remoting/ios/app/app_view_controller.h" |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 | 12 |
13 #import "remoting/ios/app/remoting_menu_view_controller.h" | 13 #import "remoting/ios/app/remoting_menu_view_controller.h" |
| 14 #import "remoting/ios/facade/remoting_oauth_authentication.h" |
14 | 15 |
15 // The Chromium implementation for the AppViewController. It simply shows the | 16 // The Chromium implementation for the AppViewController. It simply shows the |
16 // menu modally. | 17 // menu modally. |
17 @interface AppViewController () { | 18 @interface AppViewController () { |
18 UIViewController* _mainViewController; | |
19 | 19 |
20 RemotingMenuViewController* _menuController; // nullable | 20 RemotingMenuViewController* _menuController; // nullable |
21 } | 21 } |
22 @end | 22 @end |
23 | 23 |
24 @implementation AppViewController | 24 @implementation AppViewController |
25 | 25 |
26 - (instancetype)initWithMainViewController: | 26 @synthesize authentication = _authentication; |
27 (UIViewController*)mainViewController { | 27 @synthesize mainViewController = _mainViewController; |
| 28 |
| 29 - (instancetype)init { |
28 if (self = [super init]) { | 30 if (self = [super init]) { |
29 _mainViewController = mainViewController; | 31 _authentication = [[RemotingOAuthAuthentication alloc] init]; |
30 } | 32 } |
31 return self; | 33 return self; |
32 } | 34 } |
33 | 35 |
34 - (void)viewDidLoad { | |
35 [self addChildViewController:_mainViewController]; | |
36 [self.view addSubview:_mainViewController.view]; | |
37 [_mainViewController didMoveToParentViewController:self]; | |
38 } | |
39 | |
40 #pragma mark - AppController | 36 #pragma mark - AppController |
41 - (void)showMenuAnimated:(BOOL)animated { | 37 - (void)showMenuAnimated:(BOOL)animated { |
42 if (_menuController != nil && [_menuController isBeingPresented]) { | 38 if (_menuController != nil && [_menuController isBeingPresented]) { |
43 return; | 39 return; |
44 } | 40 } |
45 _menuController = [[RemotingMenuViewController alloc] init]; | 41 _menuController = [[RemotingMenuViewController alloc] init]; |
46 [self presentViewController:_menuController animated:animated completion:nil]; | 42 [self presentViewController:_menuController animated:animated completion:nil]; |
47 } | 43 } |
48 | 44 |
49 - (void)hideMenuAnimated:(BOOL)animated { | 45 - (void)hideMenuAnimated:(BOOL)animated { |
50 if (_menuController == nil || ![_menuController isBeingPresented]) { | 46 if (_menuController == nil || ![_menuController isBeingPresented]) { |
51 return; | 47 return; |
52 } | 48 } |
53 [_menuController dismissViewControllerAnimated:animated completion:nil]; | 49 [_menuController dismissViewControllerAnimated:animated completion:nil]; |
54 _menuController = nil; | 50 _menuController = nil; |
55 } | 51 } |
56 | 52 |
57 - (void)presentSignInFlow { | 53 - (void)presentSignInFlow { |
58 [self showMenuAnimated:YES]; | 54 [self showMenuAnimated:YES]; |
59 } | 55 } |
60 | 56 |
61 - (UIViewController*)childViewControllerForStatusBarStyle { | 57 - (UIViewController*)childViewControllerForStatusBarStyle { |
62 return _mainViewController; | 58 return _mainViewController; |
63 } | 59 } |
64 | 60 |
65 - (UIViewController*)childViewControllerForStatusBarHidden { | 61 - (UIViewController*)childViewControllerForStatusBarHidden { |
66 return _mainViewController; | 62 return _mainViewController; |
67 } | 63 } |
68 | 64 |
| 65 #pragma mark - Properties |
| 66 |
| 67 - (void)setMainViewController:(UIViewController*)mainViewController { |
| 68 DCHECK(self.view != nil); |
| 69 _mainViewController = mainViewController; |
| 70 [self addChildViewController:_mainViewController]; |
| 71 [self.view addSubview:_mainViewController.view]; |
| 72 [_mainViewController didMoveToParentViewController:self]; |
| 73 } |
| 74 |
69 @end | 75 @end |
OLD | NEW |