| OLD | NEW |
| (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 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 6 #error "This file requires ARC support." | |
| 7 #endif | |
| 8 | |
| 9 #import "remoting/client/ios/app/app_delegate.h" | |
| 10 | |
| 11 #include "base/logging.h" | |
| 12 #include "ui/base/l10n/l10n_util.h" | |
| 13 #include "ui/base/resource/resource_bundle.h" | |
| 14 | |
| 15 #import "remoting/client/ios/app/remoting_view_controller.h" | |
| 16 #import "remoting/client/ios/facade/remoting_authentication.h" | |
| 17 #import "remoting/client/ios/facade/remoting_service.h" | |
| 18 | |
| 19 @implementation AppDelegate | |
| 20 | |
| 21 @synthesize window = _window; | |
| 22 | |
| 23 - (BOOL)application:(UIApplication*)application | |
| 24 willFinishLaunchingWithOptions:(NSDictionary*)launchOptions { | |
| 25 self.window = | |
| 26 [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
| 27 self.window.backgroundColor = [UIColor whiteColor]; | |
| 28 return YES; | |
| 29 } | |
| 30 | |
| 31 - (BOOL)application:(UIApplication*)application | |
| 32 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { | |
| 33 [self launchRemotingViewController]; | |
| 34 return YES; | |
| 35 } | |
| 36 | |
| 37 - (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url { | |
| 38 NSMutableDictionary* components = [[NSMutableDictionary alloc] init]; | |
| 39 NSArray* urlComponents = [[url query] componentsSeparatedByString:@"&"]; | |
| 40 | |
| 41 for (NSString* componentPair in urlComponents) { | |
| 42 NSArray* pair = [componentPair componentsSeparatedByString:@"="]; | |
| 43 NSString* key = [[pair firstObject] stringByRemovingPercentEncoding]; | |
| 44 NSString* value = [[pair lastObject] stringByRemovingPercentEncoding]; | |
| 45 [components setObject:value forKey:key]; | |
| 46 } | |
| 47 NSString* authorizationCode = [components objectForKey:@"code"]; | |
| 48 | |
| 49 [[RemotingService SharedInstance].authentication | |
| 50 authenticateWithAuthorizationCode:authorizationCode]; | |
| 51 | |
| 52 [self launchRemotingViewController]; | |
| 53 return YES; | |
| 54 } | |
| 55 | |
| 56 - (void)launchRemotingViewController { | |
| 57 RemotingViewController* vc = [[RemotingViewController alloc] init]; | |
| 58 self.window.rootViewController = vc; | |
| 59 [self.window makeKeyAndVisible]; | |
| 60 } | |
| 61 | |
| 62 @end | |
| OLD | NEW |