1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.webkit; 18 19 import android.compat.annotation.UnsupportedAppUsage; 20 import android.os.Build; 21 22 import java.io.InputStream; 23 import java.util.Map; 24 25 /** 26 * This class encapsulates the content generated by a plugin. The 27 * data itself is meant to be loaded into webkit via the 28 * PluginContentLoader class, which needs to be able to construct an 29 * HTTP response. For this, it needs a stream with the response body, 30 * the length of the body, the response headers, and the response 31 * status code. The PluginData class is the container for all these 32 * parts. 33 * 34 * @hide 35 * @deprecated This class was intended to be used by Gears. Since Gears was 36 * deprecated, so is this class. 37 */ 38 @Deprecated 39 public final class PluginData { 40 /** 41 * The content stream. 42 */ 43 private InputStream mStream; 44 /** 45 * The content length. 46 */ 47 private long mContentLength; 48 /** 49 * The associated HTTP response headers stored as a map of 50 * lowercase header name to [ unmodified header name, header value]. 51 * TODO: This design was always a hack. Remove (involves updating 52 * the Gears C++ side). 53 */ 54 private Map<String, String[]> mHeaders; 55 56 /** 57 * The associated HTTP response code. 58 */ 59 private int mStatusCode; 60 61 /** 62 * Creates a PluginData instance. 63 * 64 * @param stream The stream that supplies content for the plugin. 65 * @param length The length of the plugin content. 66 * @param headers The response headers. Map of 67 * lowercase header name to [ unmodified header name, header value] 68 * @param length The HTTP response status code. 69 * 70 * @hide 71 * @deprecated This class was intended to be used by Gears. Since Gears was 72 * deprecated, so is this class. 73 */ 74 @Deprecated 75 @UnsupportedAppUsage PluginData( InputStream stream, long length, Map<String, String[]> headers, int code)76 public PluginData( 77 InputStream stream, 78 long length, 79 Map<String, String[]> headers, 80 int code) { 81 mStream = stream; 82 mContentLength = length; 83 mHeaders = headers; 84 mStatusCode = code; 85 } 86 87 /** 88 * Returns the input stream that contains the plugin content. 89 * 90 * @return An InputStream instance with the plugin content. 91 * 92 * @hide 93 * @deprecated This class was intended to be used by Gears. Since Gears was 94 * deprecated, so is this class. 95 */ 96 @Deprecated 97 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getInputStream()98 public InputStream getInputStream() { 99 return mStream; 100 } 101 102 /** 103 * Returns the length of the plugin content. 104 * 105 * @return the length of the plugin content. 106 * 107 * @hide 108 * @deprecated This class was intended to be used by Gears. Since Gears was 109 * deprecated, so is this class. 110 */ 111 @Deprecated 112 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getContentLength()113 public long getContentLength() { 114 return mContentLength; 115 } 116 117 /** 118 * Returns the HTTP response headers associated with the plugin 119 * content. 120 * 121 * @return A Map<String, String[]> containing all headers. The 122 * mapping is 'lowercase header name' to ['unmodified header 123 * name', header value]. 124 * 125 * @hide 126 * @deprecated This class was intended to be used by Gears. Since Gears was 127 * deprecated, so is this class. 128 */ 129 @Deprecated 130 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getHeaders()131 public Map<String, String[]> getHeaders() { 132 return mHeaders; 133 } 134 135 /** 136 * Returns the HTTP status code for the response. 137 * 138 * @return The HTTP statue code, e.g 200. 139 * 140 * @hide 141 * @deprecated This class was intended to be used by Gears. Since Gears was 142 * deprecated, so is this class. 143 */ 144 @Deprecated 145 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getStatusCode()146 public int getStatusCode() { 147 return mStatusCode; 148 } 149 } 150