1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Mozilla Plugin App.
18 * The Initial Developer of the Original Code is
19 * Ben Turner <bent.mozilla@gmail.com>
20 * Portions created by the Initial Developer are Copyright (C) 2009
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef dom_plugins_PluginScriptableObjectParent_h
40 #define dom_plugins_PluginScriptableObjectParent_h 1
42 #include "mozilla/plugins/PPluginScriptableObjectParent.h"
45 #include "npfunctions.h"
46 #include "npruntime.h"
51 class PluginInstanceParent
;
52 class PluginScriptableObjectParent
;
53 class PPluginIdentifierParent
;
55 struct ParentNPObject
: NPObject
58 : NPObject(), parent(NULL
), invalidated(false) { }
60 // |parent| is always valid as long as the actor is alive. Once the actor is
61 // destroyed this will be set to null.
62 PluginScriptableObjectParent
* parent
;
66 class PluginScriptableObjectParent
: public PPluginScriptableObjectParent
68 friend class PluginInstanceParent
;
71 PluginScriptableObjectParent(ScriptableObjectType aType
);
72 virtual ~PluginScriptableObjectParent();
78 InitializeLocal(NPObject
* aObject
);
81 AnswerHasMethod(PPluginIdentifierParent
* aId
,
85 AnswerInvoke(PPluginIdentifierParent
* aId
,
86 const InfallibleTArray
<Variant
>& aArgs
,
91 AnswerInvokeDefault(const InfallibleTArray
<Variant
>& aArgs
,
96 AnswerHasProperty(PPluginIdentifierParent
* aId
,
100 AnswerGetParentProperty(PPluginIdentifierParent
* aId
,
105 AnswerSetProperty(PPluginIdentifierParent
* aId
,
106 const Variant
& aValue
,
110 AnswerRemoveProperty(PPluginIdentifierParent
* aId
,
114 AnswerEnumerate(InfallibleTArray
<PPluginIdentifierParent
*>* aProperties
,
118 AnswerConstruct(const InfallibleTArray
<Variant
>& aArgs
,
123 AnswerNPN_Evaluate(const nsCString
& aScript
,
133 static const NPClass
*
139 PluginInstanceParent
*
146 GetObject(bool aCanResurrect
);
148 // Protect only affects LocalObject actors. It is called by the
149 // ProtectedVariant/Actor helper classes before the actor is used as an
150 // argument to an IPC call and when the child process resurrects a
151 // proxy object to the NPObject associated with this actor.
154 // Unprotect only affects LocalObject actors. It is called by the
155 // ProtectedVariant/Actor helper classes after the actor is used as an
156 // argument to an IPC call and when the child process is no longer using this
160 // DropNPObject is only used for Proxy actors and is called when the parent
161 // process is no longer using the NPObject associated with this actor. The
162 // child process may subsequently use this actor again in which case a new
163 // NPObject will be created and associated with this actor (see
164 // ResurrectProxyObject).
172 JSBool
GetPropertyHelper(NPIdentifier aName
,
173 PRBool
* aHasProperty
,
179 ScriptableAllocate(NPP aInstance
,
183 ScriptableInvalidate(NPObject
* aObject
);
186 ScriptableDeallocate(NPObject
* aObject
);
189 ScriptableHasMethod(NPObject
* aObject
,
193 ScriptableInvoke(NPObject
* aObject
,
195 const NPVariant
* aArgs
,
200 ScriptableInvokeDefault(NPObject
* aObject
,
201 const NPVariant
* aArgs
,
206 ScriptableHasProperty(NPObject
* aObject
,
210 ScriptableGetProperty(NPObject
* aObject
,
215 ScriptableSetProperty(NPObject
* aObject
,
217 const NPVariant
* aValue
);
220 ScriptableRemoveProperty(NPObject
* aObject
,
224 ScriptableEnumerate(NPObject
* aObject
,
225 NPIdentifier
** aIdentifiers
,
229 ScriptableConstruct(NPObject
* aObject
,
230 const NPVariant
* aArgs
,
237 // ResurrectProxyObject is only used with Proxy actors. It is called when the
238 // child process uses an actor whose NPObject was deleted by the parent
240 bool ResurrectProxyObject();
243 PluginInstanceParent
* mInstance
;
245 // This may be a ParentNPObject or some other kind depending on who created
246 // it. Have to check its class to find out.
250 ScriptableObjectType mType
;
252 static const NPClass sNPClass
;
255 } /* namespace plugins */
256 } /* namespace mozilla */
258 #endif /* dom_plugins_PluginScriptableObjectParent_h */