Commit 2bfe4c32 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Move startUpChromeUI to SceneController

Moves -startUpChromeUIPostCrash:needRestoration: method to
SceneController.

Bug: 1045658
Change-Id: I3d3890b1480dfe1facfbfe58e01cc4bb8ffd7521
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087614
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747178}
parent 644fc623
......@@ -376,8 +376,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
// Schedule the deletion of the temporary passwords files that might
// be left over from incomplete export operations.
- (void)scheduleDeleteTempPasswordsDirectory;
// Returns whether or not the app can launch in incognito mode.
- (BOOL)canLaunchInIncognito;
// Initializes the first run UI and presents it to the user.
- (void)showFirstRunUI;
// Schedules presentation of the first eligible promo found, if any.
......@@ -623,71 +621,13 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
tests_hook::RunTestsIfPresent();
}
// Starts up a single chrome window and its UI.
- (void)startUpChromeUIPostCrash:(BOOL)isPostCrashLaunch
needRestoration:(BOOL)needsRestoration {
DCHECK(!self.sceneController.browserViewWrangler);
DCHECK(self.sceneController.appURLLoadingService);
self.sceneController.browserViewWrangler = [[BrowserViewWrangler alloc]
initWithBrowserState:self.mainBrowserState
webStateListObserver:self.sceneController
applicationCommandEndpoint:self.sceneController
browsingDataCommandEndpoint:self
appURLLoadingService:self.sceneController.appURLLoadingService];
// Ensure the main tab model is created. This also creates the BVC.
[self.sceneController.browserViewWrangler createMainBrowser];
// Only create the restoration helper if the browser state was backed up
// successfully.
if (needsRestoration) {
self.restoreHelper =
[[CrashRestoreHelper alloc] initWithBrowser:self.mainBrowser];
}
[self.sceneController openTabFromLaunchOptions:_launchOptions
startupInformation:self
appState:self.appState];
[self scheduleShowPromo];
// Before bringing up the UI, make sure the launch mode is correct, and
// check for previous crashes.
BOOL startInIncognito =
[[NSUserDefaults standardUserDefaults] boolForKey:kIncognitoCurrentKey];
BOOL switchFromIncognito = startInIncognito && ![self canLaunchInIncognito];
if (isPostCrashLaunch || switchFromIncognito) {
[self.sceneController clearIOSSpecificIncognitoData];
if (switchFromIncognito)
[self.sceneController.browserViewWrangler
switchGlobalStateToMode:ApplicationMode::NORMAL];
}
if (switchFromIncognito)
startInIncognito = NO;
[self.sceneController
createInitialUI:(startInIncognito ? ApplicationMode::INCOGNITO
: ApplicationMode::NORMAL)];
[self.sceneController.browserViewWrangler updateDeviceSharingManager];
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
// will never be able to restore the session.
[self.restoreHelper showRestorePrompt];
self.restoreHelper = nil;
}
}
- (void)startUpBrowserForegroundInitialization {
BOOL postCrashLaunch = [self mustShowRestoreInfobar];
BOOL needRestore =
[self startUpBeforeFirstWindowCreatedAndPrepareForRestorationPostCrash:
postCrashLaunch];
[self startUpChromeUIPostCrash:postCrashLaunch needRestoration:needRestore];
[self.sceneController startUpChromeUIPostCrash:postCrashLaunch
needRestoration:needRestore];
[self startUpAfterFirstWindowCreated];
}
......@@ -1338,11 +1278,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return self.interfaceProvider.currentInterface.bvc;
}
- (TabModel*)currentTabModel {
return self.currentBVC.tabModel;
}
......
......@@ -9,10 +9,13 @@
#import "base/ios/block_types.h"
#include "components/browsing_data/core/browsing_data_utils.h"
#import "ios/chrome/app/application_delegate/startup_information.h"
#include "ios/chrome/app/startup/chrome_app_startup_parameters.h"
#include "ios/chrome/browser/browsing_data/browsing_data_remove_mask.h"
#import "ios/chrome/browser/crash_report/crash_restore_helper.h"
#import "ios/chrome/browser/ui/commands/browsing_data_commands.h"
@class AppState;
@class BrowserViewController;
class ChromeBrowserState;
@class TabGridCoordinator;
......@@ -21,7 +24,7 @@ class ChromeBrowserState;
// TODO(crbug.com/1012697): Remove this protocol when SceneController is
// operational. Move the private internals back into MainController, and pass
// ownership of Scene-related objects to SceneController.
@protocol MainControllerGuts
@protocol MainControllerGuts <StartupInformation, BrowsingDataCommands>
// If YES, the tab switcher is currently active.
@property(nonatomic, assign, getter=isTabSwitcherActive)
......@@ -46,6 +49,8 @@ class ChromeBrowserState;
- (TabGridCoordinator*)mainCoordinator;
- (id<BrowserInterfaceProvider>)interfaceProvider;
- (UIWindow*)window;
- (NSDictionary*)launchOptions;
- (AppState*)appState;
- (void)removeBrowsingDataForBrowserState:(ChromeBrowserState*)browserState
timePeriod:(browsing_data::TimePeriod)timePeriod
......@@ -53,6 +58,9 @@ class ChromeBrowserState;
completionBlock:(ProceduralBlock)completionBlock;
- (void)showFirstRunUI;
- (void)scheduleShowPromo;
// Returns whether or not the app can launch in incognito mode.
- (BOOL)canLaunchInIncognito;
@end
......
......@@ -7,7 +7,6 @@ import("//ios/build/chrome_build.gni")
source_set("scene_guts") {
sources = [ "scene_controller_guts.h" ]
deps = [
"//ios/chrome/app:mode",
"//ios/chrome/app/application_delegate:application_delegate_internal",
"//ios/chrome/browser:utils",
"//ios/chrome/browser/ui/tab_grid",
......@@ -36,6 +35,7 @@ source_set("scene") {
"//components/signin/public/identity_manager",
"//components/url_formatter",
"//ios/chrome/app:app",
"//ios/chrome/app:mode",
"//ios/chrome/app:tests_hook",
"//ios/chrome/app/application_delegate:application_delegate_internal",
"//ios/chrome/browser",
......
......@@ -14,6 +14,7 @@
#import "ios/chrome/app/application_delegate/app_state.h"
#include "ios/chrome/app/application_delegate/tab_opening.h"
#import "ios/chrome/app/application_delegate/url_opener.h"
#include "ios/chrome/app/application_mode.h"
#import "ios/chrome/app/chrome_overlay_window.h"
#import "ios/chrome/app/deferred_initialization_runner.h"
#import "ios/chrome/app/main_controller_guts.h"
......@@ -224,6 +225,65 @@ enum class TabSwitcherDismissalMode { NONE, NORMAL, INCOGNITO };
#pragma mark - private
// Starts up a single chrome window and its UI.
- (void)startUpChromeUIPostCrash:(BOOL)isPostCrashLaunch
needRestoration:(BOOL)needsRestoration {
DCHECK(!self.browserViewWrangler);
DCHECK(self.appURLLoadingService);
self.browserViewWrangler = [[BrowserViewWrangler alloc]
initWithBrowserState:self.mainController.mainBrowserState
webStateListObserver:self
applicationCommandEndpoint:self
browsingDataCommandEndpoint:self.mainController
appURLLoadingService:self.appURLLoadingService];
// Ensure the main tab model is created. This also creates the BVC.
[self.browserViewWrangler createMainBrowser];
// Only create the restoration helper if the browser state was backed up
// successfully.
if (needsRestoration) {
self.mainController.restoreHelper =
[[CrashRestoreHelper alloc] initWithBrowser:self.mainInterface.browser];
}
[self openTabFromLaunchOptions:self.mainController.launchOptions
startupInformation:self.mainController
appState:self.mainController.appState];
[self.mainController scheduleShowPromo];
// Before bringing up the UI, make sure the launch mode is correct, and
// check for previous crashes.
BOOL startInIncognito =
[[NSUserDefaults standardUserDefaults] boolForKey:kIncognitoCurrentKey];
BOOL switchFromIncognito =
startInIncognito && ![self.mainController canLaunchInIncognito];
if (isPostCrashLaunch || switchFromIncognito) {
[self clearIOSSpecificIncognitoData];
if (switchFromIncognito)
[self.browserViewWrangler
switchGlobalStateToMode:ApplicationMode::NORMAL];
}
if (switchFromIncognito)
startInIncognito = NO;
[self createInitialUI:(startInIncognito ? ApplicationMode::INCOGNITO
: ApplicationMode::NORMAL)];
[self.browserViewWrangler updateDeviceSharingManager];
if (!self.mainController.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
// will never be able to restore the session.
[self.mainController.restoreHelper showRestorePrompt];
self.mainController.restoreHelper = nil;
}
}
// Determines which UI should be shown on startup, and shows it.
- (void)createInitialUI:(ApplicationMode)launchMode {
DCHECK(self.mainController.mainBrowserState);
......
......@@ -9,7 +9,6 @@
#include "ios/chrome/app/application_delegate/startup_information.h"
#import "ios/chrome/app/application_delegate/tab_opening.h"
#include "ios/chrome/app/application_mode.h"
#import "ios/chrome/browser/procedural_block_types.h"
#import "ios/chrome/browser/ui/tab_grid/tab_switcher.h"
#import "ios/chrome/browser/url_loading/app_url_loading_service.h"
......@@ -31,7 +30,8 @@ class ChromeBrowserState;
// browser state level UrlLoadingService instances.
@property(nonatomic, assign) AppUrlLoadingService* appURLLoadingService;
- (void)createInitialUI:(ApplicationMode)launchMode;
- (void)startUpChromeUIPostCrash:(BOOL)isPostCrashLaunch
needRestoration:(BOOL)needsRestoration;
- (void)dismissModalDialogsWithCompletion:(ProceduralBlock)completion
dismissOmnibox:(BOOL)dismissOmnibox;
......
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