Commit 3abc3baf authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Prompt for session restore in multiwindow.

Patches the code that was always sending "NO" to session restore-related
calls in scene controller by saving the intermediate state in AppState.

Bug: 1078164
Change-Id: I028d91964054496acf01bc52b905524b4d2aa29e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2330151
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794464}
parent c907081f
......@@ -69,6 +69,12 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher
// is shown. When there is no blocking UI shown in any scene, this is nil.
@property(nonatomic, weak, readonly) SceneState* sceneShowingBlockingUI;
// Indicates that this app launch is one after a crash.
@property(nonatomic, assign) BOOL postCrashLaunch;
// Indicates that session restoration might be required for connecting scenes.
@property(nonatomic, assign) BOOL sessionRestorationRequired;
// The last window which received a tap.
@property(nonatomic, weak) UIWindow* lastTappedWindow;
......
......@@ -571,10 +571,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
}
- (void)startUpBrowserForegroundInitialization {
BOOL postCrashLaunch = [self mustShowRestoreInfobar];
BOOL needRestore =
self.appState.postCrashLaunch = [self mustShowRestoreInfobar];
self.appState.sessionRestorationRequired =
[self startUpBeforeFirstWindowCreatedAndPrepareForRestorationPostCrash:
postCrashLaunch];
self.appState.postCrashLaunch];
if (@available(iOS 13, *)) {
if (IsSceneStartupSupported()) {
......@@ -585,8 +585,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
}
SceneState* sceneState = self.appState.connectedScenes.firstObject;
[sceneState.controller startUpChromeUIPostCrash:postCrashLaunch
needRestoration:needRestore];
[sceneState.controller startUpChromeUI];
[self startUpAfterFirstWindowCreated];
}
......
......@@ -484,7 +484,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
if (IsSceneStartupSupported()) {
// TODO(crbug.com/1012697): This should probably be the only code path for
// UIScene and non-UIScene cases.
[self startUpChromeUIPostCrash:NO needRestoration:NO];
[self startUpChromeUI];
}
self.hasInitializedUI = YES;
......@@ -493,8 +493,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
#pragma mark - private
// Starts up a single chrome window and its UI.
- (void)startUpChromeUIPostCrash:(BOOL)isPostCrashLaunch
needRestoration:(BOOL)needsRestoration {
- (void)startUpChromeUI {
DCHECK(!self.browserViewWrangler);
DCHECK(self.sceneURLLoadingService);
DCHECK(self.mainController);
......@@ -511,7 +510,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
// Only create the restoration helper if the browser state was backed up
// successfully.
if (needsRestoration) {
if (self.sceneState.appState.sessionRestorationRequired) {
self.mainController.restoreHelper =
[[CrashRestoreHelper alloc] initWithBrowser:self.mainInterface.browser];
}
......@@ -523,7 +522,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
BOOL switchFromIncognito =
startInIncognito && ![self.mainController canLaunchInIncognito];
if (isPostCrashLaunch || switchFromIncognito) {
if (self.sceneState.appState.postCrashLaunch || switchFromIncognito) {
[self clearIOSSpecificIncognitoData];
if (switchFromIncognito)
[self.browserViewWrangler
......
......@@ -7,17 +7,11 @@
#import <UIKit/UIKit.h>
#import "ios/chrome/app/application_delegate/tab_opening.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/url_loading_params.h"
@protocol SceneControllerGuts
#pragma mark - iOS 12 compat
- (void)startUpChromeUIPostCrash:(BOOL)isPostCrashLaunch
needRestoration:(BOOL)needsRestoration;
- (void)startUpChromeUI;
@end
......
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