Chromium Code Reviews| 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 #import "ios/showcase/core/app_delegate.h" | 5 #import "ios/showcase/core/app_delegate.h" |
| 6 | 6 |
| 7 #import "ios/clean/chrome/app/application_state.h" | |
| 8 #import "ios/clean/chrome/app/steps/launch_to_background.h" | |
| 9 #import "ios/clean/chrome/app/steps/launch_to_basic.h" | |
| 10 #import "ios/clean/chrome/app/steps/launch_to_foreground.h" | |
| 7 #import "ios/showcase/core/showcase_model.h" | 11 #import "ios/showcase/core/showcase_model.h" |
| 8 #import "ios/showcase/core/showcase_view_controller.h" | 12 #import "ios/showcase/core/showcase_view_controller.h" |
| 9 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" | 13 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" |
| 10 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MDCTypographyAd ditions/MDFRobotoFontLoader+MDCTypographyAdditions.h" | 14 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MDCTypographyAd ditions/MDFRobotoFontLoader+MDCTypographyAdditions.h" |
| 11 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" | 15 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" |
| 12 | 16 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) | 17 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." | 18 #error "This file requires ARC support." |
| 15 #endif | 19 #endif |
| 16 | 20 |
| 21 @interface AppDelegate () | |
| 22 @property(nonatomic, strong) ApplicationState* applicationState; | |
| 23 @end | |
| 24 | |
| 17 @implementation AppDelegate | 25 @implementation AppDelegate |
| 18 @synthesize window = _window; | 26 @synthesize window = _window; |
| 27 @synthesize applicationState = _applicationState; | |
| 19 | 28 |
| 20 - (BOOL)application:(UIApplication*)application | 29 - (BOOL)application:(UIApplication*)application |
| 21 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { | 30 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { |
| 22 [MDCTypography setFontLoader:[MDFRobotoFontLoader sharedInstance]]; | 31 [MDCTypography setFontLoader:[MDFRobotoFontLoader sharedInstance]]; |
| 23 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | 32 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; |
| 24 ShowcaseViewController* viewController = | 33 ShowcaseViewController* viewController = |
| 25 [[ShowcaseViewController alloc] initWithRows:[self rowsToDisplay]]; | 34 [[ShowcaseViewController alloc] initWithRows:[self rowsToDisplay]]; |
| 26 UINavigationController* navigationController = [[UINavigationController alloc] | 35 UINavigationController* navigationController = [[UINavigationController alloc] |
| 27 initWithRootViewController:viewController]; | 36 initWithRootViewController:viewController]; |
| 28 self.window.rootViewController = navigationController; | 37 self.window.rootViewController = navigationController; |
| 29 [self.window makeKeyAndVisible]; | 38 [self.window makeKeyAndVisible]; |
| 39 | |
| 40 self.applicationState = [[ApplicationState alloc] init]; | |
|
marq (ping after 24h)
2017/01/24 09:49:07
Sorry for any confusion caused by my comment in ch
| |
| 41 self.applicationState.application = application; | |
| 42 [self configureApplicationState]; | |
| 43 | |
| 44 [self.applicationState launchWithOptions:launchOptions]; | |
| 45 | |
| 30 return YES; | 46 return YES; |
| 31 } | 47 } |
| 32 | 48 |
| 33 #pragma mark - Private | 49 #pragma mark - Private |
| 34 | 50 |
| 35 // Creates model data to display in the view controller. | 51 // Creates model data to display in the view controller. |
| 36 - (NSArray<showcase::ModelRow*>*)rowsToDisplay { | 52 - (NSArray<showcase::ModelRow*>*)rowsToDisplay { |
| 37 NSArray<showcase::ModelRow*>* rows = [ShowcaseModel model]; | 53 NSArray<showcase::ModelRow*>* rows = [ShowcaseModel model]; |
| 38 NSSortDescriptor* sortDescriptor = | 54 NSSortDescriptor* sortDescriptor = |
| 39 [NSSortDescriptor sortDescriptorWithKey:showcase::kClassForDisplayKey | 55 [NSSortDescriptor sortDescriptorWithKey:showcase::kClassForDisplayKey |
| 40 ascending:YES]; | 56 ascending:YES]; |
| 41 return [rows sortedArrayUsingDescriptors:@[ sortDescriptor ]]; | 57 return [rows sortedArrayUsingDescriptors:@[ sortDescriptor ]]; |
| 42 } | 58 } |
| 43 | 59 |
| 60 // Configures the application state for application launch by setting the launch | |
| 61 // steps. | |
| 62 // Future architecture/refactoring note: configuring the application state in | |
| 63 // this way is outside the scope of responsibility of the object as defined in | |
| 64 // the header file. The correct solution is probably a helper object that can | |
| 65 // perform all of the configuration necessary, and that can be adjusted as | |
| 66 // needed. | |
| 67 - (void)configureApplicationState { | |
| 68 [self.applicationState.launchSteps addObjectsFromArray:@[ | |
| 69 [[ProviderInitializer alloc] init], | |
| 70 [[SetupBundleAndUserDefaults alloc] init], | |
| 71 [[StartChromeMain alloc] init], | |
| 72 [[SetBrowserState alloc] init], | |
| 73 [[BeginForegrounding alloc] init], | |
| 74 [[PrepareForUI alloc] init], | |
| 75 [[CompleteForegrounding alloc] init], | |
| 76 ]]; | |
| 77 } | |
| 78 | |
| 44 @end | 79 @end |
| OLD | NEW |