OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 "sky_app_delegate.h" |
| 6 #import "sky_view_controller.h" |
| 7 |
| 8 #include "sky/shell/shell.h" |
| 9 #include "sky/shell/service_provider.h" |
| 10 #include "sky/shell/ui_delegate.h" |
| 11 #include "base/lazy_instance.h" |
| 12 #include "base/message_loop/message_loop.h" |
| 13 |
| 14 @implementation SkyAppDelegate { |
| 15 base::LazyInstance<scoped_ptr<base::MessageLoop>> _main_message_loop; |
| 16 } |
| 17 |
| 18 - (BOOL)application:(UIApplication*)application |
| 19 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { |
| 20 [self setupSkyShell]; |
| 21 [self setupViewport]; |
| 22 |
| 23 return YES; |
| 24 } |
| 25 |
| 26 - (void)setupSkyShell { |
| 27 [self adoptPlatformRunLoop]; |
| 28 |
| 29 auto service_provider_context = |
| 30 make_scoped_ptr(new sky::shell::ServiceProviderContext( |
| 31 _main_message_loop.Get()->task_runner())); |
| 32 sky::shell::Shell::Init(service_provider_context.Pass()); |
| 33 } |
| 34 |
| 35 - (void)adoptPlatformRunLoop { |
| 36 _main_message_loop.Get().reset(new base::MessageLoopForUI); |
| 37 // One cannot start the message loop on the platform main thread. Instead, |
| 38 // we attach to the CFRunLoop |
| 39 base::MessageLoopForUI::current()->Attach(); |
| 40 } |
| 41 |
| 42 - (void)setupViewport { |
| 43 CGRect frame = [UIScreen mainScreen].bounds; |
| 44 UIWindow* window = [[UIWindow alloc] initWithFrame:frame]; |
| 45 SkyViewController* viewController = [[SkyViewController alloc] init]; |
| 46 window.rootViewController = viewController; |
| 47 [viewController release]; |
| 48 self.window = window; |
| 49 [window release]; |
| 50 [self.window makeKeyAndVisible]; |
| 51 } |
| 52 |
| 53 @end |
OLD | NEW |