Commit 0ad845d3 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

aw: Check isDestroyedOrNoOperation for shouldOverrideUrlLoading

Two reasons. One is that these callbacks should not happen if renderer
process crashed. Looks like this (and a few others) are missed because
they are synchronous and called from AwContentsClient instead of
AwContentsClientCallbackHelper.

Second reason which is relevant to the bug is that we should not
callback to the app if webview is already destroyed. This can happen
when a native->java jni call uses a jweak which can resurrect objects
that are effectively destroyed already.

Bug: 824156
Change-Id: I0a8d59e2f36070d7a4c53242ce077bda3c9bfe73
Reviewed-on: https://chromium-review.googlesource.com/981433Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546158}
parent 0e268f2b
...@@ -161,6 +161,10 @@ public abstract class AwContentsClient { ...@@ -161,6 +161,10 @@ public abstract class AwContentsClient {
public final boolean shouldIgnoreNavigation(Context context, String url, boolean isMainFrame, public final boolean shouldIgnoreNavigation(Context context, String url, boolean isMainFrame,
boolean hasUserGesture, boolean isRedirect) { boolean hasUserGesture, boolean isRedirect) {
AwContentsClientCallbackHelper.CancelCallbackPoller poller =
mCallbackHelper.getCancelCallbackPoller();
if (poller != null && poller.shouldCancelAllCallbacks()) return false;
if (hasWebViewClient()) { if (hasWebViewClient()) {
AwWebResourceRequest request = new AwWebResourceRequest(); AwWebResourceRequest request = new AwWebResourceRequest();
request.url = url; request.url = url;
......
...@@ -26,9 +26,7 @@ public class AwContentsClientCallbackHelper { ...@@ -26,9 +26,7 @@ public class AwContentsClientCallbackHelper {
/** /**
* Interface to tell CallbackHelper to cancel posted callbacks. * Interface to tell CallbackHelper to cancel posted callbacks.
*/ */
public static interface CancelCallbackPoller { public static interface CancelCallbackPoller { boolean shouldCancelAllCallbacks(); }
boolean cancelAllCallbacks();
}
// TODO(boliu): Consider removing DownloadInfo and LoginRequestInfo by using native // TODO(boliu): Consider removing DownloadInfo and LoginRequestInfo by using native
// MessageLoop to post directly to AwContents. // MessageLoop to post directly to AwContents.
...@@ -156,7 +154,7 @@ public class AwContentsClientCallbackHelper { ...@@ -156,7 +154,7 @@ public class AwContentsClientCallbackHelper {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
if (mCancelCallbackPoller != null && mCancelCallbackPoller.cancelAllCallbacks()) { if (mCancelCallbackPoller != null && mCancelCallbackPoller.shouldCancelAllCallbacks()) {
removeCallbacksAndMessages(null); removeCallbacksAndMessages(null);
return; return;
} }
...@@ -266,6 +264,10 @@ public class AwContentsClientCallbackHelper { ...@@ -266,6 +264,10 @@ public class AwContentsClientCallbackHelper {
mCancelCallbackPoller = poller; mCancelCallbackPoller = poller;
} }
CancelCallbackPoller getCancelCallbackPoller() {
return mCancelCallbackPoller;
}
public void postOnLoadResource(String url) { public void postOnLoadResource(String url) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_ON_LOAD_RESOURCE, url)); mHandler.sendMessage(mHandler.obtainMessage(MSG_ON_LOAD_RESOURCE, url));
} }
......
...@@ -92,7 +92,7 @@ public class AwContentsClientCallbackHelperTest { ...@@ -92,7 +92,7 @@ public class AwContentsClientCallbackHelperTest {
} }
@Override @Override
public boolean cancelAllCallbacks() { public boolean shouldCancelAllCallbacks() {
mCallbackHelper.notifyCalled(); mCallbackHelper.notifyCalled();
return mCancelled; return mCancelled;
} }
......
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