summaryrefslogtreecommitdiffstats
path: root/android_webview/java
diff options
context:
space:
mode:
authormkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-14 20:21:45 +0000
committermkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-14 20:21:45 +0000
commita81720f0e0b2f372b10d8f01204547c2573b40e9 (patch)
treea31eb268a27efe5a1a7c8793ad88959a88ae294a /android_webview/java
parent0b07cec5ac1381ced1f5b873866131ca99216db1 (diff)
downloadchromium_src-a81720f0e0b2f372b10d8f01204547c2573b40e9.zip
chromium_src-a81720f0e0b2f372b10d8f01204547c2573b40e9.tar.gz
chromium_src-a81720f0e0b2f372b10d8f01204547c2573b40e9.tar.bz2
[android_webview] Fake onReceivedError callback for intercepted navigations.
In WebViewClassic a failed intercepted navigation would cause the onReceivedError callback to be fired. BUG=180950 Review URL: https://chromiumcodereview.appspot.com/12620004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188171 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/java')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java26
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContentsClientCallbackHelper.java24
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContentsIoThreadClient.java2
3 files changed, 44 insertions, 8 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index dc8c40a..2411657 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -142,32 +142,44 @@ public class AwContents {
@Override
public int getCacheMode() {
- return AwContents.this.mSettings.getCacheMode();
+ return mSettings.getCacheMode();
}
@Override
- public InterceptedRequestData shouldInterceptRequest(final String url) {
+ public InterceptedRequestData shouldInterceptRequest(final String url,
+ boolean isMainFrame) {
InterceptedRequestData interceptedRequestData =
- AwContents.this.mContentsClient.shouldInterceptRequest(url);
+ mContentsClient.shouldInterceptRequest(url);
+
if (interceptedRequestData == null) {
mContentsClient.getCallbackHelper().postOnLoadResource(url);
}
+
+ if (isMainFrame && interceptedRequestData != null &&
+ interceptedRequestData.getData() == null) {
+ // In this case the intercepted URLRequest job will simulate an empty response
+ // which doesn't trigger the onReceivedError callback. For WebViewClassic
+ // compatibility we synthesize that callback. http://crbug.com/180950
+ mContentsClient.getCallbackHelper().postOnReceivedError(
+ ErrorCodeConversionHelper.ERROR_UNKNOWN,
+ null /* filled in by the glue layer */, url);
+ }
return interceptedRequestData;
}
@Override
public boolean shouldBlockContentUrls() {
- return !AwContents.this.mSettings.getAllowContentAccess();
+ return !mSettings.getAllowContentAccess();
}
@Override
public boolean shouldBlockFileUrls() {
- return !AwContents.this.mSettings.getAllowFileAccess();
+ return !mSettings.getAllowFileAccess();
}
@Override
public boolean shouldBlockNetworkLoads() {
- return AwContents.this.mSettings.getBlockNetworkLoads();
+ return mSettings.getBlockNetworkLoads();
}
@Override
@@ -207,7 +219,7 @@ public class AwContents {
// The embedder is also not allowed to intercept POST requests because of
// crbug.com/155250.
} else if (!navigationParams.isPost) {
- ignoreNavigation = AwContents.this.mContentsClient.shouldIgnoreNavigation(url);
+ ignoreNavigation = mContentsClient.shouldIgnoreNavigation(url);
}
// The existing contract is that shouldIgnoreNavigation callbacks are delivered before
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsClientCallbackHelper.java b/android_webview/java/src/org/chromium/android_webview/AwContentsClientCallbackHelper.java
index 84ce826..8dbd571 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContentsClientCallbackHelper.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentsClientCallbackHelper.java
@@ -53,10 +53,23 @@ class AwContentsClientCallbackHelper {
}
}
+ private static class OnReceivedErrorInfo {
+ final int mErrorCode;
+ final String mDescription;
+ final String mFailingUrl;
+
+ OnReceivedErrorInfo(int errorCode, String description, String failingUrl) {
+ mErrorCode = errorCode;
+ mDescription = description;
+ mFailingUrl = failingUrl;
+ }
+ }
+
private final static int MSG_ON_LOAD_RESOURCE = 1;
private final static int MSG_ON_PAGE_STARTED = 2;
private final static int MSG_ON_DOWNLOAD_START = 3;
private final static int MSG_ON_RECEIVED_LOGIN_REQUEST = 4;
+ private final static int MSG_ON_RECEIVED_ERROR = 5;
private final AwContentsClient mContentsClient;
@@ -85,6 +98,12 @@ class AwContentsClientCallbackHelper {
mContentsClient.onReceivedLoginRequest(info.mRealm, info.mAccount, info.mArgs);
break;
}
+ case MSG_ON_RECEIVED_ERROR: {
+ OnReceivedErrorInfo info = (OnReceivedErrorInfo) msg.obj;
+ mContentsClient.onReceivedError(info.mErrorCode, info.mDescription,
+ info.mFailingUrl);
+ break;
+ }
default:
throw new IllegalStateException(
"AwContentsClientCallbackHelper: unhandled message " + msg.what);
@@ -115,4 +134,9 @@ class AwContentsClientCallbackHelper {
LoginRequestInfo info = new LoginRequestInfo(realm, account, args);
mHandler.sendMessage(mHandler.obtainMessage(MSG_ON_RECEIVED_LOGIN_REQUEST, info));
}
+
+ public void postOnReceivedError(int errorCode, String description, String failingUrl) {
+ OnReceivedErrorInfo info = new OnReceivedErrorInfo(errorCode, description, failingUrl);
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_ON_RECEIVED_ERROR, info));
+ }
}
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsIoThreadClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentsIoThreadClient.java
index 29f09bd..3d3dd61 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContentsIoThreadClient.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentsIoThreadClient.java
@@ -19,7 +19,7 @@ public interface AwContentsIoThreadClient {
public int getCacheMode();
@CalledByNative
- public InterceptedRequestData shouldInterceptRequest(String url);
+ public InterceptedRequestData shouldInterceptRequest(String url, boolean isMainFrame);
@CalledByNative
public boolean shouldBlockContentUrls();