Commit 7f4bdd7b authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios/web] Don't delay clear browsing data for slimnav restoration.

Since crrev.com/c/1540371 it's been safe to trigger a clear
browsing data restore during a slimnav restore.  This is because we
DetachFromWebView during clear browsing data, and reset the
|is_restore_session_in_progress| flag.

DetachFromWebView already supports extracting restore urls from history,
so there shouldn't be any data loss.

Additionally, the delay implementation is wrong, since it's valid for a
webstate to be suspended in the tab grid  while in a slimnav restore state.
In fact, on a restart, most tabs are in that state.  So triggering clear
browsing data when that suspended tab is the 'active' tab, will hang forever.

Bug: 961726
TEST=
1.) Open a few tabs and create some navigation history for each (at least 10 navigation items)
2.) Quit the app
3.) Launch the app and quickly clear browsing data

Change-Id: Ic0a67523f5a0e2a63f31061735c12a2a27abb09f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1807025Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697361}
parent b50e3f49
......@@ -2169,7 +2169,6 @@ enum class EnterTabSwitcherSnapshotResult {
disableWebUsageDuringRemoval = NO;
}
ProceduralBlock removeBrowsingDataBlock = ^{
if (disableWebUsageDuringRemoval) {
// Disables browsing and purges web views.
// Must be called only on the main thread.
......@@ -2183,47 +2182,28 @@ enum class EnterTabSwitcherSnapshotResult {
}
BrowsingDataRemoverFactory::GetForBrowserState(browserState)
->Remove(timePeriod, removeMask, base::BindOnce(^{
->Remove(
timePeriod, removeMask, base::BindOnce(^{
// Activates browsing and enables web views.
// Must be called only on the main thread.
DCHECK([NSThread isMainThread]);
if (showActivityIndicator) {
// User interaction still needs to be disabled as a way to
// force reload all the web states and to reset NTPs.
self.interfaceProvider.mainInterface
.userInteractionEnabled = NO;
self.interfaceProvider.incognitoInterface
.userInteractionEnabled = NO;
self.interfaceProvider.mainInterface.userInteractionEnabled = NO;
self.interfaceProvider.incognitoInterface.userInteractionEnabled =
NO;
[self.mainBVC.dispatcher showActivityOverlay:NO];
}
self.interfaceProvider.mainInterface.userInteractionEnabled =
self.interfaceProvider.mainInterface.userInteractionEnabled = YES;
self.interfaceProvider.incognitoInterface.userInteractionEnabled =
YES;
self.interfaceProvider.incognitoInterface
.userInteractionEnabled = YES;
[self.currentBVC setPrimary:YES];
if (completionBlock)
completionBlock();
}));
};
// Removing browsing data triggers session restore in navigation manager. If
// there is an in-progress session restore, wait for it to finish before
// attempting to clear browsing data again.
web::WebState* webState =
self.currentBVC.tabModel
? self.currentBVC.tabModel.webStateList->GetActiveWebState()
: nullptr;
if (webState && webState->GetNavigationManager()) {
webState->GetNavigationManager()->AddRestoreCompletionCallback(
base::BindOnce(^{
removeBrowsingDataBlock();
}));
return;
}
removeBrowsingDataBlock();
}
#pragma mark - Navigation Controllers
......
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