FreeWRL / FreeX3D 4.3.0
nsIPluginHost.idl
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#include "nspluginroot.idl"
39#include "nsISupports.idl"
40#include "nsIPluginInstanceOwner.idl"
41#include "nsIStreamListener.idl"
42#include "nsIStringStream.idl"
43#include "nsIPluginTag.idl"
44
45%{C++
46#include "nsPluginNativeWindow.h"
47#include "nsplugindefs.h"
48#ifdef MOZILLA_INTERNAL_API
49#include "nsString.h"
50#include "nsNetUtil.h"
51#endif
52#include "prlink.h" // for PRLibrary
53
54#define MOZ_PLUGIN_HOST_CONTRACTID \
55 "@mozilla.org/plugin/host;1"
56%}
57
58interface nsIPlugin;
59interface nsIURI;
60interface nsIDOMPlugin;
61interface nsIChannel;
63
64[ptr] native PRLibraryPtr(PRLibrary);
65[ref] native nsIStreamListenerRef(nsIStreamListener *);
66[ptr] native nsPluginNativeWindowPtr(nsPluginNativeWindow);
67
68[scriptable, uuid(30C7C529-B05C-4950-B5B8-9AF673E46521)]
69interface nsIPluginHost : nsISupports
70{
71 [noscript] void init();
72
73 [noscript] void destroy();
74
75 [noscript] void loadPlugins();
76
84 void reloadPlugins(in boolean reloadPages);
85
86 [noscript] nsIPlugin getPlugin(in string aMimeType);
87
88 [noscript] void instantiateEmbeddedPlugin(in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner);
89
90 [noscript] void instantiateFullPagePlugin(in string aMimeType, in nsIURI aURI, in nsIStreamListenerRef aStreamListener, in nsIPluginInstanceOwner aOwner);
91
97 [noscript] nsIStreamListener instantiatePluginForChannel(in nsIChannel aChannel, in nsIPluginInstanceOwner aOwner);
98
99 [noscript] void setUpPluginInstance(in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner);
100
101 // The return code is NS_OK if the plugin is enabled,
102 // NS_ERROR_PLUGIN_DISABLED if the plugin is explicitly disabled, and
103 // NS_ERROR_FAILURE if there is no plugin for this type.
104 [noscript] void isPluginEnabledForType(in string aMimeType);
105
106 // The return code is NS_OK if the plugin is enabled and NS_ERROR_FAILURE if
107 // the plugin is explicitly disabled or there is no plugin.
108 [noscript] void isPluginEnabledForExtension(in string aExtension, in constCharStarRef aMimeType);
109
110 [noscript] readonly attribute unsigned long pluginCount;
111
112 [noscript] void getPlugins(in unsigned long aPluginCount, out /*array*/ nsIDOMPlugin aPluginArray);
113
114 void getPluginTags(out unsigned long aPluginCount,
115 [retval, array, size_is(aPluginCount)] out nsIPluginTag aResults);
116
117 [noscript] void stopPluginInstance(in nsIPluginInstance aInstance);
118
119 [noscript] void handleBadPlugin(in PRLibraryPtr aLibrary, in nsIPluginInstance instance);
120
142%{C++
143 NS_IMETHOD
144 GetURL(nsISupports* pluginInst,
145 const char* url,
146 const char* target = NULL,
147 nsIPluginStreamListener* streamListener = NULL,
148 const char* altHost = NULL,
149 const char* referrer = NULL,
150 PRBool forceJSEnabled = PR_FALSE) = 0;
151%}
152
184%{C++
185 NS_IMETHOD
186 PostURL(nsISupports* pluginInst,
187 const char* url,
188 PRUint32 postDataLen,
189 const char* postData,
190 PRBool isFile = PR_FALSE,
191 const char* target = NULL,
192 nsIPluginStreamListener* streamListener = NULL,
193 const char* altHost = NULL,
194 const char* referrer = NULL,
195 PRBool forceJSEnabled = PR_FALSE,
196 PRUint32 postHeadersLength = 0,
197 const char* postHeaders = NULL) = 0;
198%}
199
213 void findProxyForURL(in string aURL, out string aResult);
214
215 [noscript] void UserAgent(in nativeChar resultingAgentString);
216
220 [noscript] void setIsScriptableInstance(in nsIPluginInstance aInstance, in boolean aScriptable);
221
245 [noscript] void parsePostBufferToFixHeaders(in string aInPostData,
246 in unsigned long aInPostDataLen,
247 out string aOutPostData,
248 out unsigned long aOutPostDataLen);
249
253 [noscript] void createTmpFileToPost(in string aPostDataURL, out string aTmpFileName);
254
258 [noscript] void newPluginNativeWindow(out nsPluginNativeWindowPtr aPluginNativeWindow);
259
263 [noscript] void deletePluginNativeWindow(in nsPluginNativeWindowPtr aPluginNativeWindow);
264
273
281 [noscript] void getPluginName(in nsIPluginInstance aInstance, [shared] out string aPluginName);
282
289};
290
291%{C++
292#ifdef MOZILLA_INTERNAL_API
303inline nsresult
304NS_NewPluginPostDataStream(nsIInputStream **result,
305 const char *data,
306 PRUint32 contentLength,
307 PRBool isFile = PR_FALSE,
308 PRBool headers = PR_FALSE)
309{
310 nsresult rv = NS_ERROR_UNEXPECTED;
311 if (!data)
312 return rv;
313
314 if (!isFile) { // do raw data case first
315 if (contentLength < 1)
316 return rv;
317
318 char *buf = (char*) data;
319 if (headers) {
320 // in assumption we got correctly formated headers just passed in
321 if (!(buf = (char*)nsMemory::Alloc(contentLength)))
322 return NS_ERROR_OUT_OF_MEMORY;
323 memcpy(buf, data, contentLength);
324 }
325 nsCOMPtr<nsIStringInputStream> sis = do_CreateInstance("@mozilla.org/io/string-input-stream;1",&rv);
326 if (NS_SUCCEEDED(rv)) {
327 sis->AdoptData(buf, contentLength); // let the string stream manage our data
328 rv = CallQueryInterface(sis, result);
329 }
330 else if (headers) {
331 nsMemory::Free(buf); // Cleanup the memory if the data was copied.
332 }
333 } else {
334 nsCOMPtr<nsILocalFile> file; // tmp file will be deleted on release of stream
335 nsCOMPtr<nsIInputStream> fileStream;
336 if (NS_SUCCEEDED(rv = NS_NewNativeLocalFile(nsDependentCString(data), PR_FALSE, getter_AddRefs(file))) &&
337 NS_SUCCEEDED(rv = NS_NewLocalFileInputStream(getter_AddRefs(fileStream),
338 file,
339 PR_RDONLY,
340 0600,
341 nsIFileInputStream::DELETE_ON_CLOSE |
342 nsIFileInputStream::CLOSE_ON_EOF))) {
343 // wrap the file stream with a buffered input stream
344 return NS_NewBufferedInputStream(result, fileStream, 8192);
345 }
346 }
347 return rv;
348}
349#endif
350%}
base class for native plugin window implementations
NS_IMETHOD GetURL(nsISupports *pluginInst, const char *url, const char *target=NULL, nsIPluginStreamListener *streamListener=NULL, const char *altHost=NULL, const char *referrer=NULL, PRBool forceJSEnabled=PR_FALSE)=0
Fetches a URL.
void newPluginNativeWindow(out nsPluginNativeWindowPtr aPluginNativeWindow)
Creates a new plugin native window object.
void setIsScriptableInstance(in nsIPluginInstance aInstance, in boolean aScriptable)
To notify the plugin manager that the plugin created a script object.
void findProxyForURL(in string aURL, out string aResult)
Returns the proxy info for a given URL.
void createTmpFileToPost(in string aPostDataURL, out string aTmpFileName)
To create tmp file with Content len header in, it will use by http POST.
void instantiateDummyJavaPlugin(in nsIPluginInstanceOwner aOwner)
Instantiate a "dummy" java plugin if a java plugin that supports NPRuntime is installed.
nsIPluginTag getPluginTagForInstance(in nsIPluginInstance aInstance)
Get the plugin tag associated with a given plugin instance.
void reloadPlugins(in boolean reloadPages)
Causes the plugins directory to be searched again for new plugin libraries.
void deletePluginNativeWindow(in nsPluginNativeWindowPtr aPluginNativeWindow)
Deletes plugin native window object created by NewPluginNativeWindow.
void parsePostBufferToFixHeaders(in string aInPostData, in unsigned long aInPostDataLen, out string aOutPostData, out unsigned long aOutPostDataLen)
This method parses post buffer to find out case insensitive "Content-length" string and CR or LF some...
NS_IMETHOD PostURL(nsISupports *pluginInst, const char *url, PRUint32 postDataLen, const char *postData, PRBool isFile=PR_FALSE, const char *target=NULL, nsIPluginStreamListener *streamListener=NULL, const char *altHost=NULL, const char *referrer=NULL, PRBool forceJSEnabled=PR_FALSE, PRUint32 postHeadersLength=0, const char *postHeaders=NULL)=0
Posts to a URL with post data and/or post headers.
nsIStreamListener instantiatePluginForChannel(in nsIChannel aChannel, in nsIPluginInstanceOwner aOwner)
Instantiate an embedded plugin for an existing channel.
void getPluginName(in nsIPluginInstance aInstance, [shared] out string aPluginName)
Get the plugin name for the plugin instance.