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 ...@@ -69,6 +69,12 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher
// is shown. When there is no blocking UI shown in any scene, this is nil. // is shown. When there is no blocking UI shown in any scene, this is nil.
@property(nonatomic, weak, readonly) SceneState* sceneShowingBlockingUI; @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. // The last window which received a tap.
@property(nonatomic, weak) UIWindow* lastTappedWindow; @property(nonatomic, weak) UIWindow* lastTappedWindow;
......
...@@ -571,10 +571,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -571,10 +571,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
} }
- (void)startUpBrowserForegroundInitialization { - (void)startUpBrowserForegroundInitialization {
BOOL postCrashLaunch = [self mustShowRestoreInfobar]; self.appState.postCrashLaunch = [self mustShowRestoreInfobar];
BOOL needRestore = self.appState.sessionRestorationRequired =
[self startUpBeforeFirstWindowCreatedAndPrepareForRestorationPostCrash: [self startUpBeforeFirstWindowCreatedAndPrepareForRestorationPostCrash:
postCrashLaunch]; self.appState.postCrashLaunch];
if (@available(iOS 13, *)) { if (@available(iOS 13, *)) {
if (IsSceneStartupSupported()) { if (IsSceneStartupSupported()) {
...@@ -585,8 +585,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -585,8 +585,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
} }
SceneState* sceneState = self.appState.connectedScenes.firstObject; SceneState* sceneState = self.appState.connectedScenes.firstObject;
[sceneState.controller startUpChromeUIPostCrash:postCrashLaunch [sceneState.controller startUpChromeUI];
needRestoration:needRestore];
[self startUpAfterFirstWindowCreated]; [self startUpAfterFirstWindowCreated];
} }
......
...@@ -484,7 +484,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] = ...@@ -484,7 +484,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
if (IsSceneStartupSupported()) { if (IsSceneStartupSupported()) {
// TODO(crbug.com/1012697): This should probably be the only code path for // TODO(crbug.com/1012697): This should probably be the only code path for
// UIScene and non-UIScene cases. // UIScene and non-UIScene cases.
[self startUpChromeUIPostCrash:NO needRestoration:NO]; [self startUpChromeUI];
} }
self.hasInitializedUI = YES; self.hasInitializedUI = YES;
...@@ -493,8 +493,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] = ...@@ -493,8 +493,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
#pragma mark - private #pragma mark - private
// Starts up a single chrome window and its UI. // Starts up a single chrome window and its UI.
- (void)startUpChromeUIPostCrash:(BOOL)isPostCrashLaunch - (void)startUpChromeUI {
needRestoration:(BOOL)needsRestoration {
DCHECK(!self.browserViewWrangler); DCHECK(!self.browserViewWrangler);
DCHECK(self.sceneURLLoadingService); DCHECK(self.sceneURLLoadingService);
DCHECK(self.mainController); DCHECK(self.mainController);
...@@ -511,7 +510,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] = ...@@ -511,7 +510,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
// Only create the restoration helper if the browser state was backed up // Only create the restoration helper if the browser state was backed up
// successfully. // successfully.
if (needsRestoration) { if (self.sceneState.appState.sessionRestorationRequired) {
self.mainController.restoreHelper = self.mainController.restoreHelper =
[[CrashRestoreHelper alloc] initWithBrowser:self.mainInterface.browser]; [[CrashRestoreHelper alloc] initWithBrowser:self.mainInterface.browser];
} }
...@@ -523,7 +522,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] = ...@@ -523,7 +522,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
BOOL switchFromIncognito = BOOL switchFromIncognito =
startInIncognito && ![self.mainController canLaunchInIncognito]; startInIncognito && ![self.mainController canLaunchInIncognito];
if (isPostCrashLaunch || switchFromIncognito) { if (self.sceneState.appState.postCrashLaunch || switchFromIncognito) {
[self clearIOSSpecificIncognitoData]; [self clearIOSSpecificIncognitoData];
if (switchFromIncognito) if (switchFromIncognito)
[self.browserViewWrangler [self.browserViewWrangler
......
...@@ -7,17 +7,11 @@ ...@@ -7,17 +7,11 @@
#import <UIKit/UIKit.h> #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 @protocol SceneControllerGuts
#pragma mark - iOS 12 compat #pragma mark - iOS 12 compat
- (void)startUpChromeUIPostCrash:(BOOL)isPostCrashLaunch - (void)startUpChromeUI;
needRestoration:(BOOL)needsRestoration;
@end @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