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
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/
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
15 * The Original Code is mozilla.org code.
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.
23 * Tim Copperfield <timecop@network.email.ne.jp>
24 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef nsNPAPIPluginInstance_h_
41 #define nsNPAPIPluginInstance_h_
44 #include "nsVoidArray.h"
45 #include "nsIPlugin.h"
46 #include "nsIPluginInstance.h"
47 #include "nsIPluginInstancePeer.h"
48 #include "nsIPluginTagInfo2.h"
49 #include "nsIScriptablePlugin.h"
50 #include "nsIPluginInstanceInternal.h"
52 #include "npfunctions.h"
55 class nsNPAPIPluginStreamListener
;
58 struct nsInstanceStream
60 nsInstanceStream
*mNext
;
61 nsNPAPIPluginStreamListener
*mPluginStreamListener
;
67 class nsNPAPIPluginInstance
: public nsIPluginInstance
,
68 public nsIScriptablePlugin
,
69 public nsIPluginInstanceInternal
74 NS_DECL_NSIPLUGININSTANCE
75 NS_DECL_NSISCRIPTABLEPLUGIN
77 // nsIPluginInstanceInternal methods
79 virtual JSObject
*GetJSObject(JSContext
*cx
);
81 virtual nsresult
GetFormValue(nsAString
& aValue
);
83 virtual void PushPopupsEnabledState(PRBool aEnabled
);
84 virtual void PopPopupsEnabledState();
86 virtual PRUint16
GetPluginAPIVersion();
88 virtual void DefineJavaProperties();
90 // nsNPAPIPluginInstance-specific methods
92 // Return the 4.x-style interface object.
93 nsresult
GetNPP(NPP
* aNPP
);
95 // Return the callbacks for the plugin instance.
96 nsresult
GetCallbacks(const NPPluginFuncs
** aCallbacks
);
98 NPError
SetWindowless(PRBool aWindowless
);
100 NPError
SetTransparent(PRBool aTransparent
);
102 NPError
SetWantsAllNetworkStreams(PRBool aWantsAllNetworkStreams
);
105 void SetDrawingModel(NPDrawingModel aModel
);
106 NPDrawingModel
GetDrawingModel();
109 nsresult
NewNotifyStream(nsIPluginStreamListener
** listener
,
114 // Construct a new 4.x plugin instance with the specified peer
116 nsNPAPIPluginInstance(NPPluginFuncs
* callbacks
, PRLibrary
* aLibrary
);
118 // Use Release() to destroy this
119 virtual ~nsNPAPIPluginInstance(void);
121 // returns the state of mStarted
122 PRBool
IsStarted(void);
124 // cache this 4.x plugin like an XPCOM plugin
125 nsresult
SetCached(PRBool aCache
) { mCached
= aCache
; return NS_OK
; }
127 // Non-refcounting accessor for faster access to the peer.
128 nsIPluginInstancePeer
*Peer()
133 already_AddRefed
<nsPIDOMWindow
> GetDOMWindow();
137 nsresult
InitializePlugin(nsIPluginInstancePeer
* peer
);
139 // Calls NPP_GetValue
140 nsresult
GetValueInternal(NPPVariable variable
, void* value
);
142 // The plugin instance peer for this instance.
143 nsCOMPtr
<nsIPluginInstancePeer
> mPeer
;
145 // A pointer to the plugin's callback functions. This information
146 // is actually stored in the plugin class (<b>nsPluginClass</b>),
147 // and is common for all plugins of the class.
148 NPPluginFuncs
* fCallbacks
;
150 // The 4.x-style structure used to communicate between the plugin
151 // instance and the browser.
155 NPDrawingModel mDrawingModel
;
158 // these are used to store the windowless properties
159 // which the browser will later query
160 PRPackedBool mWindowless
;
161 PRPackedBool mTransparent
;
162 PRPackedBool mStarted
;
163 PRPackedBool mCached
;
164 PRPackedBool mIsJavaPlugin
;
165 PRPackedBool mWantsAllNetworkStreams
;
168 // True while creating the plugin, or calling NPP_SetWindow() on it.
169 PRPackedBool mInPluginInitCall
;
171 nsInstanceStream
*mStreams
;
173 nsVoidArray mPopupStates
;
176 #endif // nsNPAPIPluginInstance_h_