OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/chrome/app/main_controller.h" | 5 #import "ios/chrome/app/main_controller.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #import <CoreSpotlight/CoreSpotlight.h> | 10 #import <CoreSpotlight/CoreSpotlight.h> |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 #import "ios/chrome/browser/ui/promos/signin_promo_view_controller.h" | 118 #import "ios/chrome/browser/ui/promos/signin_promo_view_controller.h" |
119 #import "ios/chrome/browser/ui/settings/settings_navigation_controller.h" | 119 #import "ios/chrome/browser/ui/settings/settings_navigation_controller.h" |
120 #import "ios/chrome/browser/ui/stack_view/stack_view_controller.h" | 120 #import "ios/chrome/browser/ui/stack_view/stack_view_controller.h" |
121 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.h" | 121 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.h" |
122 #import "ios/chrome/browser/ui/tabs/tab_strip_controller+tab_switcher_animation.
h" | 122 #import "ios/chrome/browser/ui/tabs/tab_strip_controller+tab_switcher_animation.
h" |
123 #include "ios/chrome/browser/ui/ui_util.h" | 123 #include "ios/chrome/browser/ui/ui_util.h" |
124 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 124 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
125 #import "ios/chrome/browser/ui/util/top_view_controller.h" | 125 #import "ios/chrome/browser/ui/util/top_view_controller.h" |
126 #import "ios/chrome/browser/ui/webui/chrome_web_ui_ios_controller_factory.h" | 126 #import "ios/chrome/browser/ui/webui/chrome_web_ui_ios_controller_factory.h" |
127 #include "ios/chrome/browser/xcallback_parameters.h" | 127 #include "ios/chrome/browser/xcallback_parameters.h" |
128 #include "ios/chrome/grit/ios_strings.h" | |
129 #include "ios/net/cookies/cookie_store_ios.h" | 128 #include "ios/net/cookies/cookie_store_ios.h" |
130 #import "ios/net/crn_http_protocol_handler.h" | 129 #import "ios/net/crn_http_protocol_handler.h" |
131 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 130 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
132 #include "ios/public/provider/chrome/browser/distribution/app_distribution_provi
der.h" | 131 #include "ios/public/provider/chrome/browser/distribution/app_distribution_provi
der.h" |
133 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_white
list_manager.h" | 132 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_white
list_manager.h" |
134 #include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h" | 133 #include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h" |
135 #import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider
.h" | 134 #import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider
.h" |
136 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 135 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
137 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 136 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
138 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MDCTypographyAd
ditions/MDFRobotoFontLoader+MDCTypographyAdditions.h" | 137 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MDCTypographyAd
ditions/MDFRobotoFontLoader+MDCTypographyAdditions.h" |
139 #include "ios/web/net/request_tracker_factory_impl.h" | 138 #include "ios/web/net/request_tracker_factory_impl.h" |
140 #include "ios/web/net/request_tracker_impl.h" | 139 #include "ios/web/net/request_tracker_impl.h" |
141 #include "ios/web/net/web_http_protocol_handler_delegate.h" | 140 #include "ios/web/net/web_http_protocol_handler_delegate.h" |
142 #import "ios/web/public/navigation_manager.h" | 141 #import "ios/web/public/navigation_manager.h" |
143 #include "ios/web/public/web_capabilities.h" | 142 #include "ios/web/public/web_capabilities.h" |
144 #include "ios/web/public/web_state/web_state.h" | 143 #include "ios/web/public/web_state/web_state.h" |
145 #import "ios/web/public/web_view_creation_util.h" | 144 #import "ios/web/public/web_view_creation_util.h" |
146 #include "ios/web/public/webui/web_ui_ios_controller_factory.h" | 145 #include "ios/web/public/webui/web_ui_ios_controller_factory.h" |
147 #include "mojo/edk/embedder/embedder.h" | 146 #include "mojo/edk/embedder/embedder.h" |
148 #import "net/base/mac/url_conversions.h" | 147 #import "net/base/mac/url_conversions.h" |
149 #include "net/url_request/url_request_context.h" | 148 #include "net/url_request/url_request_context.h" |
150 #include "ui/base/l10n/l10n_util.h" | |
151 | 149 |
152 namespace { | 150 namespace { |
153 | 151 |
154 // Preference key used to store which profile is current. | 152 // Preference key used to store which profile is current. |
155 NSString* kIncognitoCurrentKey = @"IncognitoActive"; | 153 NSString* kIncognitoCurrentKey = @"IncognitoActive"; |
156 | 154 |
157 // Constants for deferred initialization of preferences observer. | 155 // Constants for deferred initialization of preferences observer. |
158 NSString* const kPrefObserverInit = @"PrefObserverInit"; | 156 NSString* const kPrefObserverInit = @"PrefObserverInit"; |
159 | 157 |
160 // Constants for deferring notifying the AuthenticationService of a new cold | 158 // Constants for deferring notifying the AuthenticationService of a new cold |
(...skipping 27 matching lines...) Expand all Loading... |
188 // Constants for deferring the deletion of pre-upgrade crash reports. | 186 // Constants for deferring the deletion of pre-upgrade crash reports. |
189 NSString* const kCleanupCrashReports = @"CleanupCrashReports"; | 187 NSString* const kCleanupCrashReports = @"CleanupCrashReports"; |
190 | 188 |
191 // Constants for deferring the deletion of old snapshots. | 189 // Constants for deferring the deletion of old snapshots. |
192 NSString* const kPurgeSnapshots = @"PurgeSnapshots"; | 190 NSString* const kPurgeSnapshots = @"PurgeSnapshots"; |
193 | 191 |
194 // Constants for deferring startup Spotlight bookmark indexing. | 192 // Constants for deferring startup Spotlight bookmark indexing. |
195 NSString* const kStartSpotlightBookmarksIndexing = | 193 NSString* const kStartSpotlightBookmarksIndexing = |
196 @"StartSpotlightBookmarksIndexing"; | 194 @"StartSpotlightBookmarksIndexing"; |
197 | 195 |
198 // Constants for deferred initialization of dynamic application shortcut items. | |
199 NSString* const kAddApplicationShortcutItems = @"AddApplicationShortcutItems"; | |
200 | |
201 // Constants for deferred promo display. | 196 // Constants for deferred promo display. |
202 const NSTimeInterval kDisplayPromoDelay = 0.1; | 197 const NSTimeInterval kDisplayPromoDelay = 0.1; |
203 | 198 |
204 // A rough estimate of the expected duration of a view controller transition | 199 // A rough estimate of the expected duration of a view controller transition |
205 // animation. It's used to temporarily disable mutally exclusive chrome | 200 // animation. It's used to temporarily disable mutally exclusive chrome |
206 // commands that trigger a view controller presentation. | 201 // commands that trigger a view controller presentation. |
207 const int64_t kExpectedTransitionDurationInNanoSeconds = 0.2 * NSEC_PER_SEC; | 202 const int64_t kExpectedTransitionDurationInNanoSeconds = 0.2 * NSEC_PER_SEC; |
208 | 203 |
209 // Adapted from chrome/browser/ui/browser_init.cc. | 204 // Adapted from chrome/browser/ui/browser_init.cc. |
210 void RegisterComponentsForUpdate() { | 205 void RegisterComponentsForUpdate() { |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 - (SettingsNavigationController*)settingsNavigationController { | 934 - (SettingsNavigationController*)settingsNavigationController { |
940 return _settingsNavigationController; | 935 return _settingsNavigationController; |
941 } | 936 } |
942 | 937 |
943 - (void)setSettingsNavigationController: | 938 - (void)setSettingsNavigationController: |
944 (SettingsNavigationController*)settingsNavigationController { | 939 (SettingsNavigationController*)settingsNavigationController { |
945 _settingsNavigationController.reset([settingsNavigationController retain]); | 940 _settingsNavigationController.reset([settingsNavigationController retain]); |
946 } | 941 } |
947 | 942 |
948 - (BOOL)startQRScannerAfterTabSwitcherDismissal { | 943 - (BOOL)startQRScannerAfterTabSwitcherDismissal { |
949 return (experimental_flags::IsQRCodeReaderEnabled() && | 944 return _startQRScannerAfterTabSwitcherDismissal; |
950 _startQRScannerAfterTabSwitcherDismissal); | |
951 } | 945 } |
952 | 946 |
953 - (void)setStartQRScannerAfterTabSwitcherDismissal:(BOOL)startQRScanner { | 947 - (void)setStartQRScannerAfterTabSwitcherDismissal:(BOOL)startQRScanner { |
954 _startQRScannerAfterTabSwitcherDismissal = startQRScanner; | 948 _startQRScannerAfterTabSwitcherDismissal = startQRScanner; |
955 } | 949 } |
956 | 950 |
957 #pragma mark - StartupInformation implementation. | 951 #pragma mark - StartupInformation implementation. |
958 | 952 |
959 - (FirstUserActionRecorder*)firstUserActionRecorder { | 953 - (FirstUserActionRecorder*)firstUserActionRecorder { |
960 return _firstUserActionRecorder.get(); | 954 return _firstUserActionRecorder.get(); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 // Deferred tasks. | 1199 // Deferred tasks. |
1206 [self schedulePrefObserverInitialization]; | 1200 [self schedulePrefObserverInitialization]; |
1207 [self scheduleMemoryDebuggingTools]; | 1201 [self scheduleMemoryDebuggingTools]; |
1208 [_startupTasks scheduleDeferredBrowserStateInitialization:_mainBrowserState]; | 1202 [_startupTasks scheduleDeferredBrowserStateInitialization:_mainBrowserState]; |
1209 [self scheduleAuthenticationServiceNotification]; | 1203 [self scheduleAuthenticationServiceNotification]; |
1210 [self sendQueuedFeedback]; | 1204 [self sendQueuedFeedback]; |
1211 [self scheduleSpotlightResync]; | 1205 [self scheduleSpotlightResync]; |
1212 [self scheduleDeleteDownloadsDirectory]; | 1206 [self scheduleDeleteDownloadsDirectory]; |
1213 [self scheduleStartupAttemptReset]; | 1207 [self scheduleStartupAttemptReset]; |
1214 [self scheduleFreeMemoryMonitoring]; | 1208 [self scheduleFreeMemoryMonitoring]; |
1215 [self scheduleAddApplicationShortcutItems]; | |
1216 [self scheduleAppDistributionPings]; | 1209 [self scheduleAppDistributionPings]; |
1217 [self scheduleCheckNativeApps]; | 1210 [self scheduleCheckNativeApps]; |
1218 } | 1211 } |
1219 | 1212 |
1220 - (void)scheduleTasksRequiringBVCWithBrowserState { | 1213 - (void)scheduleTasksRequiringBVCWithBrowserState { |
1221 if (GetApplicationContext()->WasLastShutdownClean()) | 1214 if (GetApplicationContext()->WasLastShutdownClean()) |
1222 [self.mainBVC removeExternalFilesImmediately:NO completionHandler:nil]; | 1215 [self.mainBVC removeExternalFilesImmediately:NO completionHandler:nil]; |
1223 | 1216 |
1224 [self scheduleShowPromo]; | 1217 [self scheduleShowPromo]; |
1225 } | 1218 } |
(...skipping 11 matching lines...) Expand all Loading... |
1237 return; | 1230 return; |
1238 } | 1231 } |
1239 ProceduralBlock block = ^{ | 1232 ProceduralBlock block = ^{ |
1240 [_spotlightManager resyncIndex]; | 1233 [_spotlightManager resyncIndex]; |
1241 }; | 1234 }; |
1242 [[DeferredInitializationRunner sharedInstance] | 1235 [[DeferredInitializationRunner sharedInstance] |
1243 enqueueBlockNamed:kStartSpotlightBookmarksIndexing | 1236 enqueueBlockNamed:kStartSpotlightBookmarksIndexing |
1244 block:block]; | 1237 block:block]; |
1245 } | 1238 } |
1246 | 1239 |
1247 - (void)scheduleAddApplicationShortcutItems { | |
1248 ProceduralBlock block = ^{ | |
1249 if (experimental_flags::IsQRCodeReaderEnabled()) { | |
1250 UIApplicationShortcutItem* qrScannerShortcutItem = [[ | |
1251 [UIApplicationShortcutItem alloc] | |
1252 initWithType:@"OpenQRScanner" | |
1253 localizedTitle:l10n_util::GetNSString( | |
1254 IDS_IOS_APPLICATION_SHORTCUT_QR_SCANNER_TITLE) | |
1255 localizedSubtitle:nil | |
1256 icon:[UIApplicationShortcutIcon | |
1257 iconWithTemplateImageName: | |
1258 @"quick_action_qr_scanner"] | |
1259 userInfo:nil] autorelease]; | |
1260 // Note: The following only affects dynamic shortcut items defined | |
1261 // programmatically, and not static shortcut items set in the Info.plist | |
1262 // file. | |
1263 [[UIApplication sharedApplication] | |
1264 setShortcutItems:@[ qrScannerShortcutItem ]]; | |
1265 } else { | |
1266 [[UIApplication sharedApplication] setShortcutItems:nil]; | |
1267 } | |
1268 }; | |
1269 | |
1270 [[DeferredInitializationRunner sharedInstance] | |
1271 enqueueBlockNamed:kAddApplicationShortcutItems | |
1272 block:block]; | |
1273 } | |
1274 | |
1275 - (void)expireFirstUserActionRecorder { | 1240 - (void)expireFirstUserActionRecorder { |
1276 // Clear out any scheduled calls to this method. For example, the app may have | 1241 // Clear out any scheduled calls to this method. For example, the app may have |
1277 // been backgrounded before the |kFirstUserActionTimeout| expired. | 1242 // been backgrounded before the |kFirstUserActionTimeout| expired. |
1278 [NSObject | 1243 [NSObject |
1279 cancelPreviousPerformRequestsWithTarget:self | 1244 cancelPreviousPerformRequestsWithTarget:self |
1280 selector:@selector( | 1245 selector:@selector( |
1281 expireFirstUserActionRecorder) | 1246 expireFirstUserActionRecorder) |
1282 object:nil]; | 1247 object:nil]; |
1283 | 1248 |
1284 if (_firstUserActionRecorder) { | 1249 if (_firstUserActionRecorder) { |
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2693 }; | 2658 }; |
2694 | 2659 |
2695 callbackCounter->IncrementCount(); | 2660 callbackCounter->IncrementCount(); |
2696 [self removeBrowsingDataFromBrowserState:_mainBrowserState | 2661 [self removeBrowsingDataFromBrowserState:_mainBrowserState |
2697 mask:removeAllMask | 2662 mask:removeAllMask |
2698 timePeriod:browsing_data::ALL_TIME | 2663 timePeriod:browsing_data::ALL_TIME |
2699 completionHandler:decrementCallbackCounterCount]; | 2664 completionHandler:decrementCallbackCounterCount]; |
2700 } | 2665 } |
2701 | 2666 |
2702 @end | 2667 @end |
OLD | NEW |