Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / android_webview / java / src / org / chromium / android_webview / AwContentsIoThreadClient.java
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
3 // found in the LICENSE file.
4
5 package org.chromium.android_webview;
6
7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace;
9
10 import java.util.HashMap;
11
12 /**
13  * Delegate for handling callbacks. All methods are called on the IO thread.
14  *
15  * You should create a separate instance for every WebContents that requires the
16  * provided functionality.
17  */
18 @JNINamespace("android_webview")
19 public abstract class AwContentsIoThreadClient {
20     @CalledByNative
21     public abstract int getCacheMode();
22
23     @CalledByNative
24     public abstract boolean shouldBlockContentUrls();
25
26     @CalledByNative
27     public abstract boolean shouldBlockFileUrls();
28
29     @CalledByNative
30     public abstract boolean shouldBlockNetworkLoads();
31
32     @CalledByNative
33     public abstract boolean shouldAcceptThirdPartyCookies();
34
35     @CalledByNative
36     public abstract void onDownloadStart(String url, String userAgent,
37             String contentDisposition, String mimeType, long contentLength);
38
39     @CalledByNative
40     public abstract void newLoginRequest(String realm, String account, String args);
41
42     public abstract AwWebResourceResponse shouldInterceptRequest(
43             AwContentsClient.ShouldInterceptRequestParams params);
44
45     // Protected methods ---------------------------------------------------------------------------
46
47     @CalledByNative
48     protected AwWebResourceResponse shouldInterceptRequest(String url, boolean isMainFrame,
49             boolean hasUserGesture, String method, String[] requestHeaderNames,
50             String[] requestHeaderValues) {
51         AwContentsClient.ShouldInterceptRequestParams params =
52                 new AwContentsClient.ShouldInterceptRequestParams();
53         params.url = url;
54         params.isMainFrame = isMainFrame;
55         params.hasUserGesture = hasUserGesture;
56         params.method = method;
57         params.requestHeaders = new HashMap<String, String>(requestHeaderNames.length);
58         for (int i = 0; i < requestHeaderNames.length; ++i) {
59             params.requestHeaders.put(requestHeaderNames[i], requestHeaderValues[i]);
60         }
61         return shouldInterceptRequest(params);
62     }
63 }