Commit 9f094c9a authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[iOS][multiball] Reorder startup code.

Reorder startup code to have a continuous block of code that contains
all per-window startup logic. This allows an easier move of this code
to SceneController.

Bug: none
Change-Id: I6f4aa4b8e69cb3a9a7283ac1bf1f2473e4a209f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2039610Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738992}
parent b6fade3c
......@@ -565,9 +565,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
[self.restoreHelper moveAsideSessionInformation];
}
self.appURLLoadingService = new AppUrlLoadingService();
self.appURLLoadingService->SetDelegate(self.sceneController);
// Initialize and set the main browser state.
[self initializeBrowserState:chromeBrowserState];
self.mainBrowserState = chromeBrowserState;
......@@ -578,14 +575,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
self.mainBrowserState));
}
[self.browserViewWrangler shutdown];
self.browserViewWrangler = [[BrowserViewWrangler alloc]
initWithBrowserState:self.mainBrowserState
webStateListObserver:self.sceneController
applicationCommandEndpoint:self.sceneController
browsingDataCommandEndpoint:self
appURLLoadingService:self.appURLLoadingService];
// Force an obvious initialization of the AuthenticationService. This must
// be done before creation of the UI to ensure the service is initialised
// before use (it is a security issue, so accessing the service CHECK if
......@@ -601,9 +590,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
feature_engagement::TrackerFactory::GetForBrowserState(chromeBrowserState)
->NotifyEvent(feature_engagement::events::kChromeOpened);
// Ensure the main tab model is created. This also creates the BVC.
[self.browserViewWrangler createMainBrowser];
_spotlightManager =
[SpotlightManager spotlightManagerWithBrowserState:self.mainBrowserState];
......@@ -611,6 +597,40 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
ShareExtensionServiceFactory::GetForBrowserState(self.mainBrowserState);
service->Initialize();
if ([PreviousSessionInfo sharedInstance].isFirstSessionAfterLanguageChange) {
IOSChromeContentSuggestionsServiceFactory::GetForBrowserState(
chromeBrowserState)
->ClearAllCachedSuggestions();
}
// This is per-window code.
DCHECK(!self.browserViewWrangler);
self.appURLLoadingService = new AppUrlLoadingService();
self.appURLLoadingService->SetDelegate(self.sceneController);
self.browserViewWrangler = [[BrowserViewWrangler alloc]
initWithBrowserState:self.mainBrowserState
webStateListObserver:self.sceneController
applicationCommandEndpoint:self.sceneController
browsingDataCommandEndpoint:self
appURLLoadingService:self.appURLLoadingService];
// Ensure the main tab model is created. This also creates the BVC.
[self.browserViewWrangler createMainBrowser];
// "Low priority" tasks
[_startupTasks registerForApplicationWillResignActiveNotification];
[self registerForOrientationChangeNotifications];
[self.sceneController openTabFromLaunchOptions:_launchOptions
startupInformation:self
appState:self.appState];
_launchOptions = nil;
[self scheduleTasksRequiringBVCWithBrowserState];
// Before bringing up the UI, make sure the launch mode is correct, and
// check for previous crashes.
BOOL startInIncognito = [standardDefaults boolForKey:kIncognitoCurrentKey];
......@@ -625,37 +645,11 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
if (switchFromIncognito)
startInIncognito = NO;
if ([PreviousSessionInfo sharedInstance].isFirstSessionAfterLanguageChange) {
IOSChromeContentSuggestionsServiceFactory::GetForBrowserState(
chromeBrowserState)
->ClearAllCachedSuggestions();
}
[self createInitialUI:(startInIncognito ? ApplicationMode::INCOGNITO
: ApplicationMode::NORMAL)];
[self scheduleStartupCleanupTasks];
[MetricsMediator
logLaunchMetricsWithStartupInformation:self
interfaceProvider:self.interfaceProvider];
if (self.isColdStart) {
[ContentSuggestionsSchedulerNotifications
notifyColdStart:self.mainBrowserState];
[ContentSuggestionsSchedulerNotifications
notifyForeground:self.mainBrowserState];
}
ios::GetChromeBrowserProvider()->GetOverridesProvider()->InstallOverrides();
[self scheduleLowPriorityStartupTasks];
[self.browserViewWrangler updateDeviceSharingManager];
[self.sceneController openTabFromLaunchOptions:_launchOptions
startupInformation:self
appState:self.appState];
_launchOptions = nil;
if (!self.startupParameters) {
// The startup parameters may create new tabs or navigations. If the restore
// infobar is displayed now, it may be dismissed immediately and the user
......@@ -668,7 +662,22 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
self.restoreHelper = nil;
}
[self scheduleTasksRequiringBVCWithBrowserState];
// End of per-window code.
[self scheduleStartupCleanupTasks];
[MetricsMediator
logLaunchMetricsWithStartupInformation:self
interfaceProvider:self.interfaceProvider];
if (self.isColdStart) {
[ContentSuggestionsSchedulerNotifications
notifyColdStart:self.mainBrowserState];
[ContentSuggestionsSchedulerNotifications
notifyForeground:self.mainBrowserState];
}
ios::GetChromeBrowserProvider()->GetOverridesProvider()->InstallOverrides();
[self scheduleLowPriorityStartupTasks];
// Now that everything is properly set up, run the tests.
tests_hook::RunTestsIfPresent();
......@@ -1070,8 +1079,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
- (void)scheduleLowPriorityStartupTasks {
[_startupTasks initializeOmaha];
[_startupTasks donateIntents];
[_startupTasks registerForApplicationWillResignActiveNotification];
[self registerForOrientationChangeNotifications];
[self registerBatteryMonitoringNotifications];
// Deferred tasks.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment