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