OLD | NEW |
(Empty) | |
| 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.io.InputStream; |
| 11 import java.util.Map; |
| 12 |
| 13 /** |
| 14 * The response information that is to be returned for a particular resource fet
ch. |
| 15 */ |
| 16 @JNINamespace("android_webview") |
| 17 public class AwWebResourceResponse { |
| 18 private String mMimeType; |
| 19 private String mCharset; |
| 20 private InputStream mData; |
| 21 private int mStatusCode; |
| 22 private String mReasonPhrase; |
| 23 private String[] mResponseHeaderNames; |
| 24 private String[] mResponseHeaderValues; |
| 25 |
| 26 public AwWebResourceResponse(String mimeType, String encoding, InputStream d
ata) { |
| 27 mMimeType = mimeType; |
| 28 mCharset = encoding; |
| 29 mData = data; |
| 30 } |
| 31 |
| 32 public AwWebResourceResponse(String mimeType, String encoding, InputStream d
ata, |
| 33 int statusCode, String reasonPhrase, Map<String, String> responseHea
ders) { |
| 34 this(mimeType, encoding, data); |
| 35 |
| 36 mStatusCode = statusCode; |
| 37 mReasonPhrase = reasonPhrase; |
| 38 |
| 39 mResponseHeaderNames = new String[responseHeaders.size()]; |
| 40 mResponseHeaderValues = new String[responseHeaders.size()]; |
| 41 int i = 0; |
| 42 for (Map.Entry<String, String> entry : responseHeaders.entrySet()) { |
| 43 mResponseHeaderNames[i] = entry.getKey(); |
| 44 mResponseHeaderValues[i] = entry.getValue(); |
| 45 i++; |
| 46 } |
| 47 } |
| 48 |
| 49 @CalledByNative |
| 50 public String getMimeType() { |
| 51 return mMimeType; |
| 52 } |
| 53 |
| 54 @CalledByNative |
| 55 public String getCharset() { |
| 56 return mCharset; |
| 57 } |
| 58 |
| 59 @CalledByNative |
| 60 public InputStream getData() { |
| 61 return mData; |
| 62 } |
| 63 |
| 64 @CalledByNative |
| 65 public int getStatusCode() { |
| 66 return mStatusCode; |
| 67 } |
| 68 |
| 69 @CalledByNative |
| 70 public String getReasonPhrase() { |
| 71 return mReasonPhrase; |
| 72 } |
| 73 |
| 74 @CalledByNative |
| 75 public String[] getResponseHeaderNames() { |
| 76 return mResponseHeaderNames; |
| 77 } |
| 78 |
| 79 @CalledByNative |
| 80 public String[] getResponseHeaderValues() { |
| 81 return mResponseHeaderValues; |
| 82 } |
| 83 } |
OLD | NEW |