1 // Copyright 2014 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.
5 #import "ios/web/shell/app_delegate.h"
7 #import "base/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "ios/web/public/app/web_main.h"
10 #include "ios/web/public/web_client.h"
11 #include "ios/web/public/web_state/web_state.h"
12 #include "ios/web/shell/shell_browser_state.h"
13 #include "ios/web/shell/shell_main_delegate.h"
14 #include "ios/web/shell/shell_web_client.h"
15 #import "ios/web/shell/view_controller.h"
17 @interface AppDelegate () {
18 scoped_ptr<web::ShellMainDelegate> _delegate;
19 scoped_ptr<web::WebMain> _webMain;
23 @implementation AppDelegate
25 @synthesize window = _window;
27 - (BOOL)application:(UIApplication*)application
28 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
29 _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
30 self.window.backgroundColor = [UIColor whiteColor];
32 _delegate.reset(new web::ShellMainDelegate());
33 web::WebMainParams params(_delegate.get());
34 _webMain.reset(new web::WebMain(params));
36 web::ShellWebClient* client =
37 static_cast<web::ShellWebClient*>(web::GetWebClient());
38 web::BrowserState* browserState = client->browser_state();
40 base::scoped_nsobject<ViewController> controller(
41 [[ViewController alloc] initWithBrowserState:browserState]);
42 self.window.rootViewController = controller;
43 [self.window makeKeyAndVisible];
47 - (void)applicationWillResignActive:(UIApplication*)application {
50 - (void)applicationDidEnterBackground:(UIApplication*)application {
53 - (void)applicationWillEnterForeground:(UIApplication*)application {
56 - (void)applicationDidBecomeActive:(UIApplication*)application {
59 - (void)applicationWillTerminate:(UIApplication*)application {