mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 19:38:13 +00:00
Part of 33105 fix, replaced direct calls to plugins by safe macro, r=serge
This commit is contained in:
parent
111969d988
commit
93ee2b0c9a
@ -30,6 +30,7 @@
|
||||
#include "nsIMemory.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsPluginsDir.h"
|
||||
#include "nsPluginSafety.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Resources.h>
|
||||
@ -38,6 +39,7 @@
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -342,7 +344,11 @@ ns4xPlugin::CreatePlugin(nsIServiceManager* aServiceMgr,
|
||||
}
|
||||
|
||||
// call into the entry point
|
||||
if(CallNPP_MainEntryProc(pfnMain, &(ns4xPlugin::CALLBACKS), &callbacks, &pfnShutdown) != NPERR_NO_ERROR)
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_MainEntryProc(pfnMain,
|
||||
&(ns4xPlugin::CALLBACKS),
|
||||
&callbacks,
|
||||
&pfnShutdown), fLibrary);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
::UseResFile(appRefNum);
|
||||
@ -385,7 +391,7 @@ nsresult ns4xPlugin :: CreateInstance(nsISupports *aOuter,
|
||||
*aResult = NULL;
|
||||
|
||||
// XXX This is suspicuous!
|
||||
ns4xPluginInstance *inst = new ns4xPluginInstance(&fCallbacks);
|
||||
ns4xPluginInstance *inst = new ns4xPluginInstance(&fCallbacks, fLibrary);
|
||||
|
||||
if (inst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -433,7 +439,7 @@ ns4xPlugin::Shutdown(void)
|
||||
::CloseResFile(fPluginRefNum);
|
||||
#endif
|
||||
#else
|
||||
fShutdownEntry();
|
||||
NS_TRY_SAFE_CALL_VOID(fShutdownEntry(), fLibrary);
|
||||
#endif
|
||||
|
||||
fShutdownEntry = nsnull;
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "ns4xPluginInstance.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsPluginHostImpl.h"
|
||||
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
@ -33,6 +34,12 @@
|
||||
#include "gtkmozbox.h"
|
||||
#endif
|
||||
|
||||
#include "nsPluginSafety.h"
|
||||
#include "nsIPref.h" // needed for NS_TRY_SAFE_CALL_*
|
||||
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); // needed for NS_TRY_SAFE_CALL_*
|
||||
static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
|
||||
class ns4xPluginStreamListener : public nsIPluginStreamListener {
|
||||
|
||||
public:
|
||||
@ -122,12 +129,17 @@ ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
#if !TARGET_CARBON
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon. We need to fix this.
|
||||
error = CallNPP_NewStreamProc(callbacks->newstream,
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_NewStreamProc(callbacks->newstream,
|
||||
npp,
|
||||
(char *)contentType,
|
||||
&mNPStream,
|
||||
seekable,
|
||||
&streamType);
|
||||
&streamType), lib);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
@ -182,14 +194,19 @@ ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
while (amountRead > 0)
|
||||
{
|
||||
if (callbacks->writeready != NULL)
|
||||
{
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
numtowrite = CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&mNPStream);
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(numtowrite, CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&mNPStream), lib);
|
||||
#endif
|
||||
|
||||
if (numtowrite > amountRead)
|
||||
@ -208,12 +225,17 @@ ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
writeCount = CallNPP_WriteProc(callbacks->write,
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(writeCount, CallNPP_WriteProc(callbacks->write,
|
||||
npp,
|
||||
&mNPStream,
|
||||
mPosition,
|
||||
numtowrite,
|
||||
(void *)buffer);
|
||||
(void *)buffer), lib);
|
||||
if(writeCount < 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
@ -244,10 +266,15 @@ ns4xPluginStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
CallNPP_StreamAsFileProc(callbacks->asfile,
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_StreamAsFileProc(callbacks->asfile,
|
||||
npp,
|
||||
&mNPStream,
|
||||
fileName);
|
||||
fileName), lib);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
@ -259,7 +286,7 @@ ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
|
||||
{
|
||||
const NPPluginFuncs *callbacks;
|
||||
NPP npp;
|
||||
NPError error;
|
||||
NPError error;
|
||||
|
||||
pluginInfo->GetURL(&mNPStream.url);
|
||||
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
||||
@ -274,10 +301,14 @@ ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
error = CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&mNPStream,
|
||||
NPRES_DONE);
|
||||
NPRES_DONE), lib);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
@ -290,11 +321,16 @@ ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
CallNPP_URLNotifyProc(callbacks->urlnotify,
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_URLNotifyProc(callbacks->urlnotify,
|
||||
npp,
|
||||
mNPStream.url,
|
||||
nsPluginReason_Done,
|
||||
mNotifyData);
|
||||
mNotifyData), lib);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -310,7 +346,7 @@ ns4xPluginStreamListener::GetStreamType(nsPluginStreamType *result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ns4xPluginInstance :: ns4xPluginInstance(NPPluginFuncs* callbacks)
|
||||
ns4xPluginInstance :: ns4xPluginInstance(NPPluginFuncs* callbacks, PRLibrary* aLibrary)
|
||||
: fCallbacks(callbacks)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
@ -322,6 +358,7 @@ ns4xPluginInstance :: ns4xPluginInstance(NPPluginFuncs* callbacks)
|
||||
fNPP.pdata = NULL;
|
||||
fNPP.ndata = this;
|
||||
|
||||
fLibrary = aLibrary;
|
||||
mWindowless = PR_FALSE;
|
||||
mTransparent = PR_FALSE;
|
||||
mStarted = PR_FALSE;
|
||||
@ -403,8 +440,7 @@ NS_IMETHODIMP ns4xPluginInstance::Stop(void)
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
error = (nsresult)CallNPP_DestroyProc(fCallbacks->destroy,
|
||||
&fNPP, &sdata); // saved data
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyProc(fCallbacks->destroy, &fNPP, &sdata), fLibrary);
|
||||
#endif
|
||||
|
||||
mStarted = PR_FALSE;
|
||||
@ -450,36 +486,14 @@ nsresult ns4xPluginInstance::InitializePlugin(nsIPluginInstancePeer* peer)
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon. We need to fix this.
|
||||
|
||||
#if defined(XP_PC) && !defined(XP_OS2)
|
||||
// some really weird thing causes crash on
|
||||
// http://www.vw.com/autoshow/index_flash.html for optimized build
|
||||
// try/catch construction misteriously prevent it
|
||||
try
|
||||
{
|
||||
error = CallNPP_NewProc(fCallbacks->newp,
|
||||
(char *)mimetype,
|
||||
&fNPP,
|
||||
(PRUint16)mode,
|
||||
count,
|
||||
(char**)names,
|
||||
(char**)values,
|
||||
NULL); // saved data
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
#else // XP_PC
|
||||
|
||||
error = CallNPP_NewProc(fCallbacks->newp,
|
||||
(char *)mimetype,
|
||||
&fNPP,
|
||||
(PRUint16)mode,
|
||||
count,
|
||||
(char**)names,
|
||||
(char**)values,
|
||||
NULL); // saved data
|
||||
#endif // not XP_PC
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_NewProc(fCallbacks->newp,
|
||||
(char *)mimetype,
|
||||
&fNPP,
|
||||
(PRUint16)mode,
|
||||
count,
|
||||
(char**)names,
|
||||
(char**)values,
|
||||
NULL), fLibrary);
|
||||
#endif //!TARGET_CARBON
|
||||
|
||||
if(error != NPERR_NO_ERROR)
|
||||
@ -599,9 +613,9 @@ NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
|
||||
fflush(NULL);
|
||||
#endif
|
||||
|
||||
error = CallNPP_SetWindowProc(fCallbacks->setwindow,
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_SetWindowProc(fCallbacks->setwindow,
|
||||
&fNPP,
|
||||
(NPWindow*) window);
|
||||
(NPWindow*) window), fLibrary);
|
||||
#endif
|
||||
|
||||
// XXX In the old code, we'd just ignore any errors coming
|
||||
@ -663,14 +677,15 @@ NS_IMETHODIMP ns4xPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* hand
|
||||
(void*) event->event);
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN //~~~
|
||||
#ifdef XP_WIN
|
||||
NPEvent npEvent;
|
||||
npEvent.event = event->event;
|
||||
npEvent.wParam = event->wParam;
|
||||
npEvent.lParam = event->lParam;
|
||||
res = CallNPP_HandleEventProc(fCallbacks->event,
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(res, CallNPP_HandleEventProc(fCallbacks->event,
|
||||
&fNPP,
|
||||
(void*)&npEvent);
|
||||
(void*)&npEvent), fLibrary);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "nsplugin.h"
|
||||
#include "npupp.h"
|
||||
#include "jri.h"
|
||||
#include "prlink.h" // for PRLibrary
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include <gtk/gtk.h>
|
||||
@ -99,7 +100,7 @@ public:
|
||||
* Construct a new 4.x plugin instance with the specified peer
|
||||
* and callbacks.
|
||||
*/
|
||||
ns4xPluginInstance(NPPluginFuncs* callbacks);
|
||||
ns4xPluginInstance(NPPluginFuncs* callbacks, PRLibrary* aLibrary);
|
||||
|
||||
// Use Release() to destroy this
|
||||
virtual ~ns4xPluginInstance(void);
|
||||
@ -140,10 +141,9 @@ protected:
|
||||
PRBool mWindowless;
|
||||
PRBool mTransparent;
|
||||
PRBool mStarted;
|
||||
|
||||
public:
|
||||
PRLibrary* fLibrary;
|
||||
};
|
||||
|
||||
|
||||
#endif // ns4xPluginInstance_h__
|
||||
|
||||
|
||||
|
||||
|
@ -23,6 +23,9 @@
|
||||
|
||||
#include "ns4xPluginStream.h"
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
#include "nsPluginSafety.h"
|
||||
|
||||
static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -52,10 +55,14 @@ ns4xPluginStream::~ns4xPluginStream(void)
|
||||
|
||||
if (callbacks->destroystream != NULL)
|
||||
{
|
||||
CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&fNPStream,
|
||||
reason);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&fNPStream,
|
||||
reason), lib);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(fPeer);
|
||||
@ -147,17 +154,22 @@ NS_IMETHODIMP ns4xPluginStream::Initialize(ns4xPluginInstance* instance,
|
||||
|
||||
PRUint16 streamType = (PRUint16) fStreamType;
|
||||
|
||||
nsresult error
|
||||
= (nsresult)CallNPP_NewStreamProc(callbacks->newstream,
|
||||
npp,
|
||||
(char *)mimetype,
|
||||
&fNPStream,
|
||||
fSeekable,
|
||||
&streamType);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NP_ERROR error = NS_OK;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_NewStreamProc(callbacks->newstream,
|
||||
npp,
|
||||
(char *)mimetype,
|
||||
&fNPStream,
|
||||
fSeekable,
|
||||
&streamType), lib);
|
||||
|
||||
fStreamType = (nsPluginStreamType) streamType;
|
||||
|
||||
return error;
|
||||
return (nsresult)error;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRUint32 offset, PRUint32 len, PRUint32 *aWriteCount)
|
||||
@ -178,9 +190,13 @@ NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRUint32 offset, PRUin
|
||||
|
||||
if (callbacks->writeready != NULL)
|
||||
{
|
||||
numtowrite = CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&fNPStream);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(numtowrite, CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&fNPStream), lib);
|
||||
|
||||
if (numtowrite > remaining)
|
||||
numtowrite = remaining;
|
||||
@ -188,12 +204,16 @@ NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRUint32 offset, PRUin
|
||||
else
|
||||
numtowrite = (int32)len;
|
||||
|
||||
*aWriteCount = CallNPP_WriteProc(callbacks->write,
|
||||
npp,
|
||||
&fNPStream,
|
||||
fPosition,
|
||||
numtowrite,
|
||||
(void *)buffer);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(*aWriteCount, CallNPP_WriteProc(callbacks->write,
|
||||
npp,
|
||||
&fNPStream,
|
||||
fPosition,
|
||||
numtowrite,
|
||||
(void *)buffer), lib);
|
||||
|
||||
remaining -= numtowrite;
|
||||
}
|
||||
@ -220,10 +240,14 @@ NS_IMETHODIMP ns4xPluginStream::AsFile(const char* filename)
|
||||
if (callbacks->asfile == NULL)
|
||||
return NS_OK;
|
||||
|
||||
CallNPP_StreamAsFileProc(callbacks->asfile,
|
||||
npp,
|
||||
&fNPStream,
|
||||
filename);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_StreamAsFileProc(callbacks->asfile,
|
||||
npp,
|
||||
&fNPStream,
|
||||
filename), lib);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "nsIMemory.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsPluginsDir.h"
|
||||
#include "nsPluginSafety.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Resources.h>
|
||||
@ -38,6 +39,7 @@
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -342,7 +344,11 @@ ns4xPlugin::CreatePlugin(nsIServiceManager* aServiceMgr,
|
||||
}
|
||||
|
||||
// call into the entry point
|
||||
if(CallNPP_MainEntryProc(pfnMain, &(ns4xPlugin::CALLBACKS), &callbacks, &pfnShutdown) != NPERR_NO_ERROR)
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_MainEntryProc(pfnMain,
|
||||
&(ns4xPlugin::CALLBACKS),
|
||||
&callbacks,
|
||||
&pfnShutdown), fLibrary);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
::UseResFile(appRefNum);
|
||||
@ -385,7 +391,7 @@ nsresult ns4xPlugin :: CreateInstance(nsISupports *aOuter,
|
||||
*aResult = NULL;
|
||||
|
||||
// XXX This is suspicuous!
|
||||
ns4xPluginInstance *inst = new ns4xPluginInstance(&fCallbacks);
|
||||
ns4xPluginInstance *inst = new ns4xPluginInstance(&fCallbacks, fLibrary);
|
||||
|
||||
if (inst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -433,7 +439,7 @@ ns4xPlugin::Shutdown(void)
|
||||
::CloseResFile(fPluginRefNum);
|
||||
#endif
|
||||
#else
|
||||
fShutdownEntry();
|
||||
NS_TRY_SAFE_CALL_VOID(fShutdownEntry(), fLibrary);
|
||||
#endif
|
||||
|
||||
fShutdownEntry = nsnull;
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "ns4xPluginInstance.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsPluginHostImpl.h"
|
||||
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
@ -33,6 +34,12 @@
|
||||
#include "gtkmozbox.h"
|
||||
#endif
|
||||
|
||||
#include "nsPluginSafety.h"
|
||||
#include "nsIPref.h" // needed for NS_TRY_SAFE_CALL_*
|
||||
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); // needed for NS_TRY_SAFE_CALL_*
|
||||
static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
|
||||
class ns4xPluginStreamListener : public nsIPluginStreamListener {
|
||||
|
||||
public:
|
||||
@ -122,12 +129,17 @@ ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
#if !TARGET_CARBON
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon. We need to fix this.
|
||||
error = CallNPP_NewStreamProc(callbacks->newstream,
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_NewStreamProc(callbacks->newstream,
|
||||
npp,
|
||||
(char *)contentType,
|
||||
&mNPStream,
|
||||
seekable,
|
||||
&streamType);
|
||||
&streamType), lib);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
@ -182,14 +194,19 @@ ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
while (amountRead > 0)
|
||||
{
|
||||
if (callbacks->writeready != NULL)
|
||||
{
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
numtowrite = CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&mNPStream);
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(numtowrite, CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&mNPStream), lib);
|
||||
#endif
|
||||
|
||||
if (numtowrite > amountRead)
|
||||
@ -208,12 +225,17 @@ ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
writeCount = CallNPP_WriteProc(callbacks->write,
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(writeCount, CallNPP_WriteProc(callbacks->write,
|
||||
npp,
|
||||
&mNPStream,
|
||||
mPosition,
|
||||
numtowrite,
|
||||
(void *)buffer);
|
||||
(void *)buffer), lib);
|
||||
if(writeCount < 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
@ -244,10 +266,15 @@ ns4xPluginStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
CallNPP_StreamAsFileProc(callbacks->asfile,
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_StreamAsFileProc(callbacks->asfile,
|
||||
npp,
|
||||
&mNPStream,
|
||||
fileName);
|
||||
fileName), lib);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
@ -259,7 +286,7 @@ ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
|
||||
{
|
||||
const NPPluginFuncs *callbacks;
|
||||
NPP npp;
|
||||
NPError error;
|
||||
NPError error;
|
||||
|
||||
pluginInfo->GetURL(&mNPStream.url);
|
||||
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
||||
@ -274,10 +301,14 @@ ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
error = CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&mNPStream,
|
||||
NPRES_DONE);
|
||||
NPRES_DONE), lib);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
@ -290,11 +321,16 @@ ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
CallNPP_URLNotifyProc(callbacks->urlnotify,
|
||||
|
||||
PRLibrary* lib = nsnull;
|
||||
if(mInst)
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_URLNotifyProc(callbacks->urlnotify,
|
||||
npp,
|
||||
mNPStream.url,
|
||||
nsPluginReason_Done,
|
||||
mNotifyData);
|
||||
mNotifyData), lib);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -310,7 +346,7 @@ ns4xPluginStreamListener::GetStreamType(nsPluginStreamType *result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ns4xPluginInstance :: ns4xPluginInstance(NPPluginFuncs* callbacks)
|
||||
ns4xPluginInstance :: ns4xPluginInstance(NPPluginFuncs* callbacks, PRLibrary* aLibrary)
|
||||
: fCallbacks(callbacks)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
@ -322,6 +358,7 @@ ns4xPluginInstance :: ns4xPluginInstance(NPPluginFuncs* callbacks)
|
||||
fNPP.pdata = NULL;
|
||||
fNPP.ndata = this;
|
||||
|
||||
fLibrary = aLibrary;
|
||||
mWindowless = PR_FALSE;
|
||||
mTransparent = PR_FALSE;
|
||||
mStarted = PR_FALSE;
|
||||
@ -403,8 +440,7 @@ NS_IMETHODIMP ns4xPluginInstance::Stop(void)
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon.
|
||||
// We need to fix this.
|
||||
error = (nsresult)CallNPP_DestroyProc(fCallbacks->destroy,
|
||||
&fNPP, &sdata); // saved data
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyProc(fCallbacks->destroy, &fNPP, &sdata), fLibrary);
|
||||
#endif
|
||||
|
||||
mStarted = PR_FALSE;
|
||||
@ -450,36 +486,14 @@ nsresult ns4xPluginInstance::InitializePlugin(nsIPluginInstancePeer* peer)
|
||||
// pinkerton
|
||||
// relies on routine descriptors, not present in carbon. We need to fix this.
|
||||
|
||||
#if defined(XP_PC) && !defined(XP_OS2)
|
||||
// some really weird thing causes crash on
|
||||
// http://www.vw.com/autoshow/index_flash.html for optimized build
|
||||
// try/catch construction misteriously prevent it
|
||||
try
|
||||
{
|
||||
error = CallNPP_NewProc(fCallbacks->newp,
|
||||
(char *)mimetype,
|
||||
&fNPP,
|
||||
(PRUint16)mode,
|
||||
count,
|
||||
(char**)names,
|
||||
(char**)values,
|
||||
NULL); // saved data
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
#else // XP_PC
|
||||
|
||||
error = CallNPP_NewProc(fCallbacks->newp,
|
||||
(char *)mimetype,
|
||||
&fNPP,
|
||||
(PRUint16)mode,
|
||||
count,
|
||||
(char**)names,
|
||||
(char**)values,
|
||||
NULL); // saved data
|
||||
#endif // not XP_PC
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_NewProc(fCallbacks->newp,
|
||||
(char *)mimetype,
|
||||
&fNPP,
|
||||
(PRUint16)mode,
|
||||
count,
|
||||
(char**)names,
|
||||
(char**)values,
|
||||
NULL), fLibrary);
|
||||
#endif //!TARGET_CARBON
|
||||
|
||||
if(error != NPERR_NO_ERROR)
|
||||
@ -599,9 +613,9 @@ NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
|
||||
fflush(NULL);
|
||||
#endif
|
||||
|
||||
error = CallNPP_SetWindowProc(fCallbacks->setwindow,
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_SetWindowProc(fCallbacks->setwindow,
|
||||
&fNPP,
|
||||
(NPWindow*) window);
|
||||
(NPWindow*) window), fLibrary);
|
||||
#endif
|
||||
|
||||
// XXX In the old code, we'd just ignore any errors coming
|
||||
@ -663,14 +677,15 @@ NS_IMETHODIMP ns4xPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* hand
|
||||
(void*) event->event);
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN //~~~
|
||||
#ifdef XP_WIN
|
||||
NPEvent npEvent;
|
||||
npEvent.event = event->event;
|
||||
npEvent.wParam = event->wParam;
|
||||
npEvent.lParam = event->lParam;
|
||||
res = CallNPP_HandleEventProc(fCallbacks->event,
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(res, CallNPP_HandleEventProc(fCallbacks->event,
|
||||
&fNPP,
|
||||
(void*)&npEvent);
|
||||
(void*)&npEvent), fLibrary);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "nsplugin.h"
|
||||
#include "npupp.h"
|
||||
#include "jri.h"
|
||||
#include "prlink.h" // for PRLibrary
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include <gtk/gtk.h>
|
||||
@ -99,7 +100,7 @@ public:
|
||||
* Construct a new 4.x plugin instance with the specified peer
|
||||
* and callbacks.
|
||||
*/
|
||||
ns4xPluginInstance(NPPluginFuncs* callbacks);
|
||||
ns4xPluginInstance(NPPluginFuncs* callbacks, PRLibrary* aLibrary);
|
||||
|
||||
// Use Release() to destroy this
|
||||
virtual ~ns4xPluginInstance(void);
|
||||
@ -140,10 +141,9 @@ protected:
|
||||
PRBool mWindowless;
|
||||
PRBool mTransparent;
|
||||
PRBool mStarted;
|
||||
|
||||
public:
|
||||
PRLibrary* fLibrary;
|
||||
};
|
||||
|
||||
|
||||
#endif // ns4xPluginInstance_h__
|
||||
|
||||
|
||||
|
||||
|
@ -23,6 +23,9 @@
|
||||
|
||||
#include "ns4xPluginStream.h"
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
#include "nsPluginSafety.h"
|
||||
|
||||
static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -52,10 +55,14 @@ ns4xPluginStream::~ns4xPluginStream(void)
|
||||
|
||||
if (callbacks->destroystream != NULL)
|
||||
{
|
||||
CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&fNPStream,
|
||||
reason);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&fNPStream,
|
||||
reason), lib);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(fPeer);
|
||||
@ -147,17 +154,22 @@ NS_IMETHODIMP ns4xPluginStream::Initialize(ns4xPluginInstance* instance,
|
||||
|
||||
PRUint16 streamType = (PRUint16) fStreamType;
|
||||
|
||||
nsresult error
|
||||
= (nsresult)CallNPP_NewStreamProc(callbacks->newstream,
|
||||
npp,
|
||||
(char *)mimetype,
|
||||
&fNPStream,
|
||||
fSeekable,
|
||||
&streamType);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NP_ERROR error = NS_OK;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_NewStreamProc(callbacks->newstream,
|
||||
npp,
|
||||
(char *)mimetype,
|
||||
&fNPStream,
|
||||
fSeekable,
|
||||
&streamType), lib);
|
||||
|
||||
fStreamType = (nsPluginStreamType) streamType;
|
||||
|
||||
return error;
|
||||
return (nsresult)error;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRUint32 offset, PRUint32 len, PRUint32 *aWriteCount)
|
||||
@ -178,9 +190,13 @@ NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRUint32 offset, PRUin
|
||||
|
||||
if (callbacks->writeready != NULL)
|
||||
{
|
||||
numtowrite = CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&fNPStream);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(numtowrite, CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&fNPStream), lib);
|
||||
|
||||
if (numtowrite > remaining)
|
||||
numtowrite = remaining;
|
||||
@ -188,12 +204,16 @@ NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRUint32 offset, PRUin
|
||||
else
|
||||
numtowrite = (int32)len;
|
||||
|
||||
*aWriteCount = CallNPP_WriteProc(callbacks->write,
|
||||
npp,
|
||||
&fNPStream,
|
||||
fPosition,
|
||||
numtowrite,
|
||||
(void *)buffer);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(*aWriteCount, CallNPP_WriteProc(callbacks->write,
|
||||
npp,
|
||||
&fNPStream,
|
||||
fPosition,
|
||||
numtowrite,
|
||||
(void *)buffer), lib);
|
||||
|
||||
remaining -= numtowrite;
|
||||
}
|
||||
@ -220,10 +240,14 @@ NS_IMETHODIMP ns4xPluginStream::AsFile(const char* filename)
|
||||
if (callbacks->asfile == NULL)
|
||||
return NS_OK;
|
||||
|
||||
CallNPP_StreamAsFileProc(callbacks->asfile,
|
||||
npp,
|
||||
&fNPStream,
|
||||
filename);
|
||||
PRLibrary* lib = nsnull;
|
||||
if(fInstance)
|
||||
lib = fInstance->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_StreamAsFileProc(callbacks->asfile,
|
||||
npp,
|
||||
&fNPStream,
|
||||
filename), lib);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user