Commit 47c34860 authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

Revert "Do not recover incognito tabs if user deliberately terminates Chrome."

This reverts commit 0928665a.

Reason for revert: This behavior is causing more confusion for users than it is helping. See crbug.com/854274 for details.

Original change's description:
> Do not recover incognito tabs if user deliberately terminates Chrome.
>
> Previously incognito tabs were always recovered no matter how the app
> was last shutdown.
>
> Instead, do not restore the incognito tabs if the user explicitly closes
> Chrome. If the system terminates the app, the tabs should be restored.
> (This can happen at any time and without user notice, so such
> terminations should not lead to a loss of the user's incognito tabs.)
>
> Bug: 653248
> Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
> Change-Id: I018cdf5cda2004e32e1010c4d9bab4bd10c0ae99
> Reviewed-on: https://chromium-review.googlesource.com/835532
> Reviewed-by: Eugene But <eugenebut@chromium.org>
> Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#526099}

TBR=marq@chromium.org,eugenebut@chromium.org,michaeldo@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 653248, 854274
Change-Id: I952db05d6364d0944c3e46b9fa78b1432e889830
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Reviewed-on: https://chromium-review.googlesource.com/1106777
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568603}
parent 76118b8c
...@@ -395,15 +395,7 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher ...@@ -395,15 +395,7 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher
// closing the tabs. Set the BVC to inactive to cancel all the dialogs. // closing the tabs. Set the BVC to inactive to cancel all the dialogs.
if ([_browserLauncher browserInitializationStage] >= if ([_browserLauncher browserInitializationStage] >=
INITIALIZATION_STAGE_FOREGROUND) { INITIALIZATION_STAGE_FOREGROUND) {
[[_browserLauncher browserViewInformation].mainTabModel haltAllTabs]; [[_browserLauncher browserViewInformation] haltAllTabs];
// Application termination flow is only triggered on a shutdown deliberately
// triggered by a user. In this case, close all incognito tabs.
TabModel* OTRTabModel =
[_browserLauncher browserViewInformation].otrTabModel;
[OTRTabModel closeAllTabs];
[OTRTabModel saveSessionImmediately:YES];
[_browserLauncher browserViewInformation].currentBVC.active = NO; [_browserLauncher browserViewInformation].currentBVC.active = NO;
} }
......
...@@ -524,14 +524,10 @@ TEST_F(AppStateWithThreadTest, willTerminate) { ...@@ -524,14 +524,10 @@ TEST_F(AppStateWithThreadTest, willTerminate) {
id window = [OCMockObject mockForClass:[UIWindow class]]; id window = [OCMockObject mockForClass:[UIWindow class]];
id browserViewInformation = id browserViewInformation =
[OCMockObject mockForProtocol:@protocol(BrowserViewInformation)]; [OCMockObject mockForProtocol:@protocol(BrowserViewInformation)];
id mainTabModel = [OCMockObject mockForClass:[TabModel class]];
id OTRTabModel = [OCMockObject mockForClass:[TabModel class]];
[[[browserLauncher stub] andReturnValue:@(INITIALIZATION_STAGE_FOREGROUND)] [[[browserLauncher stub] andReturnValue:@(INITIALIZATION_STAGE_FOREGROUND)]
browserInitializationStage]; browserInitializationStage];
[[[browserLauncher stub] andReturn:browserViewInformation] [[[browserLauncher stub] andReturn:browserViewInformation]
browserViewInformation]; browserViewInformation];
[[[browserViewInformation stub] andReturn:mainTabModel] mainTabModel];
[[[browserViewInformation stub] andReturn:OTRTabModel] otrTabModel];
[[[browserViewInformation stub] andReturn:browserViewController] currentBVC]; [[[browserViewInformation stub] andReturn:browserViewController] currentBVC];
id settingsNavigationController = id settingsNavigationController =
...@@ -543,11 +539,7 @@ TEST_F(AppStateWithThreadTest, willTerminate) { ...@@ -543,11 +539,7 @@ TEST_F(AppStateWithThreadTest, willTerminate) {
[[appNavigation expect] closeSettingsAnimated:NO completion:nil]; [[appNavigation expect] closeSettingsAnimated:NO completion:nil];
[[browserViewInformation expect] cleanDeviceSharingManager]; [[browserViewInformation expect] cleanDeviceSharingManager];
[[browserViewInformation expect] haltAllTabs];
[[mainTabModel expect] haltAllTabs];
[[OTRTabModel expect] closeAllTabs];
[[OTRTabModel expect] saveSessionImmediately:YES];
id startupInformation = id startupInformation =
[OCMockObject mockForProtocol:@protocol(StartupInformation)]; [OCMockObject mockForProtocol:@protocol(StartupInformation)];
...@@ -566,8 +558,6 @@ TEST_F(AppStateWithThreadTest, willTerminate) { ...@@ -566,8 +558,6 @@ TEST_F(AppStateWithThreadTest, willTerminate) {
applicationNavigation:appNavigation]; applicationNavigation:appNavigation];
// Test. // Test.
EXPECT_OCMOCK_VERIFY(OTRTabModel);
EXPECT_OCMOCK_VERIFY(mainTabModel);
EXPECT_OCMOCK_VERIFY(browserViewController); EXPECT_OCMOCK_VERIFY(browserViewController);
EXPECT_OCMOCK_VERIFY(startupInformation); EXPECT_OCMOCK_VERIFY(startupInformation);
EXPECT_OCMOCK_VERIFY(appNavigation); EXPECT_OCMOCK_VERIFY(appNavigation);
......
...@@ -967,6 +967,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -967,6 +967,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
#pragma mark - BrowserViewInformation implementation. #pragma mark - BrowserViewInformation implementation.
- (void)haltAllTabs {
[_browserViewWrangler haltAllTabs];
}
- (void)cleanDeviceSharingManager { - (void)cleanDeviceSharingManager {
[_browserViewWrangler cleanDeviceSharingManager]; [_browserViewWrangler cleanDeviceSharingManager];
} }
......
...@@ -29,6 +29,9 @@ class ChromeBrowserState; ...@@ -29,6 +29,9 @@ class ChromeBrowserState;
// otrBVC). The other, if present, is in suspended mode. // otrBVC). The other, if present, is in suspended mode.
@property(nonatomic, assign) BrowserViewController* currentBVC; @property(nonatomic, assign) BrowserViewController* currentBVC;
// Halts all tabs from all TabModels.
- (void)haltAllTabs;
// Returns the browser state corresponding to the current browser view. // Returns the browser state corresponding to the current browser view.
- (ios::ChromeBrowserState*)currentBrowserState; - (ios::ChromeBrowserState*)currentBrowserState;
......
...@@ -221,6 +221,11 @@ ...@@ -221,6 +221,11 @@
return self.currentBVC.browserState; return self.currentBVC.browserState;
} }
- (void)haltAllTabs {
[self.mainTabModel haltAllTabs];
[self.otrTabModel haltAllTabs];
}
- (void)cleanDeviceSharingManager { - (void)cleanDeviceSharingManager {
[self.deviceSharingManager updateBrowserState:NULL]; [self.deviceSharingManager updateBrowserState:NULL];
} }
......
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