2004-07-12 15:53:22 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2001-09-28 20:14:13 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 22:01:16 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-07-07 20:18:27 +00:00
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* 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/
|
1999-07-07 20:18:27 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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.
|
1999-07-07 20:18:27 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:43:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 22:01:16 +00:00
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 22:01:16 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 22:01:16 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2008-09-11 15:10:26 +00:00
|
|
|
#ifndef ns4xPlugin_h_
|
|
|
|
#define ns4xPlugin_h_
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2007-02-17 18:44:42 +00:00
|
|
|
#include "nsIFactory.h"
|
2002-10-03 21:31:41 +00:00
|
|
|
#include "nsIPlugin.h"
|
|
|
|
#include "nsIPluginInstancePeer.h"
|
|
|
|
#include "nsIWindowlessPlugInstPeer.h"
|
2008-09-11 15:10:26 +00:00
|
|
|
#include "prlink.h"
|
1999-07-07 20:18:27 +00: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 15:10:26 +00:00
|
|
|
// XXX NP_CALLBACK should be the same as NP_LOADDS in npapi.h which differs
|
|
|
|
// for WIN16 and maybe WIN64?
|
2000-11-13 21:40:27 +00:00
|
|
|
#ifdef XP_OS2
|
2007-06-27 00:41:08 +00:00
|
|
|
#define NP_CALLBACK _System
|
2000-11-13 21:40:27 +00:00
|
|
|
#else
|
2007-06-27 00:41:08 +00:00
|
|
|
#define NP_CALLBACK
|
2000-11-13 21:40:27 +00:00
|
|
|
#endif
|
2001-10-19 04:10:49 +00:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
#define NS_4XPLUGIN_CALLBACK(_type, _name) _type (__stdcall * _name)
|
|
|
|
#elif defined(XP_OS2)
|
|
|
|
#define NS_4XPLUGIN_CALLBACK(_type, _name) _type (_System * _name)
|
|
|
|
#else
|
|
|
|
#define NS_4XPLUGIN_CALLBACK(_type, _name) _type (* _name)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef NS_4XPLUGIN_CALLBACK(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
|
|
|
|
typedef NS_4XPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
|
|
|
|
typedef NS_4XPLUGIN_CALLBACK(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks,NPPluginFuncs* fCallbacks);
|
|
|
|
typedef NS_4XPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) (void);
|
2006-07-13 19:47:32 +00:00
|
|
|
#ifdef XP_MACOSX
|
2001-10-19 04:10:49 +00:00
|
|
|
typedef NS_4XPLUGIN_CALLBACK(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownUPP* unloadUpp);
|
2006-09-21 19:32:30 +00:00
|
|
|
#endif
|
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
class ns4xPlugin : public nsIPlugin
|
|
|
|
{
|
|
|
|
public:
|
2004-07-12 15:53:22 +00:00
|
|
|
ns4xPlugin(NPPluginFuncs* callbacks, PRLibrary* aLibrary,
|
2008-09-11 15:10:26 +00:00
|
|
|
NP_PLUGINSHUTDOWN aShutdown);
|
1999-07-07 20:18:27 +00:00
|
|
|
virtual ~ns4xPlugin(void);
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2007-02-17 18:44:42 +00:00
|
|
|
NS_DECL_NSIFACTORY
|
|
|
|
NS_DECL_NSIPLUGIN
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2008-09-11 15:10:26 +00:00
|
|
|
// Constructs and initializes an ns4xPlugin object
|
|
|
|
static nsresult CreatePlugin(const char* aFileName,
|
|
|
|
const char* aFullPath,
|
|
|
|
PRLibrary* aLibrary,
|
|
|
|
nsIPlugin** aResult);
|
2006-07-13 19:47:32 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
void SetPluginRefNum(short aRefNum);
|
1999-07-07 20:18:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2008-09-11 15:10:26 +00:00
|
|
|
// Ensures that the static CALLBACKS is properly initialized
|
1999-07-07 20:18:27 +00:00
|
|
|
static void CheckClassInitialized(void);
|
|
|
|
|
2006-07-13 19:47:32 +00:00
|
|
|
#ifdef XP_MACOSX
|
2000-11-13 21:40:27 +00:00
|
|
|
short fPluginRefNum;
|
|
|
|
#endif
|
|
|
|
|
2008-09-11 15:10:26 +00:00
|
|
|
// The plugin-side callbacks that the browser calls. One set of
|
|
|
|
// plugin callbacks for each plugin.
|
2000-11-13 21:40:27 +00:00
|
|
|
NPPluginFuncs fCallbacks;
|
|
|
|
PRLibrary* fLibrary;
|
|
|
|
|
|
|
|
NP_PLUGINSHUTDOWN fShutdownEntry;
|
|
|
|
|
2008-09-11 15:10:26 +00:00
|
|
|
// The browser-side callbacks that a 4.x-style plugin calls.
|
2000-11-13 21:40:27 +00:00
|
|
|
static NPNetscapeFuncs CALLBACKS;
|
|
|
|
};
|
|
|
|
|
2004-07-12 15:53:22 +00:00
|
|
|
|
|
|
|
PR_BEGIN_EXTERN_C
|
2007-06-27 00:41:08 +00:00
|
|
|
NPObject* NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_getwindowobject(NPP npp);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
NPObject* NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_getpluginelement(NPP npp);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
NPIdentifier NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_getstringidentifier(const NPUTF8* name);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
void NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_getstringidentifiers(const NPUTF8** names, int32_t nameCount,
|
|
|
|
NPIdentifier *identifiers);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_identifierisstring(NPIdentifier identifiers);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
NPIdentifier NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_getintidentifier(int32_t intid);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
NPUTF8* NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_utf8fromidentifier(NPIdentifier identifier);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
int32_t NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_intfromidentifier(NPIdentifier identifier);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
NPObject* NP_CALLBACK
|
2004-07-30 04:00:05 +00:00
|
|
|
_createobject(NPP npp, NPClass* aClass);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
NPObject* NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_retainobject(NPObject* npobj);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
void NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_releaseobject(NPObject* npobj);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2004-08-30 04:31:16 +00:00
|
|
|
_invoke(NPP npp, NPObject* npobj, NPIdentifier method, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2004-08-30 04:31:16 +00:00
|
|
|
_invokeDefault(NPP npp, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2004-07-30 04:00:05 +00:00
|
|
|
_getproperty(NPP npp, NPObject* npobj, NPIdentifier property,
|
|
|
|
NPVariant *result);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2004-07-30 04:00:05 +00:00
|
|
|
_setproperty(NPP npp, NPObject* npobj, NPIdentifier property,
|
|
|
|
const NPVariant *value);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2004-07-30 04:00:05 +00:00
|
|
|
_removeproperty(NPP npp, NPObject* npobj, NPIdentifier property);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2004-07-30 04:00:05 +00:00
|
|
|
_hasproperty(NPP npp, NPObject* npobj, NPIdentifier propertyName);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2004-07-30 04:00:05 +00:00
|
|
|
_hasmethod(NPP npp, NPObject* npobj, NPIdentifier methodName);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
bool NP_CALLBACK
|
2006-03-01 00:13:38 +00:00
|
|
|
_enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier,
|
|
|
|
uint32_t *count);
|
|
|
|
|
2007-10-10 01:24:28 +00:00
|
|
|
bool NP_CALLBACK
|
|
|
|
_construct(NPP npp, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
void NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_releasevariantvalue(NPVariant *variant);
|
|
|
|
|
2007-06-27 00:41:08 +00:00
|
|
|
void NP_CALLBACK
|
2004-07-12 15:53:22 +00:00
|
|
|
_setexception(NPObject* npobj, const NPUTF8 *message);
|
|
|
|
|
|
|
|
PR_END_EXTERN_C
|
|
|
|
|
2004-07-30 04:00:05 +00:00
|
|
|
const char *
|
|
|
|
PeekException();
|
|
|
|
|
|
|
|
void
|
|
|
|
PopException();
|
|
|
|
|
2007-07-11 23:25:45 +00:00
|
|
|
void
|
|
|
|
OnPluginDestroy(NPP instance);
|
|
|
|
|
|
|
|
void
|
|
|
|
OnShutdown();
|
|
|
|
|
|
|
|
void
|
|
|
|
EnterAsyncPluginThreadCallLock();
|
|
|
|
void
|
|
|
|
ExitAsyncPluginThreadCallLock();
|
|
|
|
|
2004-07-30 04:00:05 +00:00
|
|
|
class NPPStack
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static NPP Peek()
|
|
|
|
{
|
|
|
|
return sCurrentNPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static NPP sCurrentNPP;
|
|
|
|
};
|
|
|
|
|
2008-02-29 02:06:00 +00: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
|
2004-07-30 04:00:05 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NPPAutoPusher(NPP npp)
|
2008-02-29 02:06:00 +00:00
|
|
|
: PluginDestructionGuard(npp),
|
|
|
|
mOldNPP(sCurrentNPP)
|
2004-07-30 04:00:05 +00: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-11 15:10:26 +00:00
|
|
|
#endif // ns4xPlugin_h_
|