Commit 0928665a authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

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/835532Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526099}
parent d6fdfe40
......@@ -407,7 +407,15 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher
// closing the tabs. Set the BVC to inactive to cancel all the dialogs.
if ([_browserLauncher browserInitializationStage] >=
INITIALIZATION_STAGE_FOREGROUND) {
[[_browserLauncher browserViewInformation] haltAllTabs];
[[_browserLauncher browserViewInformation].mainTabModel 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;
}
......
......@@ -523,10 +523,14 @@ TEST_F(AppStateWithThreadTest, willTerminate) {
id window = [OCMockObject mockForClass:[UIWindow class]];
id browserViewInformation =
[OCMockObject mockForProtocol:@protocol(BrowserViewInformation)];
id mainTabModel = [OCMockObject mockForClass:[TabModel class]];
id OTRTabModel = [OCMockObject mockForClass:[TabModel class]];
[[[browserLauncher stub] andReturnValue:@(INITIALIZATION_STAGE_FOREGROUND)]
browserInitializationStage];
[[[browserLauncher stub] andReturn:browserViewInformation]
browserViewInformation];
[[[browserViewInformation stub] andReturn:mainTabModel] mainTabModel];
[[[browserViewInformation stub] andReturn:OTRTabModel] otrTabModel];
[[[browserViewInformation stub] andReturn:browserViewController] currentBVC];
id settingsNavigationController =
......@@ -538,7 +542,11 @@ TEST_F(AppStateWithThreadTest, willTerminate) {
[[appNavigation expect] closeSettingsAnimated:NO completion:nil];
[[browserViewInformation expect] cleanDeviceSharingManager];
[[browserViewInformation expect] haltAllTabs];
[[mainTabModel expect] haltAllTabs];
[[OTRTabModel expect] closeAllTabs];
[[OTRTabModel expect] saveSessionImmediately:YES];
id startupInformation =
[OCMockObject mockForProtocol:@protocol(StartupInformation)];
......@@ -559,6 +567,8 @@ TEST_F(AppStateWithThreadTest, willTerminate) {
applicationNavigation:appNavigation];
// Test.
EXPECT_OCMOCK_VERIFY(OTRTabModel);
EXPECT_OCMOCK_VERIFY(mainTabModel);
EXPECT_OCMOCK_VERIFY(browserViewController);
EXPECT_OCMOCK_VERIFY(startupInformation);
EXPECT_OCMOCK_VERIFY(appNavigation);
......
......@@ -919,10 +919,6 @@ const int kExternalFilesCleanupDelaySeconds = 60;
#pragma mark - BrowserViewInformation implementation.
- (void)haltAllTabs {
[_browserViewWrangler haltAllTabs];
}
- (void)cleanDeviceSharingManager {
[_browserViewWrangler cleanDeviceSharingManager];
}
......
......@@ -29,9 +29,6 @@ class ChromeBrowserState;
// otrBVC). The other, if present, is in suspended mode.
@property(nonatomic, assign) BrowserViewController* currentBVC;
// Halts all tabs from all TabModels.
- (void)haltAllTabs;
// Returns the browser state corresponding to the current browser view.
- (ios::ChromeBrowserState*)currentBrowserState;
......
......@@ -224,11 +224,6 @@
return self.currentBVC.browserState;
}
- (void)haltAllTabs {
[self.mainTabModel haltAllTabs];
[self.otrTabModel haltAllTabs];
}
- (void)cleanDeviceSharingManager {
[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