Commit 2aa8d3b9 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Fix a crash in Preview Tab

Preview Tab based on ThinWebView/BottomSheet is designed to reuse
the WebContents until the sheet is closed. But it was actually being
recreated for every new url due to how OverlayPanelContent works.

When preview tab displays an interstitial page with security state
change, the access to WebContents is made while it is in the destroyed
state, hence the reported crash occurred. This CL adds a new public
method in OverlayPanelContent so it has a way to reuse the WebContents.

Bug: 1030616
Change-Id: If9ed28dfefd83720ccd08fc6ef9fd6ffce92aa3c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006836Reviewed-by: default avatarDonn Denman <donnd@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733060}
parent c7c61c62
...@@ -268,12 +268,20 @@ public class OverlayPanelContent { ...@@ -268,12 +268,20 @@ public class OverlayPanelContent {
} }
} }
/**
* Whether we should reuse any existing WebContents instead of deleting and recreating.
* @param reuse {@code true} if we want to reuse the WebContents.
*/
public void setReuseWebContents(boolean reuse) {
mShouldReuseWebContents = reuse;
}
/** /**
* Call this when a loadUrl request has failed to notify the panel that the WebContents can * Call this when a loadUrl request has failed to notify the panel that the WebContents can
* be reused. See crbug.com/682953 for details. * be reused. See crbug.com/682953 for details.
*/ */
void onLoadUrlFailed() { void onLoadUrlFailed() {
mShouldReuseWebContents = true; setReuseWebContents(true);
} }
/** /**
......
...@@ -139,6 +139,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -139,6 +139,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
new PageLoadProgressObserver(), mActivity, mIsIncognito, new PageLoadProgressObserver(), mActivity, mIsIncognito,
mActivity.getResources().getDimensionPixelSize( mActivity.getResources().getDimensionPixelSize(
R.dimen.toolbar_height_no_shadow)); R.dimen.toolbar_height_no_shadow));
mPanelContent.setReuseWebContents(true);
} }
return mPanelContent; return mPanelContent;
} }
......
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