Commit f89cb5f7 authored by Danyao Wang's avatar Danyao Wang Committed by Commit Bot

[Nav Experiment] RestoreSession after webUsageEnabled is true.

WKBasedNavigationManager needs to create a web view to restore session.
The current order causes an CHECK in CRWWebController that prevents
the creation of new web view when |_webUsageEnabled| is false.

This fixes failure in NavigationTestCase and crashes observed in the
wild.

Bug: 852847
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ia6a7800ca6ec985a2080d0e0acc3a743c8c62c5f
Reviewed-on: https://chromium-review.googlesource.com/1108575Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Danyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569259}
parent 6be4bc5d
......@@ -568,6 +568,11 @@ bool WebStateImpl::IsWebUsageEnabled() const {
}
void WebStateImpl::SetWebUsageEnabled(bool enabled) {
// This must be called before RestoreSessionStorage() because the latter
// creates a web view under WKBasedNavigationManager, and expects
// _webUsageEnabled to be true.
[web_controller_ setWebUsageEnabled:enabled];
// SetWebUsageEnabled(false) will cause the WKWebView to be removed and this
// is the only way to clear browser data. Cache the session history in this
// WebState so that when web usage is re-enabled, history can be restored into
......@@ -583,8 +588,6 @@ void WebStateImpl::SetWebUsageEnabled(bool enabled) {
cached_session_storage_ = BuildSessionStorage();
}
}
[web_controller_ setWebUsageEnabled:enabled];
}
bool WebStateImpl::ShouldSuppressDialogs() const {
......
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