dom/plugins/ipc/PluginScriptableObjectChild.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * vim: sw=2 ts=2 et :
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef dom_plugins_PluginScriptableObjectChild_h
michael@0 8 #define dom_plugins_PluginScriptableObjectChild_h 1
michael@0 9
michael@0 10 #include "mozilla/plugins/PPluginScriptableObjectChild.h"
michael@0 11 #include "mozilla/plugins/PluginMessageUtils.h"
michael@0 12
michael@0 13 #include "npruntime.h"
michael@0 14
michael@0 15 namespace mozilla {
michael@0 16 namespace plugins {
michael@0 17
michael@0 18 class PluginInstanceChild;
michael@0 19 class PluginScriptableObjectChild;
michael@0 20 class PPluginIdentifierChild;
michael@0 21
michael@0 22 struct ChildNPObject : NPObject
michael@0 23 {
michael@0 24 ChildNPObject()
michael@0 25 : NPObject(), parent(nullptr), invalidated(false)
michael@0 26 {
michael@0 27 MOZ_COUNT_CTOR(ChildNPObject);
michael@0 28 }
michael@0 29
michael@0 30 ~ChildNPObject()
michael@0 31 {
michael@0 32 MOZ_COUNT_DTOR(ChildNPObject);
michael@0 33 }
michael@0 34
michael@0 35 // |parent| is always valid as long as the actor is alive. Once the actor is
michael@0 36 // destroyed this will be set to null.
michael@0 37 PluginScriptableObjectChild* parent;
michael@0 38 bool invalidated;
michael@0 39 };
michael@0 40
michael@0 41 class PluginScriptableObjectChild : public PPluginScriptableObjectChild
michael@0 42 {
michael@0 43 friend class PluginInstanceChild;
michael@0 44
michael@0 45 public:
michael@0 46 PluginScriptableObjectChild(ScriptableObjectType aType);
michael@0 47 virtual ~PluginScriptableObjectChild();
michael@0 48
michael@0 49 void
michael@0 50 InitializeProxy();
michael@0 51
michael@0 52 void
michael@0 53 InitializeLocal(NPObject* aObject);
michael@0 54
michael@0 55
michael@0 56 virtual bool
michael@0 57 AnswerInvalidate() MOZ_OVERRIDE;
michael@0 58
michael@0 59 virtual bool
michael@0 60 AnswerHasMethod(PPluginIdentifierChild* aId,
michael@0 61 bool* aHasMethod) MOZ_OVERRIDE;
michael@0 62
michael@0 63 virtual bool
michael@0 64 AnswerInvoke(PPluginIdentifierChild* aId,
michael@0 65 const InfallibleTArray<Variant>& aArgs,
michael@0 66 Variant* aResult,
michael@0 67 bool* aSuccess) MOZ_OVERRIDE;
michael@0 68
michael@0 69 virtual bool
michael@0 70 AnswerInvokeDefault(const InfallibleTArray<Variant>& aArgs,
michael@0 71 Variant* aResult,
michael@0 72 bool* aSuccess) MOZ_OVERRIDE;
michael@0 73
michael@0 74 virtual bool
michael@0 75 AnswerHasProperty(PPluginIdentifierChild* aId,
michael@0 76 bool* aHasProperty) MOZ_OVERRIDE;
michael@0 77
michael@0 78 virtual bool
michael@0 79 AnswerGetChildProperty(PPluginIdentifierChild* aId,
michael@0 80 bool* aHasProperty,
michael@0 81 bool* aHasMethod,
michael@0 82 Variant* aResult,
michael@0 83 bool* aSuccess) MOZ_OVERRIDE;
michael@0 84
michael@0 85 virtual bool
michael@0 86 AnswerSetProperty(PPluginIdentifierChild* aId,
michael@0 87 const Variant& aValue,
michael@0 88 bool* aSuccess) MOZ_OVERRIDE;
michael@0 89
michael@0 90 virtual bool
michael@0 91 AnswerRemoveProperty(PPluginIdentifierChild* aId,
michael@0 92 bool* aSuccess) MOZ_OVERRIDE;
michael@0 93
michael@0 94 virtual bool
michael@0 95 AnswerEnumerate(InfallibleTArray<PPluginIdentifierChild*>* aProperties,
michael@0 96 bool* aSuccess) MOZ_OVERRIDE;
michael@0 97
michael@0 98 virtual bool
michael@0 99 AnswerConstruct(const InfallibleTArray<Variant>& aArgs,
michael@0 100 Variant* aResult,
michael@0 101 bool* aSuccess) MOZ_OVERRIDE;
michael@0 102
michael@0 103 virtual bool
michael@0 104 RecvProtect() MOZ_OVERRIDE;
michael@0 105
michael@0 106 virtual bool
michael@0 107 RecvUnprotect() MOZ_OVERRIDE;
michael@0 108
michael@0 109 NPObject*
michael@0 110 GetObject(bool aCanResurrect);
michael@0 111
michael@0 112 static const NPClass*
michael@0 113 GetClass()
michael@0 114 {
michael@0 115 return &sNPClass;
michael@0 116 }
michael@0 117
michael@0 118 PluginInstanceChild*
michael@0 119 GetInstance() const
michael@0 120 {
michael@0 121 return mInstance;
michael@0 122 }
michael@0 123
michael@0 124 // Protect only affects LocalObject actors. It is called by the
michael@0 125 // ProtectedVariant/Actor helper classes before the actor is used as an
michael@0 126 // argument to an IPC call and when the parent process resurrects a
michael@0 127 // proxy object to the NPObject associated with this actor.
michael@0 128 void Protect();
michael@0 129
michael@0 130 // Unprotect only affects LocalObject actors. It is called by the
michael@0 131 // ProtectedVariant/Actor helper classes after the actor is used as an
michael@0 132 // argument to an IPC call and when the parent process is no longer using
michael@0 133 // this actor.
michael@0 134 void Unprotect();
michael@0 135
michael@0 136 // DropNPObject is only used for Proxy actors and is called when the child
michael@0 137 // process is no longer using the NPObject associated with this actor. The
michael@0 138 // parent process may subsequently use this actor again in which case a new
michael@0 139 // NPObject will be created and associated with this actor (see
michael@0 140 // ResurrectProxyObject).
michael@0 141 void DropNPObject();
michael@0 142
michael@0 143 /**
michael@0 144 * After NPP_Destroy, all NPObjects associated with an instance are
michael@0 145 * destroyed. We are informed of this destruction. This should only be called
michael@0 146 * on Local actors.
michael@0 147 */
michael@0 148 void NPObjectDestroyed();
michael@0 149
michael@0 150 bool
michael@0 151 Evaluate(NPString* aScript,
michael@0 152 NPVariant* aResult);
michael@0 153
michael@0 154 ScriptableObjectType
michael@0 155 Type() const {
michael@0 156 return mType;
michael@0 157 }
michael@0 158
michael@0 159 private:
michael@0 160 static NPObject*
michael@0 161 ScriptableAllocate(NPP aInstance,
michael@0 162 NPClass* aClass);
michael@0 163
michael@0 164 static void
michael@0 165 ScriptableInvalidate(NPObject* aObject);
michael@0 166
michael@0 167 static void
michael@0 168 ScriptableDeallocate(NPObject* aObject);
michael@0 169
michael@0 170 static bool
michael@0 171 ScriptableHasMethod(NPObject* aObject,
michael@0 172 NPIdentifier aName);
michael@0 173
michael@0 174 static bool
michael@0 175 ScriptableInvoke(NPObject* aObject,
michael@0 176 NPIdentifier aName,
michael@0 177 const NPVariant* aArgs,
michael@0 178 uint32_t aArgCount,
michael@0 179 NPVariant* aResult);
michael@0 180
michael@0 181 static bool
michael@0 182 ScriptableInvokeDefault(NPObject* aObject,
michael@0 183 const NPVariant* aArgs,
michael@0 184 uint32_t aArgCount,
michael@0 185 NPVariant* aResult);
michael@0 186
michael@0 187 static bool
michael@0 188 ScriptableHasProperty(NPObject* aObject,
michael@0 189 NPIdentifier aName);
michael@0 190
michael@0 191 static bool
michael@0 192 ScriptableGetProperty(NPObject* aObject,
michael@0 193 NPIdentifier aName,
michael@0 194 NPVariant* aResult);
michael@0 195
michael@0 196 static bool
michael@0 197 ScriptableSetProperty(NPObject* aObject,
michael@0 198 NPIdentifier aName,
michael@0 199 const NPVariant* aValue);
michael@0 200
michael@0 201 static bool
michael@0 202 ScriptableRemoveProperty(NPObject* aObject,
michael@0 203 NPIdentifier aName);
michael@0 204
michael@0 205 static bool
michael@0 206 ScriptableEnumerate(NPObject* aObject,
michael@0 207 NPIdentifier** aIdentifiers,
michael@0 208 uint32_t* aCount);
michael@0 209
michael@0 210 static bool
michael@0 211 ScriptableConstruct(NPObject* aObject,
michael@0 212 const NPVariant* aArgs,
michael@0 213 uint32_t aArgCount,
michael@0 214 NPVariant* aResult);
michael@0 215
michael@0 216 NPObject*
michael@0 217 CreateProxyObject();
michael@0 218
michael@0 219 // ResurrectProxyObject is only used with Proxy actors. It is called when the
michael@0 220 // parent process uses an actor whose NPObject was deleted by the child
michael@0 221 // process.
michael@0 222 bool ResurrectProxyObject();
michael@0 223
michael@0 224 private:
michael@0 225 PluginInstanceChild* mInstance;
michael@0 226 NPObject* mObject;
michael@0 227 bool mInvalidated;
michael@0 228 int mProtectCount;
michael@0 229
michael@0 230 ScriptableObjectType mType;
michael@0 231
michael@0 232 static const NPClass sNPClass;
michael@0 233 };
michael@0 234
michael@0 235 } /* namespace plugins */
michael@0 236 } /* namespace mozilla */
michael@0 237
michael@0 238 #endif /* dom_plugins_PluginScriptableObjectChild_h */

mercurial