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,61 +2169,41 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -2169,61 +2169,41 @@ enum class EnterTabSwitcherSnapshotResult {
disableWebUsageDuringRemoval = NO; disableWebUsageDuringRemoval = NO;
} }
ProceduralBlock removeBrowsingDataBlock = ^{ if (disableWebUsageDuringRemoval) {
if (disableWebUsageDuringRemoval) { // Disables browsing and purges web views.
// Disables browsing and purges web views. // Must be called only on the main thread.
// Must be called only on the main thread. DCHECK([NSThread isMainThread]);
DCHECK([NSThread isMainThread]); self.interfaceProvider.mainInterface.userInteractionEnabled = NO;
self.interfaceProvider.mainInterface.userInteractionEnabled = NO; self.interfaceProvider.incognitoInterface.userInteractionEnabled = NO;
self.interfaceProvider.incognitoInterface.userInteractionEnabled = NO; } else if (showActivityIndicator) {
} else if (showActivityIndicator) { // Show activity overlay so users know that clear browsing data is in
// Show activity overlay so users know that clear browsing data is in // progress.
// progress. [self.mainBVC.dispatcher showActivityOverlay:YES];
[self.mainBVC.dispatcher showActivityOverlay:YES]; }
}
BrowsingDataRemoverFactory::GetForBrowserState(browserState)
BrowsingDataRemoverFactory::GetForBrowserState(browserState) ->Remove(
->Remove(timePeriod, removeMask, base::BindOnce(^{ timePeriod, removeMask, base::BindOnce(^{
// Activates browsing and enables web views. // Activates browsing and enables web views.
// Must be called only on the main thread. // Must be called only on the main thread.
DCHECK([NSThread isMainThread]); DCHECK([NSThread isMainThread]);
if (showActivityIndicator) { if (showActivityIndicator) {
// User interaction still needs to be disabled as a way to // User interaction still needs to be disabled as a way to
// force reload all the web states and to reset NTPs. // force reload all the web states and to reset NTPs.
self.interfaceProvider.mainInterface self.interfaceProvider.mainInterface.userInteractionEnabled = NO;
.userInteractionEnabled = NO; self.interfaceProvider.incognitoInterface.userInteractionEnabled =
self.interfaceProvider.incognitoInterface NO;
.userInteractionEnabled = NO;
[self.mainBVC.dispatcher showActivityOverlay:NO];
[self.mainBVC.dispatcher showActivityOverlay:NO]; }
} self.interfaceProvider.mainInterface.userInteractionEnabled = YES;
self.interfaceProvider.mainInterface.userInteractionEnabled = self.interfaceProvider.incognitoInterface.userInteractionEnabled =
YES; YES;
self.interfaceProvider.incognitoInterface [self.currentBVC setPrimary:YES];
.userInteractionEnabled = YES;
[self.currentBVC setPrimary:YES]; if (completionBlock)
completionBlock();
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 #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