OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
6 | 6 |
| 7 import android.util.ArrayMap; |
| 8 |
| 9 import org.chromium.android_webview.AwContentsClient; |
7 import org.chromium.base.CalledByNative; | 10 import org.chromium.base.CalledByNative; |
8 import org.chromium.base.JNINamespace; | 11 import org.chromium.base.JNINamespace; |
9 | 12 |
10 /** | 13 /** |
11 * Delegate for handling callbacks. All methods are called on the IO thread. | 14 * Delegate for handling callbacks. All methods are called on the IO thread. |
12 * | 15 * |
13 * You should create a separate instance for every WebContents that requires the | 16 * You should create a separate instance for every WebContents that requires the |
14 * provided functionality. | 17 * provided functionality. |
15 */ | 18 */ |
16 @JNINamespace("android_webview") | 19 @JNINamespace("android_webview") |
17 public interface AwContentsIoThreadClient { | 20 public abstract class AwContentsIoThreadClient { |
18 @CalledByNative | 21 @CalledByNative |
19 public int getCacheMode(); | 22 public abstract int getCacheMode(); |
20 | 23 |
21 @CalledByNative | 24 @CalledByNative |
22 public InterceptedRequestData shouldInterceptRequest(String url, boolean isM
ainFrame); | 25 public abstract boolean shouldBlockContentUrls(); |
23 | 26 |
24 @CalledByNative | 27 @CalledByNative |
25 public boolean shouldBlockContentUrls(); | 28 public abstract boolean shouldBlockFileUrls(); |
26 | 29 |
27 @CalledByNative | 30 @CalledByNative |
28 public boolean shouldBlockFileUrls(); | 31 public abstract boolean shouldBlockNetworkLoads(); |
29 | 32 |
30 @CalledByNative | 33 @CalledByNative |
31 public boolean shouldBlockNetworkLoads(); | 34 public abstract boolean shouldAcceptThirdPartyCookies(); |
32 | 35 |
33 @CalledByNative | 36 @CalledByNative |
34 public boolean shouldAcceptThirdPartyCookies(); | 37 public abstract void onDownloadStart(String url, String userAgent, |
35 | |
36 @CalledByNative | |
37 public void onDownloadStart(String url, String userAgent, | |
38 String contentDisposition, String mimeType, long contentLength); | 38 String contentDisposition, String mimeType, long contentLength); |
39 | 39 |
40 @CalledByNative | 40 @CalledByNative |
41 public void newLoginRequest(String realm, String account, String args); | 41 public abstract void newLoginRequest(String realm, String account, String ar
gs); |
| 42 |
| 43 public abstract AwWebResourceResponse shouldInterceptRequest( |
| 44 AwContentsClient.ShouldInterceptRequestParams params); |
| 45 |
| 46 // Protected methods -------------------------------------------------------
-------------------- |
| 47 |
| 48 @CalledByNative |
| 49 protected AwWebResourceResponse shouldInterceptRequest(String url, boolean i
sMainFrame, |
| 50 boolean hasUserGesture, String method, String[] requestHeaderNames, |
| 51 String[] requestHeaderValues) { |
| 52 AwContentsClient.ShouldInterceptRequestParams params = |
| 53 new AwContentsClient.ShouldInterceptRequestParams(); |
| 54 params.url = url; |
| 55 params.isMainFrame = isMainFrame; |
| 56 params.hasUserGesture = hasUserGesture; |
| 57 params.method = method; |
| 58 params.requestHeaders = new ArrayMap<String, String>(requestHeaderNames.
length); |
| 59 for (int i = 0; i < requestHeaderNames.length; ++i) { |
| 60 params.requestHeaders.put(requestHeaderNames[i], requestHeaderValues
[i]); |
| 61 } |
| 62 return shouldInterceptRequest(params); |
| 63 } |
42 } | 64 } |
OLD | NEW |