1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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_
45 #include "nsIPlugin.h"
46 #include "nsIPluginInstance.h"
47 #include "nsIPluginTagInfo.h"
48 #include "nsPIDOMWindow.h"
49 #include "nsIPluginInstanceOwner.h"
51 #include "mozilla/TimeStamp.h"
53 #include "npfunctions.h"
54 #include "mozilla/PluginLibrary.h"
56 class nsNPAPIPluginStreamListener
;
64 nsCOMPtr
<nsITimer
> timer
;
65 void (*callback
)(NPP npp
, uint32_t timerID
);
68 class nsNPAPIPluginInstance
: public nsIPluginInstance
71 typedef mozilla::PluginLibrary PluginLibrary
;
75 NS_DECL_NSIPLUGININSTANCE
77 nsresult
GetNPP(NPP
* aNPP
);
79 // Return the callbacks for the plugin instance.
80 nsresult
GetCallbacks(const NPPluginFuncs
** aCallbacks
);
82 NPError
SetWindowless(PRBool aWindowless
);
84 NPError
SetWindowlessLocal(PRBool aWindowlessLocal
);
86 NPError
SetTransparent(PRBool aTransparent
);
88 NPError
SetWantsAllNetworkStreams(PRBool aWantsAllNetworkStreams
);
91 void SetDrawingModel(NPDrawingModel aModel
);
92 void SetEventModel(NPEventModel aModel
);
95 nsresult
NewNotifyStream(nsIPluginStreamListener
** listener
,
100 nsNPAPIPluginInstance(NPPluginFuncs
* callbacks
, PluginLibrary
* aLibrary
);
102 // Use Release() to destroy this
103 virtual ~nsNPAPIPluginInstance();
105 // Indicates whether the plugin is running normally.
107 return RUNNING
== mRunning
;
110 // Indicates whether the plugin is running normally or being shut down
111 bool CanFireNotifications() {
112 return mRunning
== RUNNING
|| mRunning
== DESTROYING
;
115 // return is only valid when the plugin is not running
116 mozilla::TimeStamp
LastStopTime();
118 // cache this NPAPI plugin
119 nsresult
SetCached(PRBool aCache
);
121 already_AddRefed
<nsPIDOMWindow
> GetDOMWindow();
123 nsresult
PrivateModeStateChanged();
125 nsresult
GetDOMElement(nsIDOMElement
* *result
);
127 nsNPAPITimer
* TimerWithID(uint32_t id
, PRUint32
* index
);
128 uint32_t ScheduleTimer(uint32_t interval
, NPBool repeat
, void (*timerFunc
)(NPP npp
, uint32_t timerID
));
129 void UnscheduleTimer(uint32_t timerID
);
130 NPError
PopUpContextMenu(NPMenu
* menu
);
131 NPBool
ConvertPoint(double sourceX
, double sourceY
, NPCoordinateSpace sourceSpace
, double *destX
, double *destY
, NPCoordinateSpace destSpace
);
133 nsresult
InitializePlugin();
135 nsresult
GetTagType(nsPluginTagType
*result
);
136 nsresult
GetAttributes(PRUint16
& n
, const char*const*& names
,
137 const char*const*& values
);
138 nsresult
GetParameters(PRUint16
& n
, const char*const*& names
,
139 const char*const*& values
);
140 nsresult
GetMode(PRInt32
*result
);
142 // A pointer to the plugin's callback functions. This information
143 // is actually stored in the plugin class (<b>nsPluginClass</b>),
144 // and is common for all plugins of the class.
145 NPPluginFuncs
* mCallbacks
;
147 // The structure used to communicate between the plugin instance and
152 NPDrawingModel mDrawingModel
;
162 // these are used to store the windowless properties
163 // which the browser will later query
164 PRPackedBool mWindowless
;
165 PRPackedBool mWindowlessLocal
;
166 PRPackedBool mTransparent
;
167 PRPackedBool mCached
;
168 PRPackedBool mWantsAllNetworkStreams
;
171 // True while creating the plugin, or calling NPP_SetWindow() on it.
172 PRPackedBool mInPluginInitCall
;
173 PluginLibrary
* mLibrary
;
174 nsTArray
<nsNPAPIPluginStreamListener
*> mStreamListeners
;
177 nsTArray
<PopupControlState
> mPopupStates
;
181 // Weak pointer to the owner. The owner nulls this out (by calling
182 // InvalidateOwner()) when it's no longer our owner.
183 nsIPluginInstanceOwner
*mOwner
;
185 nsTArray
<nsNPAPITimer
*> mTimers
;
187 // non-null during a HandleEvent call
188 void* mCurrentPluginEvent
;
190 // Timestamp for the last time this plugin was stopped.
191 // This is only valid when the plugin is actually stopped!
192 mozilla::TimeStamp mStopTime
;
195 #endif // nsNPAPIPluginInstance_h_