LCOV - code coverage report
Current view: directory - objdir/dist/include/mozilla/plugins - PluginScriptableObjectParent.h (source / functions) Found Hit Coverage
Test: app.info Lines: 4 0 0.0 %
Date: 2012-06-02 Functions: 2 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2                 :  * vim: sw=2 ts=2 et :
       3                 :  * ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       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/
      10                 :  *
      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
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla Plugin App.
      17                 :  *
      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.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *
      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.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef dom_plugins_PluginScriptableObjectParent_h
      40                 : #define dom_plugins_PluginScriptableObjectParent_h 1
      41                 : 
      42                 : #include "mozilla/plugins/PPluginScriptableObjectParent.h"
      43                 : 
      44                 : #include "jsapi.h"
      45                 : #include "npfunctions.h"
      46                 : #include "npruntime.h"
      47                 : 
      48                 : namespace mozilla {
      49                 : namespace plugins {
      50                 : 
      51                 : class PluginInstanceParent;
      52                 : class PluginScriptableObjectParent;
      53                 : class PPluginIdentifierParent;
      54                 : 
      55                 : struct ParentNPObject : NPObject
      56                 : {
      57                 :   ParentNPObject()
      58                 :     : NPObject(), parent(NULL), invalidated(false) { }
      59                 : 
      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;
      63                 :   bool invalidated;
      64                 : };
      65                 : 
      66                 : class PluginScriptableObjectParent : public PPluginScriptableObjectParent
      67                 : {
      68                 :   friend class PluginInstanceParent;
      69                 : 
      70                 : public:
      71                 :   PluginScriptableObjectParent(ScriptableObjectType aType);
      72                 :   virtual ~PluginScriptableObjectParent();
      73                 : 
      74                 :   void
      75                 :   InitializeProxy();
      76                 : 
      77                 :   void
      78                 :   InitializeLocal(NPObject* aObject);
      79                 : 
      80                 :   virtual bool
      81                 :   AnswerHasMethod(PPluginIdentifierParent* aId,
      82                 :                   bool* aHasMethod);
      83                 : 
      84                 :   virtual bool
      85                 :   AnswerInvoke(PPluginIdentifierParent* aId,
      86                 :                const InfallibleTArray<Variant>& aArgs,
      87                 :                Variant* aResult,
      88                 :                bool* aSuccess);
      89                 : 
      90                 :   virtual bool
      91                 :   AnswerInvokeDefault(const InfallibleTArray<Variant>& aArgs,
      92                 :                       Variant* aResult,
      93                 :                       bool* aSuccess);
      94                 : 
      95                 :   virtual bool
      96                 :   AnswerHasProperty(PPluginIdentifierParent* aId,
      97                 :                     bool* aHasProperty);
      98                 : 
      99                 :   virtual bool
     100                 :   AnswerGetParentProperty(PPluginIdentifierParent* aId,
     101                 :                           Variant* aResult,
     102                 :                           bool* aSuccess);
     103                 : 
     104                 :   virtual bool
     105                 :   AnswerSetProperty(PPluginIdentifierParent* aId,
     106                 :                     const Variant& aValue,
     107                 :                     bool* aSuccess);
     108                 : 
     109                 :   virtual bool
     110                 :   AnswerRemoveProperty(PPluginIdentifierParent* aId,
     111                 :                        bool* aSuccess);
     112                 : 
     113                 :   virtual bool
     114                 :   AnswerEnumerate(InfallibleTArray<PPluginIdentifierParent*>* aProperties,
     115                 :                   bool* aSuccess);
     116                 : 
     117                 :   virtual bool
     118                 :   AnswerConstruct(const InfallibleTArray<Variant>& aArgs,
     119                 :                   Variant* aResult,
     120                 :                   bool* aSuccess);
     121                 : 
     122                 :   virtual bool
     123                 :   AnswerNPN_Evaluate(const nsCString& aScript,
     124                 :                      Variant* aResult,
     125                 :                      bool* aSuccess);
     126                 : 
     127                 :   virtual bool
     128                 :   RecvProtect();
     129                 : 
     130                 :   virtual bool
     131                 :   RecvUnprotect();
     132                 : 
     133                 :   static const NPClass*
     134               0 :   GetClass()
     135                 :   {
     136               0 :     return &sNPClass;
     137                 :   }
     138                 : 
     139                 :   PluginInstanceParent*
     140               0 :   GetInstance() const
     141                 :   {
     142               0 :     return mInstance;
     143                 :   }
     144                 : 
     145                 :   NPObject*
     146                 :   GetObject(bool aCanResurrect);
     147                 : 
     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.
     152                 :   void Protect();
     153                 : 
     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
     157                 :   // actor.
     158                 :   void Unprotect();
     159                 : 
     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).
     165                 :   void DropNPObject();
     166                 : 
     167                 :   ScriptableObjectType
     168                 :   Type() const {
     169                 :     return mType;
     170                 :   }
     171                 : 
     172                 :   JSBool GetPropertyHelper(NPIdentifier aName,
     173                 :                            bool* aHasProperty,
     174                 :                            bool* aHasMethod,
     175                 :                            NPVariant* aResult);
     176                 : 
     177                 : private:
     178                 :   static NPObject*
     179                 :   ScriptableAllocate(NPP aInstance,
     180                 :                      NPClass* aClass);
     181                 : 
     182                 :   static void
     183                 :   ScriptableInvalidate(NPObject* aObject);
     184                 : 
     185                 :   static void
     186                 :   ScriptableDeallocate(NPObject* aObject);
     187                 : 
     188                 :   static bool
     189                 :   ScriptableHasMethod(NPObject* aObject,
     190                 :                       NPIdentifier aName);
     191                 : 
     192                 :   static bool
     193                 :   ScriptableInvoke(NPObject* aObject,
     194                 :                    NPIdentifier aName,
     195                 :                    const NPVariant* aArgs,
     196                 :                    uint32_t aArgCount,
     197                 :                    NPVariant* aResult);
     198                 : 
     199                 :   static bool
     200                 :   ScriptableInvokeDefault(NPObject* aObject,
     201                 :                           const NPVariant* aArgs,
     202                 :                           uint32_t aArgCount,
     203                 :                           NPVariant* aResult);
     204                 : 
     205                 :   static bool
     206                 :   ScriptableHasProperty(NPObject* aObject,
     207                 :                         NPIdentifier aName);
     208                 : 
     209                 :   static bool
     210                 :   ScriptableGetProperty(NPObject* aObject,
     211                 :                         NPIdentifier aName,
     212                 :                         NPVariant* aResult);
     213                 : 
     214                 :   static bool
     215                 :   ScriptableSetProperty(NPObject* aObject,
     216                 :                         NPIdentifier aName,
     217                 :                         const NPVariant* aValue);
     218                 : 
     219                 :   static bool
     220                 :   ScriptableRemoveProperty(NPObject* aObject,
     221                 :                            NPIdentifier aName);
     222                 : 
     223                 :   static bool
     224                 :   ScriptableEnumerate(NPObject* aObject,
     225                 :                       NPIdentifier** aIdentifiers,
     226                 :                       uint32_t* aCount);
     227                 : 
     228                 :   static bool
     229                 :   ScriptableConstruct(NPObject* aObject,
     230                 :                       const NPVariant* aArgs,
     231                 :                       uint32_t aArgCount,
     232                 :                       NPVariant* aResult);
     233                 : 
     234                 :   NPObject*
     235                 :   CreateProxyObject();
     236                 : 
     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
     239                 :   // process.
     240                 :   bool ResurrectProxyObject();
     241                 : 
     242                 : private:
     243                 :   PluginInstanceParent* mInstance;
     244                 : 
     245                 :   // This may be a ParentNPObject or some other kind depending on who created
     246                 :   // it. Have to check its class to find out.
     247                 :   NPObject* mObject;
     248                 :   int mProtectCount;
     249                 : 
     250                 :   ScriptableObjectType mType;
     251                 : 
     252                 :   static const NPClass sNPClass;
     253                 : };
     254                 : 
     255                 : } /* namespace plugins */
     256                 : } /* namespace mozilla */
     257                 : 
     258                 : #endif /* dom_plugins_PluginScriptableObjectParent_h */

Generated by: LCOV version 1.7