2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
#ifndef nsNPAPIPlugin_h_
|
|
|
|
#define nsNPAPIPlugin_h_
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsIFactory.h"
|
|
|
|
#include "nsIPlugin.h"
|
|
|
|
#include "nsIPluginInstancePeer.h"
|
|
|
|
#include "nsIWindowlessPlugInstPeer.h"
|
2008-09-11 08:10:26 -07:00
|
|
|
#include "prlink.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "npupp.h"
|
|
|
|
#include "nsPluginHostImpl.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use this macro before each exported function
|
|
|
|
* (between the return address and the function
|
|
|
|
* itself), to ensure that the function has the
|
|
|
|
* right calling conventions on Win16.
|
|
|
|
*/
|
2008-09-11 08:10:26 -07:00
|
|
|
// XXX NP_CALLBACK should be the same as NP_LOADDS in npapi.h which differs
|
|
|
|
// for WIN16 and maybe WIN64?
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef XP_OS2
|
2007-06-26 17:41:08 -07:00
|
|
|
#define NP_CALLBACK _System
|
2007-03-22 10:30:00 -07:00
|
|
|
#else
|
2007-06-26 17:41:08 -07:00
|
|
|
#define NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
#if defined(XP_WIN)
|
2008-09-15 05:45:01 -07:00
|
|
|
#define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (__stdcall * _name)
|
2007-03-22 10:30:00 -07:00
|
|
|
#elif defined(XP_OS2)
|
2008-09-15 05:45:01 -07:00
|
|
|
#define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (_System * _name)
|
2007-03-22 10:30:00 -07:00
|
|
|
#else
|
2008-09-15 05:45:01 -07:00
|
|
|
#define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (* _name)
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
|
|
|
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
|
|
|
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks,NPPluginFuncs* fCallbacks);
|
|
|
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) (void);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef XP_MACOSX
|
2008-09-15 05:45:01 -07:00
|
|
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownUPP* unloadUpp);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
class nsNPAPIPlugin : public nsIPlugin
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2008-09-15 05:45:01 -07:00
|
|
|
nsNPAPIPlugin(NPPluginFuncs* callbacks, PRLibrary* aLibrary,
|
|
|
|
NP_PLUGINSHUTDOWN aShutdown);
|
|
|
|
virtual ~nsNPAPIPlugin(void);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFACTORY
|
|
|
|
NS_DECL_NSIPLUGIN
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
// Constructs and initializes an nsNPAPIPlugin object
|
2008-09-11 08:10:26 -07:00
|
|
|
static nsresult CreatePlugin(const char* aFileName,
|
|
|
|
const char* aFullPath,
|
|
|
|
PRLibrary* aLibrary,
|
|
|
|
nsIPlugin** aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
void SetPluginRefNum(short aRefNum);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2008-09-11 08:10:26 -07:00
|
|
|
// Ensures that the static CALLBACKS is properly initialized
|
2007-03-22 10:30:00 -07:00
|
|
|
static void CheckClassInitialized(void);
|
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
short fPluginRefNum;
|
|
|
|
#endif
|
|
|
|
|
2008-09-11 08:10:26 -07:00
|
|
|
// The plugin-side callbacks that the browser calls. One set of
|
|
|
|
// plugin callbacks for each plugin.
|
2007-03-22 10:30:00 -07:00
|
|
|
NPPluginFuncs fCallbacks;
|
|
|
|
PRLibrary* fLibrary;
|
|
|
|
|
|
|
|
NP_PLUGINSHUTDOWN fShutdownEntry;
|
|
|
|
|
2008-09-11 08:10:26 -07:00
|
|
|
// The browser-side callbacks that a 4.x-style plugin calls.
|
2007-03-22 10:30:00 -07:00
|
|
|
static NPNetscapeFuncs CALLBACKS;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PR_BEGIN_EXTERN_C
|
2007-06-26 17:41:08 -07:00
|
|
|
NPObject* NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getwindowobject(NPP npp);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPObject* NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getpluginelement(NPP npp);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPIdentifier NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getstringidentifier(const NPUTF8* name);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getstringidentifiers(const NPUTF8** names, int32_t nameCount,
|
|
|
|
NPIdentifier *identifiers);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_identifierisstring(NPIdentifier identifiers);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPIdentifier NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getintidentifier(int32_t intid);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPUTF8* NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_utf8fromidentifier(NPIdentifier identifier);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
int32_t NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_intfromidentifier(NPIdentifier identifier);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPObject* NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_createobject(NPP npp, NPClass* aClass);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPObject* NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_retainobject(NPObject* npobj);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_releaseobject(NPObject* npobj);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_invoke(NPP npp, NPObject* npobj, NPIdentifier method, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_invokeDefault(NPP npp, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getproperty(NPP npp, NPObject* npobj, NPIdentifier property,
|
|
|
|
NPVariant *result);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_setproperty(NPP npp, NPObject* npobj, NPIdentifier property,
|
|
|
|
const NPVariant *value);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_removeproperty(NPP npp, NPObject* npobj, NPIdentifier property);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_hasproperty(NPP npp, NPObject* npobj, NPIdentifier propertyName);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_hasmethod(NPP npp, NPObject* npobj, NPIdentifier methodName);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier,
|
|
|
|
uint32_t *count);
|
|
|
|
|
2007-10-09 18:24:28 -07:00
|
|
|
bool NP_CALLBACK
|
|
|
|
_construct(NPP npp, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_releasevariantvalue(NPVariant *variant);
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_setexception(NPObject* npobj, const NPUTF8 *message);
|
|
|
|
|
|
|
|
PR_END_EXTERN_C
|
|
|
|
|
|
|
|
const char *
|
|
|
|
PeekException();
|
|
|
|
|
|
|
|
void
|
|
|
|
PopException();
|
|
|
|
|
2007-07-11 16:25:45 -07:00
|
|
|
void
|
|
|
|
OnPluginDestroy(NPP instance);
|
|
|
|
|
|
|
|
void
|
|
|
|
OnShutdown();
|
|
|
|
|
|
|
|
void
|
|
|
|
EnterAsyncPluginThreadCallLock();
|
|
|
|
void
|
|
|
|
ExitAsyncPluginThreadCallLock();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class NPPStack
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static NPP Peek()
|
|
|
|
{
|
|
|
|
return sCurrentNPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static NPP sCurrentNPP;
|
|
|
|
};
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
// XXXjst: The NPPAutoPusher stack is a bit redundant now that
|
|
|
|
// PluginDestructionGuard exists, and could thus be replaced by code
|
|
|
|
// that uses the PluginDestructionGuard list of plugins on the
|
|
|
|
// stack. But they're not identical, and to minimize code changes
|
|
|
|
// we're keeping both for the moment, and making NPPAutoPusher inherit
|
|
|
|
// the PluginDestructionGuard class to avoid having to keep two
|
|
|
|
// separate objects on the stack since we always want a
|
|
|
|
// PluginDestructionGuard where we use an NPPAutoPusher.
|
|
|
|
|
|
|
|
class NPPAutoPusher : public NPPStack,
|
|
|
|
protected PluginDestructionGuard
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NPPAutoPusher(NPP npp)
|
2008-02-28 18:06:00 -08:00
|
|
|
: PluginDestructionGuard(npp),
|
|
|
|
mOldNPP(sCurrentNPP)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(npp, "Uh, null npp passed to NPPAutoPusher!");
|
|
|
|
|
|
|
|
sCurrentNPP = npp;
|
|
|
|
}
|
|
|
|
|
|
|
|
~NPPAutoPusher()
|
|
|
|
{
|
|
|
|
sCurrentNPP = mOldNPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
NPP mOldNPP;
|
|
|
|
};
|
|
|
|
|
|
|
|
class NPPExceptionAutoHolder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NPPExceptionAutoHolder();
|
|
|
|
~NPPExceptionAutoHolder();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
char *mOldException;
|
|
|
|
};
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
#endif // nsNPAPIPlugin_h_
|