LCOV - code coverage report
Current view: directory - dom/plugins/base - nsNPAPIPlugin.h (source / functions) Found Hit Coverage
Test: app.info Lines: 34 0 0.0 %
Date: 2012-06-02 Functions: 13 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       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/
       9                 :  *
      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
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      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.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef nsNPAPIPlugin_h_
      39                 : #define nsNPAPIPlugin_h_
      40                 : 
      41                 : #include "prlink.h"
      42                 : #include "npfunctions.h"
      43                 : #include "nsPluginHost.h"
      44                 : 
      45                 : #include "jsapi.h"
      46                 : 
      47                 : #include "mozilla/PluginLibrary.h"
      48                 : 
      49                 : /*
      50                 :  * Use this macro before each exported function
      51                 :  * (between the return address and the function
      52                 :  * itself), to ensure that the function has the
      53                 :  * right calling conventions on OS/2.
      54                 :  */
      55                 : #ifdef XP_OS2
      56                 : #define NP_CALLBACK _System
      57                 : #else
      58                 : #define NP_CALLBACK
      59                 : #endif
      60                 : 
      61                 : #if defined(XP_WIN)
      62                 : #define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (__stdcall * _name)
      63                 : #elif defined(XP_OS2)
      64                 : #define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (_System * _name)
      65                 : #else
      66                 : #define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (* _name)
      67                 : #endif
      68                 : 
      69                 : typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
      70                 : typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
      71                 : typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks, NPPluginFuncs* fCallbacks);
      72                 : typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) ();
      73                 : 
      74                 : class nsNPAPIPlugin : public nsISupports
      75                 : {
      76                 : private:
      77                 :   typedef mozilla::PluginLibrary PluginLibrary;
      78                 : 
      79                 : public:
      80                 :   nsNPAPIPlugin();
      81                 :   virtual ~nsNPAPIPlugin();
      82                 : 
      83                 :   NS_DECL_ISUPPORTS
      84                 : 
      85                 :   // Constructs and initializes an nsNPAPIPlugin object. A NULL file path
      86                 :   // will prevent this from calling NP_Initialize.
      87                 :   static nsresult CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult);
      88                 : 
      89                 :   PluginLibrary* GetLibrary();
      90                 :   // PluginFuncs() can't fail but results are only valid if GetLibrary() succeeds
      91                 :   NPPluginFuncs* PluginFuncs();
      92                 : 
      93                 : #if defined(XP_MACOSX) && !defined(__LP64__)
      94                 :   void SetPluginRefNum(short aRefNum);
      95                 : #endif
      96                 : 
      97                 :   // The IPC mechanism notifies the nsNPAPIPlugin if the plugin
      98                 :   // crashes and is no longer usable. pluginDumpID/browserDumpID are
      99                 :   // the IDs of respective minidumps that were written, or empty if no
     100                 :   // minidump was written.
     101                 :   void PluginCrashed(const nsAString& pluginDumpID,
     102                 :                      const nsAString& browserDumpID);
     103                 :   
     104                 :   static bool RunPluginOOP(const nsPluginTag *aPluginTag);
     105                 : 
     106                 :   nsresult CreatePluginInstance(nsNPAPIPluginInstance **aResult);
     107                 :   nsresult Shutdown();
     108                 : 
     109                 :   static nsresult RetainStream(NPStream *pstream, nsISupports **aRetainedPeer);
     110                 : 
     111                 : protected:
     112                 :   NPPluginFuncs mPluginFuncs;
     113                 :   PluginLibrary* mLibrary;
     114                 : };
     115                 : 
     116                 : namespace mozilla {
     117                 : namespace plugins {
     118                 : namespace parent {
     119                 : 
     120                 : JS_STATIC_ASSERT(sizeof(NPIdentifier) == sizeof(jsid));
     121                 : 
     122                 : inline jsid
     123               0 : NPIdentifierToJSId(NPIdentifier id)
     124                 : {
     125                 :     jsid tmp;
     126               0 :     JSID_BITS(tmp) = (size_t)id;
     127                 :     return tmp;
     128                 : }
     129                 : 
     130                 : inline NPIdentifier
     131               0 : JSIdToNPIdentifier(jsid id)
     132                 : {
     133               0 :     return (NPIdentifier)JSID_BITS(id);
     134                 : }
     135                 : 
     136                 : inline bool
     137               0 : NPIdentifierIsString(NPIdentifier id)
     138                 : {
     139               0 :     return JSID_IS_STRING(NPIdentifierToJSId(id));
     140                 : }
     141                 : 
     142                 : inline JSString *
     143               0 : NPIdentifierToString(NPIdentifier id)
     144                 : {
     145               0 :     return JSID_TO_STRING(NPIdentifierToJSId(id));
     146                 : }
     147                 : 
     148                 : inline NPIdentifier
     149               0 : StringToNPIdentifier(JSContext *cx, JSString *str)
     150                 : {
     151               0 :     return JSIdToNPIdentifier(INTERNED_STRING_TO_JSID(cx, str));
     152                 : }
     153                 : 
     154                 : inline bool
     155               0 : NPIdentifierIsInt(NPIdentifier id)
     156                 : {
     157               0 :     return JSID_IS_INT(NPIdentifierToJSId(id));
     158                 : }
     159                 : 
     160                 : inline int
     161               0 : NPIdentifierToInt(NPIdentifier id)
     162                 : {
     163               0 :     return JSID_TO_INT(NPIdentifierToJSId(id));
     164                 : }
     165                 : 
     166                 : inline NPIdentifier
     167               0 : IntToNPIdentifier(int i)
     168                 : {
     169               0 :     return JSIdToNPIdentifier(INT_TO_JSID(i));
     170                 : }
     171                 : 
     172                 : JSContext* GetJSContext(NPP npp);
     173                 : 
     174                 : inline bool
     175               0 : NPStringIdentifierIsPermanent(NPP npp, NPIdentifier id)
     176                 : {
     177               0 :   JSContext* cx = GetJSContext(npp);
     178               0 :   if (!cx) // OOM?
     179               0 :     return false;
     180                 : 
     181               0 :   JSAutoRequest ar(cx);
     182               0 :   return JS_StringHasBeenInterned(cx, NPIdentifierToString(id));
     183                 : }
     184                 : 
     185                 : #define NPIdentifier_VOID (JSIdToNPIdentifier(JSID_VOID))
     186                 : 
     187                 : NPObject* NP_CALLBACK
     188                 : _getwindowobject(NPP npp);
     189                 : 
     190                 : NPObject* NP_CALLBACK
     191                 : _getpluginelement(NPP npp);
     192                 : 
     193                 : NPIdentifier NP_CALLBACK
     194                 : _getstringidentifier(const NPUTF8* name);
     195                 : 
     196                 : void NP_CALLBACK
     197                 : _getstringidentifiers(const NPUTF8** names, int32_t nameCount,
     198                 :                       NPIdentifier *identifiers);
     199                 : 
     200                 : bool NP_CALLBACK
     201                 : _identifierisstring(NPIdentifier identifiers);
     202                 : 
     203                 : NPIdentifier NP_CALLBACK
     204                 : _getintidentifier(int32_t intid);
     205                 : 
     206                 : NPUTF8* NP_CALLBACK
     207                 : _utf8fromidentifier(NPIdentifier identifier);
     208                 : 
     209                 : int32_t NP_CALLBACK
     210                 : _intfromidentifier(NPIdentifier identifier);
     211                 : 
     212                 : NPObject* NP_CALLBACK
     213                 : _createobject(NPP npp, NPClass* aClass);
     214                 : 
     215                 : NPObject* NP_CALLBACK
     216                 : _retainobject(NPObject* npobj);
     217                 : 
     218                 : void NP_CALLBACK
     219                 : _releaseobject(NPObject* npobj);
     220                 : 
     221                 : bool NP_CALLBACK
     222                 : _invoke(NPP npp, NPObject* npobj, NPIdentifier method, const NPVariant *args,
     223                 :         uint32_t argCount, NPVariant *result);
     224                 : 
     225                 : bool NP_CALLBACK
     226                 : _invokeDefault(NPP npp, NPObject* npobj, const NPVariant *args,
     227                 :                uint32_t argCount, NPVariant *result);
     228                 : 
     229                 : bool NP_CALLBACK
     230                 : _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result);
     231                 : 
     232                 : bool NP_CALLBACK
     233                 : _getproperty(NPP npp, NPObject* npobj, NPIdentifier property,
     234                 :              NPVariant *result);
     235                 : 
     236                 : bool NP_CALLBACK
     237                 : _setproperty(NPP npp, NPObject* npobj, NPIdentifier property,
     238                 :              const NPVariant *value);
     239                 : 
     240                 : bool NP_CALLBACK
     241                 : _removeproperty(NPP npp, NPObject* npobj, NPIdentifier property);
     242                 : 
     243                 : bool NP_CALLBACK
     244                 : _hasproperty(NPP npp, NPObject* npobj, NPIdentifier propertyName);
     245                 : 
     246                 : bool NP_CALLBACK
     247                 : _hasmethod(NPP npp, NPObject* npobj, NPIdentifier methodName);
     248                 : 
     249                 : bool NP_CALLBACK
     250                 : _enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier,
     251                 :            uint32_t *count);
     252                 : 
     253                 : bool NP_CALLBACK
     254                 : _construct(NPP npp, NPObject* npobj, const NPVariant *args,
     255                 :            uint32_t argCount, NPVariant *result);
     256                 : 
     257                 : void NP_CALLBACK
     258                 : _releasevariantvalue(NPVariant *variant);
     259                 : 
     260                 : void NP_CALLBACK
     261                 : _setexception(NPObject* npobj, const NPUTF8 *message);
     262                 : 
     263                 : void NP_CALLBACK
     264                 : _pushpopupsenabledstate(NPP npp, NPBool enabled);
     265                 : 
     266                 : void NP_CALLBACK
     267                 : _poppopupsenabledstate(NPP npp);
     268                 : 
     269                 : typedef void(*PluginThreadCallback)(void *);
     270                 : 
     271                 : void NP_CALLBACK
     272                 : _pluginthreadasynccall(NPP instance, PluginThreadCallback func,
     273                 :                        void *userData);
     274                 : 
     275                 : NPError NP_CALLBACK
     276                 : _getvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
     277                 :                 char **value, uint32_t *len);
     278                 : 
     279                 : NPError NP_CALLBACK
     280                 : _setvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
     281                 :                 const char *value, uint32_t len);
     282                 : 
     283                 : NPError NP_CALLBACK
     284                 : _getauthenticationinfo(NPP instance, const char *protocol, const char *host,
     285                 :                        int32_t port, const char *scheme, const char *realm,
     286                 :                        char **username, uint32_t *ulen, char **password,
     287                 :                        uint32_t *plen);
     288                 : 
     289                 : typedef void(*PluginTimerFunc)(NPP npp, uint32_t timerID);
     290                 : 
     291                 : uint32_t NP_CALLBACK
     292                 : _scheduletimer(NPP instance, uint32_t interval, NPBool repeat, PluginTimerFunc timerFunc);
     293                 : 
     294                 : void NP_CALLBACK
     295                 : _unscheduletimer(NPP instance, uint32_t timerID);
     296                 : 
     297                 : NPError NP_CALLBACK
     298                 : _popupcontextmenu(NPP instance, NPMenu* menu);
     299                 : 
     300                 : NPError NP_CALLBACK
     301                 : _initasyncsurface(NPP instance, NPSize *size, NPImageFormat format, void *initData, NPAsyncSurface *surface);
     302                 : 
     303                 : NPError NP_CALLBACK
     304                 : _finalizeasyncsurface(NPP instance, NPAsyncSurface *surface);
     305                 : 
     306                 : void NP_CALLBACK
     307                 : _setcurrentasyncsurface(NPP instance, NPAsyncSurface *surface, NPRect *changed);
     308                 : 
     309                 : NPBool NP_CALLBACK
     310                 : _convertpoint(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace);
     311                 : 
     312                 : NPError NP_CALLBACK
     313                 : _requestread(NPStream *pstream, NPByteRange *rangeList);
     314                 : 
     315                 : NPError NP_CALLBACK
     316                 : _geturlnotify(NPP npp, const char* relativeURL, const char* target,
     317                 :               void* notifyData);
     318                 : 
     319                 : NPError NP_CALLBACK
     320                 : _getvalue(NPP npp, NPNVariable variable, void *r_value);
     321                 : 
     322                 : NPError NP_CALLBACK
     323                 : _setvalue(NPP npp, NPPVariable variable, void *r_value);
     324                 : 
     325                 : NPError NP_CALLBACK
     326                 : _geturl(NPP npp, const char* relativeURL, const char* target);
     327                 : 
     328                 : NPError NP_CALLBACK
     329                 : _posturlnotify(NPP npp, const char* relativeURL, const char *target,
     330                 :                uint32_t len, const char *buf, NPBool file, void* notifyData);
     331                 : 
     332                 : NPError NP_CALLBACK
     333                 : _posturl(NPP npp, const char* relativeURL, const char *target, uint32_t len,
     334                 :             const char *buf, NPBool file);
     335                 : 
     336                 : NPError NP_CALLBACK
     337                 : _newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream);
     338                 : 
     339                 : int32_t NP_CALLBACK
     340                 : _write(NPP npp, NPStream *pstream, int32_t len, void *buffer);
     341                 : 
     342                 : NPError NP_CALLBACK
     343                 : _destroystream(NPP npp, NPStream *pstream, NPError reason);
     344                 : 
     345                 : void NP_CALLBACK
     346                 : _status(NPP npp, const char *message);
     347                 : 
     348                 : void NP_CALLBACK
     349                 : _memfree (void *ptr);
     350                 : 
     351                 : uint32_t NP_CALLBACK
     352                 : _memflush(uint32_t size);
     353                 : 
     354                 : void NP_CALLBACK
     355                 : _reloadplugins(NPBool reloadPages);
     356                 : 
     357                 : void NP_CALLBACK
     358                 : _invalidaterect(NPP npp, NPRect *invalidRect);
     359                 : 
     360                 : void NP_CALLBACK
     361                 : _invalidateregion(NPP npp, NPRegion invalidRegion);
     362                 : 
     363                 : void NP_CALLBACK
     364                 : _forceredraw(NPP npp);
     365                 : 
     366                 : const char* NP_CALLBACK
     367                 : _useragent(NPP npp);
     368                 : 
     369                 : void* NP_CALLBACK
     370                 : _memalloc (uint32_t size);
     371                 : 
     372                 : // Deprecated entry points for the old Java plugin.
     373                 : void* NP_CALLBACK /* OJI type: JRIEnv* */
     374                 : _getJavaEnv();
     375                 : 
     376                 : void* NP_CALLBACK /* OJI type: jref */
     377                 : _getJavaPeer(NPP npp);
     378                 : 
     379                 : void NP_CALLBACK
     380                 : _urlredirectresponse(NPP instance, void* notifyData, NPBool allow);
     381                 : 
     382                 : } /* namespace parent */
     383                 : } /* namespace plugins */
     384                 : } /* namespace mozilla */
     385                 : 
     386                 : const char *
     387                 : PeekException();
     388                 : 
     389                 : void
     390                 : PopException();
     391                 : 
     392                 : void
     393                 : OnPluginDestroy(NPP instance);
     394                 : 
     395                 : void
     396                 : OnShutdown();
     397                 : 
     398                 : /**
     399                 :  * within a lexical scope, locks and unlocks the mutex used to
     400                 :  * serialize modifications to plugin async callback state.
     401                 :  */
     402                 : struct NS_STACK_CLASS AsyncCallbackAutoLock
     403                 : {
     404                 :   AsyncCallbackAutoLock();
     405                 :   ~AsyncCallbackAutoLock();
     406                 : };
     407                 : 
     408                 : class NPPStack
     409               0 : {
     410                 : public:
     411               0 :   static NPP Peek()
     412                 :   {
     413               0 :     return sCurrentNPP;
     414                 :   }
     415                 : 
     416                 : protected:
     417                 :   static NPP sCurrentNPP;
     418                 : };
     419                 : 
     420                 : // XXXjst: The NPPAutoPusher stack is a bit redundant now that
     421                 : // PluginDestructionGuard exists, and could thus be replaced by code
     422                 : // that uses the PluginDestructionGuard list of plugins on the
     423                 : // stack. But they're not identical, and to minimize code changes
     424                 : // we're keeping both for the moment, and making NPPAutoPusher inherit
     425                 : // the PluginDestructionGuard class to avoid having to keep two
     426                 : // separate objects on the stack since we always want a
     427                 : // PluginDestructionGuard where we use an NPPAutoPusher.
     428                 : 
     429                 : class NPPAutoPusher : public NPPStack,
     430                 :                       protected PluginDestructionGuard
     431                 : {
     432                 : public:
     433               0 :   NPPAutoPusher(NPP npp)
     434                 :     : PluginDestructionGuard(npp),
     435               0 :       mOldNPP(sCurrentNPP)
     436                 :   {
     437               0 :     NS_ASSERTION(npp, "Uh, null npp passed to NPPAutoPusher!");
     438                 : 
     439               0 :     sCurrentNPP = npp;
     440               0 :   }
     441                 : 
     442               0 :   ~NPPAutoPusher()
     443               0 :   {
     444               0 :     sCurrentNPP = mOldNPP;
     445               0 :   }
     446                 : 
     447                 : private:
     448                 :   NPP mOldNPP;
     449                 : };
     450                 : 
     451                 : class NPPExceptionAutoHolder
     452                 : {
     453                 : public:
     454                 :   NPPExceptionAutoHolder();
     455                 :   ~NPPExceptionAutoHolder();
     456                 : 
     457                 : protected:
     458                 :   char *mOldException;
     459                 : };
     460                 : 
     461                 : #endif // nsNPAPIPlugin_h_

Generated by: LCOV version 1.7