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 
21 import java.io.InputStream;
22 import java.util.Map;
23 
24 /**
25  * This class encapsulates the content generated by a plugin.  The
26  * data itself is meant to be loaded into webkit via the
27  * PluginContentLoader class, which needs to be able to construct an
28  * HTTP response. For this, it needs a stream with the response body,
29  * the length of the body, the response headers, and the response
30  * status code. The PluginData class is the container for all these
31  * parts.
32  *
33  * @hide
34  * @deprecated This class was intended to be used by Gears. Since Gears was
35  * deprecated, so is this class.
36  */
37 @Deprecated
38 public final class PluginData {
39     /**
40      * The content stream.
41      */
42     private InputStream mStream;
43     /**
44      * The content length.
45      */
46     private long mContentLength;
47     /**
48      * The associated HTTP response headers stored as a map of
49      * lowercase header name to [ unmodified header name, header value].
50      * TODO: This design was always a hack. Remove (involves updating
51      * the Gears C++ side).
52      */
53     private Map<String, String[]> mHeaders;
54 
55     /**
56      * The associated HTTP response code.
57      */
58     private int mStatusCode;
59 
60     /**
61      * Creates a PluginData instance.
62      *
63      * @param stream The stream that supplies content for the plugin.
64      * @param length The length of the plugin content.
65      * @param headers The response headers. Map of
66      * lowercase header name to [ unmodified header name, header value]
67      * @param length The HTTP response status code.
68      *
69      * @hide
70      * @deprecated This class was intended to be used by Gears. Since Gears was
71      * deprecated, so is this class.
72      */
73     @Deprecated
74     @UnsupportedAppUsage
PluginData( InputStream stream, long length, Map<String, String[]> headers, int code)75     public PluginData(
76             InputStream stream,
77             long length,
78             Map<String, String[]> headers,
79             int code) {
80         mStream = stream;
81         mContentLength = length;
82         mHeaders = headers;
83         mStatusCode = code;
84     }
85 
86     /**
87      * Returns the input stream that contains the plugin content.
88      *
89      * @return An InputStream instance with the plugin content.
90      *
91      * @hide
92      * @deprecated This class was intended to be used by Gears. Since Gears was
93      * deprecated, so is this class.
94      */
95     @Deprecated
96     @UnsupportedAppUsage
getInputStream()97     public InputStream getInputStream() {
98         return mStream;
99     }
100 
101     /**
102      * Returns the length of the plugin content.
103      *
104      * @return the length of the plugin content.
105      *
106      * @hide
107      * @deprecated This class was intended to be used by Gears. Since Gears was
108      * deprecated, so is this class.
109      */
110     @Deprecated
111     @UnsupportedAppUsage
getContentLength()112     public long getContentLength() {
113         return mContentLength;
114     }
115 
116     /**
117      * Returns the HTTP response headers associated with the plugin
118      * content.
119      *
120      * @return A Map<String, String[]> containing all headers. The
121      * mapping is 'lowercase header name' to ['unmodified header
122      * name', header value].
123      *
124      * @hide
125      * @deprecated This class was intended to be used by Gears. Since Gears was
126      * deprecated, so is this class.
127      */
128     @Deprecated
129     @UnsupportedAppUsage
getHeaders()130     public Map<String, String[]> getHeaders() {
131         return mHeaders;
132     }
133 
134     /**
135      * Returns the HTTP status code for the response.
136      *
137      * @return The HTTP statue code, e.g 200.
138      *
139      * @hide
140      * @deprecated This class was intended to be used by Gears. Since Gears was
141      * deprecated, so is this class.
142      */
143     @Deprecated
144     @UnsupportedAppUsage
getStatusCode()145     public int getStatusCode() {
146         return mStatusCode;
147     }
148 }
149