Commit cda30669 authored by Tobias Sargeant's avatar Tobias Sargeant Committed by Commit Bot

aw: Make sure that the null WebViewClient is always returned.

Bug: 853175
Change-Id: I3982fd6c2bc6fecbda09c3f5edb6731921c8618a
Reviewed-on: https://chromium-review.googlesource.com/1102464Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Commit-Queue: Tobias Sargeant <tobiasjs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567701}
parent 2bd0fd44
......@@ -23,8 +23,10 @@ public class SharedWebViewChromium {
// The WebView wrapper for ContentViewCore and required browser compontents.
private AwContents mAwContents;
// Default WebViewClient used to avoid null checks.
final static WebViewClient sNullWebViewClient = new WebViewClient();
// The WebViewClient instance that was passed to WebView.setWebViewClient().
private WebViewClient mWebViewClient;
private WebViewClient mWebViewClient = sNullWebViewClient;
public SharedWebViewChromium(WebViewChromiumRunQueue runQueue, WebViewChromiumAwInit awInit) {
mRunQueue = runQueue;
......@@ -32,7 +34,7 @@ public class SharedWebViewChromium {
}
void setWebViewClient(WebViewClient client) {
mWebViewClient = client;
mWebViewClient = client != null ? client : sNullWebViewClient;
}
public WebViewClient getWebViewClient() {
......
......@@ -1279,7 +1279,7 @@ class WebViewChromium implements WebViewProvider, WebViewProvider.ScrollDelegate
@Override
public void setWebViewClient(WebViewClient client) {
mSharedWebViewChromium.setWebViewClient(client);
mContentsClientAdapter.setWebViewClient(client);
mContentsClientAdapter.setWebViewClient(mSharedWebViewChromium.getWebViewClient());
}
@Override
......
......@@ -92,14 +92,12 @@ class WebViewContentsClientAdapter extends AwContentsClient {
private static final String TAG = "WebViewCallback";
// Enables API callback tracing
private static final boolean TRACE = false;
// Default WebViewClient used to avoid null checks.
private static WebViewClient sNullWebViewClient = new WebViewClient();
// The WebView instance that this adapter is serving.
protected final WebView mWebView;
// The Context to use. This is different from mWebView.getContext(), which should not be used.
private final Context mContext;
// A reference to the current WebViewClient associated with this WebView.
protected WebViewClient mWebViewClient = sNullWebViewClient;
protected WebViewClient mWebViewClient = SharedWebViewChromium.sNullWebViewClient;
// Some callbacks will be forwarded to this client for apps using the support library.
private final SupportLibWebViewContentsClientAdapter mSupportLibClient;
// The WebChromeClient instance that was passed to WebView.setContentViewClient().
......@@ -147,7 +145,6 @@ class WebViewContentsClientAdapter extends AwContentsClient {
try (ScopedSysTraceEvent event =
ScopedSysTraceEvent.scoped("WebViewContentsClientAdapter.constructor")) {
mSupportLibClient = new SupportLibWebViewContentsClientAdapter();
setWebViewClient(null);
mUiThreadHandler = new Handler() {
@Override
......@@ -180,14 +177,8 @@ class WebViewContentsClientAdapter extends AwContentsClient {
}
void setWebViewClient(WebViewClient client) {
if (client != null) {
mWebViewClient = client;
} else {
mWebViewClient = sNullWebViewClient;
}
// Always reset mSupportLibClient, since the WebViewClient may no longer be a
// WebViewClientCompat, or may support a different set of Features.
mSupportLibClient.setWebViewClient(mWebViewClient);
mWebViewClient = client;
mSupportLibClient.setWebViewClient(client);
}
void setWebChromeClient(WebChromeClient client) {
......@@ -220,7 +211,7 @@ class WebViewContentsClientAdapter extends AwContentsClient {
*/
@Override
public boolean hasWebViewClient() {
return mWebViewClient != sNullWebViewClient;
return mWebViewClient != SharedWebViewChromium.sNullWebViewClient;
}
/**
......
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