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 // ====== New Architecture ===== |
| 6 // = This code is only used in the new iOS Chrome architecture. = |
| 7 // ============================================================================ |
| 8 |
| 9 #import "ios/chrome/app/app_delegate.h" |
| 10 |
| 11 #import "ios/chrome/app/application_state.h" |
| 12 #import "ios/chrome/app/steps/launch_to_background.h" |
| 13 #import "ios/chrome/app/steps/launch_to_basic.h" |
| 14 #import "ios/chrome/app/steps/launch_to_foreground.h" |
| 15 #import "ios/chrome/app/steps/tab_grid_coordinator+application_step.h" |
| 16 |
| 17 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 18 #error "This file requires ARC support." |
| 19 #endif |
| 20 |
| 21 @interface AppDelegate () |
| 22 @property(nonatomic, strong) ApplicationState* applicationState; |
| 23 @end |
| 24 |
| 25 @implementation AppDelegate |
| 26 |
| 27 @synthesize applicationState = _applicationState; |
| 28 |
| 29 #pragma mark - UIApplicationDelegate (app state changes and system events) |
| 30 |
| 31 - (BOOL)application:(UIApplication*)application |
| 32 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { |
| 33 self.applicationState = [[ApplicationState alloc] init]; |
| 34 self.applicationState.application = application; |
| 35 [self configureApplicationState]; |
| 36 |
| 37 [self.applicationState launchWithOptions:launchOptions]; |
| 38 return YES; |
| 39 } |
| 40 |
| 41 - (void)applicationDidBecomeActive:(UIApplication*)application { |
| 42 } |
| 43 |
| 44 - (void)applicationWillResignActive:(UIApplication*)application { |
| 45 } |
| 46 |
| 47 - (void)applicationDidEnterBackground:(UIApplication*)application { |
| 48 } |
| 49 |
| 50 - (void)applicationWillEnterForeground:(UIApplication*)application { |
| 51 } |
| 52 |
| 53 - (void)applicationWillTerminate:(UIApplication*)application { |
| 54 } |
| 55 |
| 56 - (void)applicationDidReceiveMemoryWarning:(UIApplication*)application { |
| 57 } |
| 58 |
| 59 #pragma mark - UIApplicationDelegate (background dowloading) |
| 60 |
| 61 - (void)application:(UIApplication*)application |
| 62 performFetchWithCompletionHandler: |
| 63 (void (^)(UIBackgroundFetchResult))completionHandler { |
| 64 } |
| 65 |
| 66 - (void)application:(UIApplication*)application |
| 67 handleEventsForBackgroundURLSession:(NSString*)identifier |
| 68 completionHandler:(void (^)())completionHandler { |
| 69 } |
| 70 |
| 71 #pragma mark - UIApplicationDelegate (user activity and quick actions) |
| 72 |
| 73 - (BOOL)application:(UIApplication*)application |
| 74 willContinueUserActivityWithType:(NSString*)userActivityType { |
| 75 return NO; |
| 76 } |
| 77 |
| 78 - (BOOL)application:(UIApplication*)application |
| 79 continueUserActivity:(NSUserActivity*)userActivity |
| 80 restorationHandler:(void (^)(NSArray*))restorationHandler { |
| 81 return NO; |
| 82 } |
| 83 |
| 84 - (void)application:(UIApplication*)application |
| 85 performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem |
| 86 completionHandler:(void (^)(BOOL))completionHandler { |
| 87 } |
| 88 |
| 89 #pragma mark - UIApplicationDelegate (opening URL-specified resources) |
| 90 |
| 91 - (BOOL)application:(UIApplication*)application |
| 92 openURL:(NSURL*)url |
| 93 options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options { |
| 94 [self.applicationState.URLOpener openURL:url]; |
| 95 return YES; |
| 96 } |
| 97 |
| 98 #pragma mark - Private methods |
| 99 |
| 100 // Configures the application state for application launch by setting the launch |
| 101 // steps. |
| 102 // Future architecture/refactoring note: configuring the application state in |
| 103 // this way is outside the scope of responsibility of the object as defined in |
| 104 // the header file. The correct solution is probably a helper object that can |
| 105 // perform all of the configuration necessary, and that can be adjusted as |
| 106 // needed. |
| 107 - (void)configureApplicationState { |
| 108 [self.applicationState.launchSteps addObjectsFromArray:@[ |
| 109 [[ProviderInitializer alloc] init], |
| 110 [[SetupBundleAndUserDefaults alloc] init], |
| 111 [[StartChromeMain alloc] init], |
| 112 [[SetBrowserState alloc] init], |
| 113 [[BeginForegrounding alloc] init], |
| 114 [[BrowserStateInitializer alloc] init], |
| 115 [[PrepareForUI alloc] init], |
| 116 [[CompleteForegrounding alloc] init], |
| 117 [[TabGridCoordinator alloc] init], |
| 118 ]]; |
| 119 } |
| 120 |
| 121 @end |
OLD | NEW |