OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_delegate.h" | 9 #import "remoting/ios/app/app_delegate.h" |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
14 | 14 |
| 15 #import "remoting/ios/app/app_view_controller.h" |
15 #import "remoting/ios/app/remoting_view_controller.h" | 16 #import "remoting/ios/app/remoting_view_controller.h" |
16 #import "remoting/ios/facade/remoting_authentication.h" | 17 #import "remoting/ios/facade/remoting_authentication.h" |
17 #import "remoting/ios/facade/remoting_service.h" | 18 #import "remoting/ios/facade/remoting_service.h" |
18 | 19 |
| 20 @interface AppDelegate () { |
| 21 AppViewController* _appViewController; |
| 22 } |
| 23 @end |
| 24 |
19 @implementation AppDelegate | 25 @implementation AppDelegate |
20 | 26 |
21 @synthesize window = _window; | 27 @synthesize window = _window; |
22 | 28 |
23 - (BOOL)application:(UIApplication*)application | 29 - (BOOL)application:(UIApplication*)application |
24 willFinishLaunchingWithOptions:(NSDictionary*)launchOptions { | 30 willFinishLaunchingWithOptions:(NSDictionary*)launchOptions { |
25 self.window = | 31 self.window = |
26 [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | 32 [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; |
27 self.window.backgroundColor = [UIColor whiteColor]; | 33 self.window.backgroundColor = [UIColor whiteColor]; |
28 return YES; | 34 return YES; |
(...skipping 17 matching lines...) Expand all Loading... |
46 } | 52 } |
47 NSString* authorizationCode = [components objectForKey:@"code"]; | 53 NSString* authorizationCode = [components objectForKey:@"code"]; |
48 | 54 |
49 [[RemotingService SharedInstance].authentication | 55 [[RemotingService SharedInstance].authentication |
50 authenticateWithAuthorizationCode:authorizationCode]; | 56 authenticateWithAuthorizationCode:authorizationCode]; |
51 | 57 |
52 [self launchRemotingViewController]; | 58 [self launchRemotingViewController]; |
53 return YES; | 59 return YES; |
54 } | 60 } |
55 | 61 |
| 62 #pragma mark - Public |
| 63 - (void)setMenuVisible:(BOOL)visible animated:(BOOL)animated { |
| 64 DCHECK(_appViewController != nil); |
| 65 [_appViewController setMenuVisible:visible animated:animated]; |
| 66 } |
| 67 |
| 68 - (void)requestSignIn { |
| 69 DCHECK(_appViewController != nil); |
| 70 [_appViewController requestSignIn]; |
| 71 } |
| 72 |
| 73 #pragma mark - Properties |
| 74 |
| 75 + (AppDelegate*)instance { |
| 76 return (AppDelegate*)UIApplication.sharedApplication.delegate; |
| 77 } |
| 78 |
| 79 #pragma mark - Private |
| 80 |
56 - (void)launchRemotingViewController { | 81 - (void)launchRemotingViewController { |
57 RemotingViewController* vc = [[RemotingViewController alloc] init]; | 82 RemotingViewController* vc = [[RemotingViewController alloc] init]; |
58 UINavigationController* navController = | 83 UINavigationController* navController = |
59 [[UINavigationController alloc] initWithRootViewController:vc]; | 84 [[UINavigationController alloc] initWithRootViewController:vc]; |
60 navController.navigationBarHidden = true; | 85 navController.navigationBarHidden = true; |
61 self.window.rootViewController = navController; | 86 |
| 87 _appViewController = [[AppViewController alloc] init]; |
| 88 _appViewController.mainViewController = navController; |
| 89 self.window.rootViewController = _appViewController; |
62 [self.window makeKeyAndVisible]; | 90 [self.window makeKeyAndVisible]; |
63 } | 91 } |
64 | 92 |
65 @end | 93 @end |
OLD | NEW |