зеркало из https://github.com/mozilla/pjs.git
Fixing 91140, the Acrobat blocker -- latering plugin stream destruction, r=peterl, bnesse, sr=vidur
This commit is contained in:
Родитель
299252d49c
Коммит
c91c7ae93b
|
@ -50,22 +50,94 @@ static NS_DEFINE_IID(kIPluginStreamListener2IID, NS_IPLUGINSTREAMLISTENER2_IID);
|
|||
ns4xPluginStreamListener::ns4xPluginStreamListener(nsIPluginInstance* inst,
|
||||
void* notifyData)
|
||||
: mNotifyData(notifyData),
|
||||
mStreamInfo(nsnull)
|
||||
mStreamInfo(nsnull),
|
||||
mStreamStarted(PR_FALSE),
|
||||
mStreamCleanedUp(PR_FALSE)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInst = (ns4xPluginInstance*) inst;
|
||||
mStreamBuffer=nsnull;
|
||||
mPosition = 0;
|
||||
mCurrentStreamOffset = -1;
|
||||
// Initialize the 4.x interface structure
|
||||
memset(&mNPStream, 0, sizeof(mNPStream));
|
||||
NS_INIT_REFCNT();
|
||||
mInst = (ns4xPluginInstance*) inst;
|
||||
mStreamBuffer=nsnull;
|
||||
mPosition = 0;
|
||||
mCurrentStreamOffset = -1;
|
||||
// Initialize the 4.x interface structure
|
||||
memset(&mNPStream, 0, sizeof(mNPStream));
|
||||
|
||||
NS_IF_ADDREF(mInst);
|
||||
NS_IF_ADDREF(mInst);
|
||||
}
|
||||
|
||||
ns4xPluginStreamListener::~ns4xPluginStreamListener(void)
|
||||
{
|
||||
NS_IF_RELEASE(mInst);
|
||||
#ifdef NS_DEBUG
|
||||
printf("ns4xPluginStreamListener::~ns4xPluginStreamListener\n");
|
||||
#endif
|
||||
CleanUpStream();
|
||||
NS_IF_RELEASE(mInst);
|
||||
}
|
||||
|
||||
nsresult ns4xPluginStreamListener::CleanUpStream()
|
||||
{
|
||||
if(!mStreamStarted || mStreamCleanedUp)
|
||||
return NS_OK;
|
||||
|
||||
if(!mInst)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NPP npp;
|
||||
const NPPluginFuncs *callbacks = nsnull;
|
||||
|
||||
mInst->GetCallbacks(&callbacks);
|
||||
mInst->GetNPP(&npp);
|
||||
|
||||
if(!callbacks)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NPError error;
|
||||
|
||||
if (callbacks->destroystream != NULL)
|
||||
{
|
||||
// XXX need to convert status to NPReason
|
||||
PRLibrary* lib = nsnull;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
printf("calling NPP_DestroyStream\n");
|
||||
#endif
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&mNPStream,
|
||||
NPRES_DONE), lib);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// check to see if we have a call back and a
|
||||
// XXX nasty hack for Shockwave Registration.
|
||||
// we seem to crash doing URLNotify so just always exclude it.
|
||||
// See bug 85334.
|
||||
if (callbacks->urlnotify != NULL && mNotifyData != nsnull &&
|
||||
strcmp(mNPStream.url,"http://pinger.macromedia.com") < 0 )
|
||||
{
|
||||
PRLibrary* lib = nsnull;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_URLNotifyProc(callbacks->urlnotify,
|
||||
npp,
|
||||
mNPStream.url,
|
||||
nsPluginReason_Done,
|
||||
mNotifyData), lib);
|
||||
}
|
||||
|
||||
// lets get rid of the buffer if we made one globally
|
||||
if (mStreamBuffer)
|
||||
{
|
||||
PR_Free(mStreamBuffer);
|
||||
mStreamBuffer=nsnull;
|
||||
}
|
||||
|
||||
mStreamCleanedUp = PR_TRUE;
|
||||
mStreamStarted = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(ns4xPluginStreamListener, nsIPluginStreamListener,
|
||||
|
@ -144,6 +216,7 @@ ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mStreamStarted = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -447,62 +520,27 @@ NS_IMETHODIMP
|
|||
ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
|
||||
nsresult status)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf("ns4xPluginStreamListener::OnStopBinding\n");
|
||||
#endif
|
||||
|
||||
if(!mInst || !mInst->IsStarted())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NPP npp;
|
||||
const NPPluginFuncs *callbacks = nsnull;
|
||||
if(pluginInfo) {
|
||||
pluginInfo->GetURL(&mNPStream.url);
|
||||
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
||||
}
|
||||
|
||||
mInst->GetCallbacks(&callbacks);
|
||||
mInst->GetNPP(&npp);
|
||||
|
||||
if(!callbacks)
|
||||
// check if the stream is not of asfileonly type and later its destruction
|
||||
// see bug 91140
|
||||
nsresult rv = NS_OK;
|
||||
if(mStreamType == nsPluginStreamType_AsFileOnly)
|
||||
rv = CleanUpStream();
|
||||
|
||||
if(rv != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NPError error;
|
||||
|
||||
pluginInfo->GetURL(&mNPStream.url);
|
||||
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
||||
|
||||
if (callbacks->destroystream != NULL)
|
||||
{
|
||||
// XXX need to convert status to NPReason
|
||||
PRLibrary* lib = nsnull;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&mNPStream,
|
||||
NPRES_DONE), lib);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// check to see if we have a call back and a
|
||||
// XXX nasty hack for Shockwave Registration.
|
||||
// we seem to crash doing URLNotify so just always exclude it.
|
||||
// See bug 85334.
|
||||
if (callbacks->urlnotify != NULL && mNotifyData != nsnull &&
|
||||
strcmp(mNPStream.url,"http://pinger.macromedia.com") < 0 )
|
||||
{
|
||||
PRLibrary* lib = nsnull;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_URLNotifyProc(callbacks->urlnotify,
|
||||
npp,
|
||||
mNPStream.url,
|
||||
nsPluginReason_Done,
|
||||
mNotifyData), lib);
|
||||
}
|
||||
|
||||
|
||||
// lets get rid of the buffer if we made one globally
|
||||
if (mStreamBuffer)
|
||||
{
|
||||
PR_Free(mStreamBuffer);
|
||||
mStreamBuffer=nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
ns4xPluginStreamListener(nsIPluginInstance* inst, void* notifyData);
|
||||
virtual ~ns4xPluginStreamListener();
|
||||
PRBool IsStarted();
|
||||
nsresult CleanUpStream();
|
||||
|
||||
protected:
|
||||
void* mNotifyData;
|
||||
|
@ -57,6 +58,8 @@ protected:
|
|||
PRUint32 mPosition;
|
||||
PRUint32 mCurrentStreamOffset;
|
||||
nsPluginStreamType mStreamType;
|
||||
PRBool mStreamStarted;
|
||||
PRBool mStreamCleanedUp;
|
||||
|
||||
public:
|
||||
nsIPluginStreamInfo * mStreamInfo;
|
||||
|
|
|
@ -50,22 +50,94 @@ static NS_DEFINE_IID(kIPluginStreamListener2IID, NS_IPLUGINSTREAMLISTENER2_IID);
|
|||
ns4xPluginStreamListener::ns4xPluginStreamListener(nsIPluginInstance* inst,
|
||||
void* notifyData)
|
||||
: mNotifyData(notifyData),
|
||||
mStreamInfo(nsnull)
|
||||
mStreamInfo(nsnull),
|
||||
mStreamStarted(PR_FALSE),
|
||||
mStreamCleanedUp(PR_FALSE)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInst = (ns4xPluginInstance*) inst;
|
||||
mStreamBuffer=nsnull;
|
||||
mPosition = 0;
|
||||
mCurrentStreamOffset = -1;
|
||||
// Initialize the 4.x interface structure
|
||||
memset(&mNPStream, 0, sizeof(mNPStream));
|
||||
NS_INIT_REFCNT();
|
||||
mInst = (ns4xPluginInstance*) inst;
|
||||
mStreamBuffer=nsnull;
|
||||
mPosition = 0;
|
||||
mCurrentStreamOffset = -1;
|
||||
// Initialize the 4.x interface structure
|
||||
memset(&mNPStream, 0, sizeof(mNPStream));
|
||||
|
||||
NS_IF_ADDREF(mInst);
|
||||
NS_IF_ADDREF(mInst);
|
||||
}
|
||||
|
||||
ns4xPluginStreamListener::~ns4xPluginStreamListener(void)
|
||||
{
|
||||
NS_IF_RELEASE(mInst);
|
||||
#ifdef NS_DEBUG
|
||||
printf("ns4xPluginStreamListener::~ns4xPluginStreamListener\n");
|
||||
#endif
|
||||
CleanUpStream();
|
||||
NS_IF_RELEASE(mInst);
|
||||
}
|
||||
|
||||
nsresult ns4xPluginStreamListener::CleanUpStream()
|
||||
{
|
||||
if(!mStreamStarted || mStreamCleanedUp)
|
||||
return NS_OK;
|
||||
|
||||
if(!mInst)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NPP npp;
|
||||
const NPPluginFuncs *callbacks = nsnull;
|
||||
|
||||
mInst->GetCallbacks(&callbacks);
|
||||
mInst->GetNPP(&npp);
|
||||
|
||||
if(!callbacks)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NPError error;
|
||||
|
||||
if (callbacks->destroystream != NULL)
|
||||
{
|
||||
// XXX need to convert status to NPReason
|
||||
PRLibrary* lib = nsnull;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
printf("calling NPP_DestroyStream\n");
|
||||
#endif
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&mNPStream,
|
||||
NPRES_DONE), lib);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// check to see if we have a call back and a
|
||||
// XXX nasty hack for Shockwave Registration.
|
||||
// we seem to crash doing URLNotify so just always exclude it.
|
||||
// See bug 85334.
|
||||
if (callbacks->urlnotify != NULL && mNotifyData != nsnull &&
|
||||
strcmp(mNPStream.url,"http://pinger.macromedia.com") < 0 )
|
||||
{
|
||||
PRLibrary* lib = nsnull;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_URLNotifyProc(callbacks->urlnotify,
|
||||
npp,
|
||||
mNPStream.url,
|
||||
nsPluginReason_Done,
|
||||
mNotifyData), lib);
|
||||
}
|
||||
|
||||
// lets get rid of the buffer if we made one globally
|
||||
if (mStreamBuffer)
|
||||
{
|
||||
PR_Free(mStreamBuffer);
|
||||
mStreamBuffer=nsnull;
|
||||
}
|
||||
|
||||
mStreamCleanedUp = PR_TRUE;
|
||||
mStreamStarted = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(ns4xPluginStreamListener, nsIPluginStreamListener,
|
||||
|
@ -144,6 +216,7 @@ ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mStreamStarted = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -447,62 +520,27 @@ NS_IMETHODIMP
|
|||
ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
|
||||
nsresult status)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf("ns4xPluginStreamListener::OnStopBinding\n");
|
||||
#endif
|
||||
|
||||
if(!mInst || !mInst->IsStarted())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NPP npp;
|
||||
const NPPluginFuncs *callbacks = nsnull;
|
||||
if(pluginInfo) {
|
||||
pluginInfo->GetURL(&mNPStream.url);
|
||||
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
||||
}
|
||||
|
||||
mInst->GetCallbacks(&callbacks);
|
||||
mInst->GetNPP(&npp);
|
||||
|
||||
if(!callbacks)
|
||||
// check if the stream is not of asfileonly type and later its destruction
|
||||
// see bug 91140
|
||||
nsresult rv = NS_OK;
|
||||
if(mStreamType == nsPluginStreamType_AsFileOnly)
|
||||
rv = CleanUpStream();
|
||||
|
||||
if(rv != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NPError error;
|
||||
|
||||
pluginInfo->GetURL(&mNPStream.url);
|
||||
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
||||
|
||||
if (callbacks->destroystream != NULL)
|
||||
{
|
||||
// XXX need to convert status to NPReason
|
||||
PRLibrary* lib = nsnull;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyStreamProc(callbacks->destroystream,
|
||||
npp,
|
||||
&mNPStream,
|
||||
NPRES_DONE), lib);
|
||||
if(error != NPERR_NO_ERROR)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// check to see if we have a call back and a
|
||||
// XXX nasty hack for Shockwave Registration.
|
||||
// we seem to crash doing URLNotify so just always exclude it.
|
||||
// See bug 85334.
|
||||
if (callbacks->urlnotify != NULL && mNotifyData != nsnull &&
|
||||
strcmp(mNPStream.url,"http://pinger.macromedia.com") < 0 )
|
||||
{
|
||||
PRLibrary* lib = nsnull;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_VOID(CallNPP_URLNotifyProc(callbacks->urlnotify,
|
||||
npp,
|
||||
mNPStream.url,
|
||||
nsPluginReason_Done,
|
||||
mNotifyData), lib);
|
||||
}
|
||||
|
||||
|
||||
// lets get rid of the buffer if we made one globally
|
||||
if (mStreamBuffer)
|
||||
{
|
||||
PR_Free(mStreamBuffer);
|
||||
mStreamBuffer=nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef ns4xPluginStreamListener_h__
|
||||
#define ns4xPluginStreamListener_h__
|
||||
|
||||
#include "nsIPluginStreamListener2.h"
|
||||
#include "nsIPluginStreamInfo.h"
|
||||
|
||||
#define MAX_PLUGIN_NECKO_BUFFER 16384
|
||||
|
||||
class ns4xPluginStreamListener : public nsIPluginStreamListener2
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// from nsIPluginStreamListener:
|
||||
NS_IMETHOD OnStartBinding(nsIPluginStreamInfo* pluginInfo);
|
||||
NS_IMETHOD OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length, PRUint32 offset);
|
||||
NS_IMETHOD OnFileAvailable( nsIPluginStreamInfo* pluginInfo, const char* fileName);
|
||||
NS_IMETHOD OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
|
||||
NS_IMETHOD GetStreamType(nsPluginStreamType *result);
|
||||
|
||||
NS_IMETHOD OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
PRUint32 length);
|
||||
|
||||
// ns4xPluginStreamListener specific methods:
|
||||
ns4xPluginStreamListener(nsIPluginInstance* inst, void* notifyData);
|
||||
virtual ~ns4xPluginStreamListener();
|
||||
PRBool IsStarted();
|
||||
|
||||
protected:
|
||||
void* mNotifyData;
|
||||
char* mStreamBuffer;
|
||||
ns4xPluginInstance* mInst;
|
||||
NPStream mNPStream;
|
||||
PRUint32 mPosition;
|
||||
PRUint32 mCurrentStreamOffset;
|
||||
nsPluginStreamType mStreamType;
|
||||
|
||||
public:
|
||||
nsIPluginStreamInfo * mStreamInfo;
|
||||
};
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче