Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwWebResourceResponse.java

Issue 976403003: Make shouldInterceptRequest thinner in glue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.webkit.WebResourceResponse;
8
7 import org.chromium.base.CalledByNative; 9 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace; 10 import org.chromium.base.JNINamespace;
9 import org.chromium.base.VisibleForTesting; 11 import org.chromium.base.VisibleForTesting;
10 12
11 import java.io.InputStream; 13 import java.io.InputStream;
12 import java.util.Map; 14 import java.util.Map;
13 15
14 /** 16 /**
15 * The response information that is to be returned for a particular resource fet ch. 17 * The response information that is to be returned for a particular resource fet ch.
16 */ 18 */
17 @JNINamespace("android_webview") 19 @JNINamespace("android_webview")
18 public class AwWebResourceResponse { 20 public class AwWebResourceResponse {
19 private String mMimeType; 21 private String mMimeType;
20 private String mCharset; 22 private String mCharset;
21 private InputStream mData; 23 private InputStream mData;
22 private int mStatusCode; 24 private int mStatusCode;
23 private String mReasonPhrase; 25 private String mReasonPhrase;
24 private String[] mResponseHeaderNames; 26 private String[] mResponseHeaderNames;
25 private String[] mResponseHeaderValues; 27 private String[] mResponseHeaderValues;
26 28
27 public AwWebResourceResponse(String mimeType, String encoding, InputStream d ata) { 29 public AwWebResourceResponse(String mimeType, String encoding, InputStream d ata) {
28 mMimeType = mimeType; 30 mMimeType = mimeType;
29 mCharset = encoding; 31 mCharset = encoding;
30 mData = data; 32 mData = data;
31 } 33 }
32 34
33 public AwWebResourceResponse(String mimeType, String encoding, InputStream d ata, 35 @VisibleForTesting
34 int statusCode, String reasonPhrase, Map<String, String> responseHea ders) { 36 public AwWebResourceResponse(String mimeType, String encoding, InputStream d ata, int statusCode,
37 String reasonPhrase, Map<String, String> responseHeaders) {
35 this(mimeType, encoding, data); 38 this(mimeType, encoding, data);
36 39
37 mStatusCode = statusCode; 40 mStatusCode = statusCode;
38 mReasonPhrase = reasonPhrase; 41 mReasonPhrase = reasonPhrase;
39 42
40 if (responseHeaders != null) { 43 if (responseHeaders != null) {
41 mResponseHeaderNames = new String[responseHeaders.size()]; 44 mResponseHeaderNames = new String[responseHeaders.size()];
42 mResponseHeaderValues = new String[responseHeaders.size()]; 45 mResponseHeaderValues = new String[responseHeaders.size()];
43 int i = 0; 46 int i = 0;
44 for (Map.Entry<String, String> entry : responseHeaders.entrySet()) { 47 for (Map.Entry<String, String> entry : responseHeaders.entrySet()) {
45 mResponseHeaderNames[i] = entry.getKey(); 48 mResponseHeaderNames[i] = entry.getKey();
46 mResponseHeaderValues[i] = entry.getValue(); 49 mResponseHeaderValues[i] = entry.getValue();
47 i++; 50 i++;
48 } 51 }
49 } 52 }
50 } 53 }
51 54
55 public AwWebResourceResponse(WebResourceResponse response) {
56 this(response.getMimeType(), response.getEncoding(), response.getData(),
57 response.getStatusCode(), response.getReasonPhrase(),
58 response.getResponseHeaders());
59 }
60
52 @VisibleForTesting 61 @VisibleForTesting
53 @CalledByNative 62 @CalledByNative
54 public String getMimeType() { 63 public String getMimeType() {
55 return mMimeType; 64 return mMimeType;
56 } 65 }
57 66
58 @CalledByNative 67 @CalledByNative
59 private String getCharset() { 68 private String getCharset() {
60 return mCharset; 69 return mCharset;
61 } 70 }
(...skipping 17 matching lines...) Expand all
79 @CalledByNative 88 @CalledByNative
80 private String[] getResponseHeaderNames() { 89 private String[] getResponseHeaderNames() {
81 return mResponseHeaderNames; 90 return mResponseHeaderNames;
82 } 91 }
83 92
84 @CalledByNative 93 @CalledByNative
85 private String[] getResponseHeaderValues() { 94 private String[] getResponseHeaderValues() {
86 return mResponseHeaderValues; 95 return mResponseHeaderValues;
87 } 96 }
88 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698