Bug 17732 -- fixing streaming API from plugin to browser, some formatting fixed, r=peterl, sr=rpotts

This commit is contained in:
av%netscape.com 2001-12-29 22:10:07 +00:00
Родитель 99af556ca2
Коммит b5ca9a2c4d
3 изменённых файлов: 173 добавлений и 263 удалений

Просмотреть файл

@ -814,8 +814,11 @@ _posturl(NPP npp, const char *relativeURL, const char *target,
// A little helper class used to wrap up plugin manager streams (that is, // A little helper class used to wrap up plugin manager streams (that is,
// streams from the plugin to the browser). // streams from the plugin to the browser).
class ns4xStreamWrapper class ns4xStreamWrapper : nsISupports
{ {
public:
NS_DECL_ISUPPORTS
protected: protected:
nsIOutputStream *fStream; nsIOutputStream *fStream;
NPStream fNPStream; NPStream fNPStream;
@ -828,6 +831,8 @@ public:
NPStream* GetNPStream(void) { return &fNPStream; }; NPStream* GetNPStream(void) { return &fNPStream; };
}; };
NS_IMPL_ISUPPORTS1(ns4xStreamWrapper, nsISupports);
ns4xStreamWrapper::ns4xStreamWrapper(nsIOutputStream* stream) ns4xStreamWrapper::ns4xStreamWrapper(nsIOutputStream* stream)
: fStream(stream) : fStream(stream)
{ {

Просмотреть файл

@ -73,8 +73,7 @@ nsPluginInstancePeerImpl::~nsPluginInstancePeerImpl()
mInstance = nsnull; mInstance = nsnull;
NS_IF_RELEASE(mOwner); NS_IF_RELEASE(mOwner);
if (nsnull != mMIMEType) if (nsnull != mMIMEType) {
{
PR_Free((void *)mMIMEType); PR_Free((void *)mMIMEType);
mMIMEType = nsnull; mMIMEType = nsnull;
} }
@ -91,52 +90,46 @@ NS_IMPL_RELEASE(nsPluginInstancePeerImpl);
nsresult nsPluginInstancePeerImpl::QueryInterface(const nsIID& iid, void** instance) nsresult nsPluginInstancePeerImpl::QueryInterface(const nsIID& iid, void** instance)
{ {
if (instance == NULL) if (instance == NULL)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
if (iid.Equals(NS_GET_IID(nsIPluginInstancePeer)) || iid.Equals(NS_GET_IID(nsIPluginInstancePeer2))) if (iid.Equals(NS_GET_IID(nsIPluginInstancePeer)) || iid.Equals(NS_GET_IID(nsIPluginInstancePeer2))) {
{ *instance = (void *)(nsIPluginInstancePeer2*)this;
*instance = (void *)(nsIPluginInstancePeer2*)this; AddRef();
AddRef(); return NS_OK;
return NS_OK; }
}
if (iid.Equals(kIWindowlessPluginInstancePeerIID))//~~~ if (iid.Equals(kIWindowlessPluginInstancePeerIID)) {
{ *instance = (void *)(nsIWindowlessPluginInstancePeer*)this;
*instance = (void *)(nsIWindowlessPluginInstancePeer*)this; AddRef();
AddRef(); return NS_OK;
return NS_OK; }
}
if (iid.Equals(kIPluginTagInfoIID)) if (iid.Equals(kIPluginTagInfoIID)) {
{ *instance = (void *)(nsIPluginTagInfo *)this;
*instance = (void *)(nsIPluginTagInfo *)this; AddRef();
AddRef(); return NS_OK;
return NS_OK; }
}
if (iid.Equals(kIPluginTagInfo2IID)) if (iid.Equals(kIPluginTagInfo2IID)) {
{ *instance = (void *)(nsIPluginTagInfo2 *)this;
*instance = (void *)(nsIPluginTagInfo2 *)this; AddRef();
AddRef(); return NS_OK;
return NS_OK; }
}
if (iid.Equals(kIJVMPluginTagInfoIID)) if (iid.Equals(kIJVMPluginTagInfoIID)) {
{ *instance = (void *)(nsIJVMPluginTagInfo *)this;
*instance = (void *)(nsIJVMPluginTagInfo *)this; AddRef();
AddRef(); return NS_OK;
return NS_OK; }
}
if (iid.Equals(kISupportsIID)) if (iid.Equals(kISupportsIID)) {
{ *instance = (void *)(nsISupports *)(nsIPluginTagInfo *)this;
*instance = (void *)(nsISupports *)(nsIPluginTagInfo *)this; AddRef();
AddRef(); return NS_OK;
return NS_OK; }
}
return NS_NOINTERFACE; return NS_NOINTERFACE;
} }
NS_IMETHODIMP nsPluginInstancePeerImpl::GetValue(nsPluginInstancePeerVariable variable, void *value) NS_IMETHODIMP nsPluginInstancePeerImpl::GetValue(nsPluginInstancePeerVariable variable, void *value)
@ -177,82 +170,79 @@ class nsPluginStreamToFile : public nsIOutputStream
{ {
public: public:
nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner); nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner);
virtual ~nsPluginStreamToFile(); virtual ~nsPluginStreamToFile();
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTPUTSTREAM
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTPUTSTREAM
protected: protected:
char* mTarget; char* mTarget;
nsFileURL mFileURL; nsFileURL mFileURL;
nsFileSpec mFileSpec; nsFileSpec mFileSpec;
nsCOMPtr<nsIFileSpecOutputStream> mFileThing; nsCOMPtr<nsIFileSpecOutputStream> mFileThing;
nsIPluginInstanceOwner* mOwner; nsIPluginInstanceOwner* mOwner;
}; };
NS_IMPL_ADDREF(nsPluginStreamToFile); NS_IMPL_ADDREF(nsPluginStreamToFile);
NS_IMPL_RELEASE(nsPluginStreamToFile); NS_IMPL_RELEASE(nsPluginStreamToFile);
nsPluginStreamToFile::nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner) nsPluginStreamToFile::nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner) :
: mTarget(PL_strdup(target)) mTarget(PL_strdup(target)),
, mFileURL(nsnull) mFileURL(nsnull),
, mOwner(owner) mOwner(owner)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
// open the file and prepare it for writing // open the file and prepare it for writing
char buf[400], tpath[300]; char buf[400], tpath[300];
#ifdef XP_PC #ifdef XP_PC
#ifdef XP_OS2 #ifdef XP_OS2
PL_strcpy(tpath, getenv("TEMP")); PL_strcpy(tpath, getenv("TEMP"));
#else #else
::GetTempPath(sizeof(tpath), tpath); ::GetTempPath(sizeof(tpath), tpath);
#endif #endif
PRInt32 len = PL_strlen(tpath); PRInt32 len = PL_strlen(tpath);
if ((len > 0) && (tpath[len-1] != '\\')) if ((len > 0) && (tpath[len-1] != '\\')) {
{ tpath[len] = '\\';
tpath[len] = '\\'; tpath[len+1] = 0;
tpath[len+1] = 0; }
}
#elif defined (XP_UNIX) || defined (XP_BEOS) #elif defined (XP_UNIX) || defined (XP_BEOS)
PL_strcpy(tpath, "/tmp/"); PL_strcpy(tpath, "/tmp/");
#else #else
tpath[0] = 0; tpath[0] = 0;
#endif // XP_PC #endif // XP_PC
PR_snprintf(buf, sizeof(buf), "%s%08X.html", tpath, this); PR_snprintf(buf, sizeof(buf), "%s%08X", tpath, this);
// Create and validate the file spec object. (When we have a constructor for the temp
// directory, we should use this instead of the per-platform hack above).
mFileSpec = PL_strdup(buf);
if (mFileSpec.Error())
return;
// Create and validate the file spec object. (When we have a constructor for the temp // create the file
// directory, we should use this instead of the per-platform hack above). nsISupports* ourStream;
mFileSpec = PL_strdup(buf); if (NS_FAILED(NS_NewTypicalOutputFileStream(&ourStream, mFileSpec)))
if (mFileSpec.Error()) return;
return; mFileThing = do_QueryInterface(ourStream);
NS_RELEASE(ourStream);
// create the file
nsISupports* ourStream;
if (NS_FAILED(NS_NewTypicalOutputFileStream(&ourStream, mFileSpec)))
return;
mFileThing = do_QueryInterface(ourStream);
NS_RELEASE(ourStream);
mFileThing->Close(); mFileThing->Close();
// construct the URL we'll use later in calls to GetURL() // construct the URL we'll use later in calls to GetURL()
mFileURL = mFileSpec; mFileURL = mFileSpec;
#ifdef NS_DEBUG #ifdef NS_DEBUG
printf("File URL = %s\n", mFileURL.GetAsString()); printf("File URL = %s\n", mFileURL.GetAsString());
#endif #endif
} }
nsPluginStreamToFile::~nsPluginStreamToFile() nsPluginStreamToFile::~nsPluginStreamToFile()
{ {
if (nsnull != mTarget) if (nsnull != mTarget)
PL_strfree(mTarget); PL_strfree(mTarget);
} }
nsresult nsPluginStreamToFile::QueryInterface(const nsIID& aIID, nsresult nsPluginStreamToFile::QueryInterface(const nsIID& aIID,
@ -263,8 +253,7 @@ nsresult nsPluginStreamToFile::QueryInterface(const nsIID& aIID,
if (nsnull == aInstancePtrResult) if (nsnull == aInstancePtrResult)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIOutputStreamIID)) if (aIID.Equals(kIOutputStreamIID)) {
{
*aInstancePtrResult = (void *)((nsIOutputStream *)this); *aInstancePtrResult = (void *)((nsIOutputStream *)this);
AddRef(); AddRef();
return NS_OK; return NS_OK;
@ -276,72 +265,71 @@ nsresult nsPluginStreamToFile::QueryInterface(const nsIID& aIID,
NS_IMETHODIMP NS_IMETHODIMP
nsPluginStreamToFile::Flush() nsPluginStreamToFile::Flush()
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPluginStreamToFile::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount) nsPluginStreamToFile::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount)
{ {
// write the data to the file and update the target // write the data to the file and update the target
nsCOMPtr<nsIOpenFile> thing; nsCOMPtr<nsIOpenFile> thing;
thing = do_QueryInterface(mFileThing); thing = do_QueryInterface(mFileThing);
thing->Open(mFileSpec, (PR_RDWR|PR_APPEND), 0700); thing->Open(mFileSpec, (PR_WRONLY | PR_CREATE_FILE | PR_APPEND), 0700);
PRUint32 actualCount; PRUint32 actualCount;
mFileThing->Write(aBuf, aCount, &actualCount); mFileThing->Write(aBuf, aCount, &actualCount);
mFileThing->Close(); mFileThing->Close();
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0); mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPluginStreamToFile::WriteFrom(nsIInputStream *inStr, PRUint32 count, PRUint32 *_retval) nsPluginStreamToFile::WriteFrom(nsIInputStream *inStr, PRUint32 count, PRUint32 *_retval)
{ {
NS_NOTREACHED("WriteFrom"); NS_NOTREACHED("WriteFrom");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPluginStreamToFile::WriteSegments(nsReadSegmentFun reader, void * closure, PRUint32 count, PRUint32 *_retval) nsPluginStreamToFile::WriteSegments(nsReadSegmentFun reader, void * closure, PRUint32 count, PRUint32 *_retval)
{ {
NS_NOTREACHED("WriteSegments"); NS_NOTREACHED("WriteSegments");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPluginStreamToFile::GetNonBlocking(PRBool *aNonBlocking) nsPluginStreamToFile::GetNonBlocking(PRBool *aNonBlocking)
{ {
NS_NOTREACHED("GetNonBlocking"); NS_NOTREACHED("GetNonBlocking");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPluginStreamToFile::SetNonBlocking(PRBool aNonBlocking) nsPluginStreamToFile::SetNonBlocking(PRBool aNonBlocking)
{ {
NS_NOTREACHED("SetNonBlocking"); NS_NOTREACHED("SetNonBlocking");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPluginStreamToFile::GetObserver(nsIOutputStreamObserver * *aObserver) nsPluginStreamToFile::GetObserver(nsIOutputStreamObserver * *aObserver)
{ {
NS_NOTREACHED("GetObserver"); NS_NOTREACHED("GetObserver");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPluginStreamToFile::SetObserver(nsIOutputStreamObserver * aObserver) nsPluginStreamToFile::SetObserver(nsIOutputStreamObserver * aObserver)
{ {
NS_NOTREACHED("SetObserver"); NS_NOTREACHED("SetObserver");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPluginStreamToFile::Close(void) nsPluginStreamToFile::Close(void)
{ {
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0); mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0);
return NS_OK;
return NS_OK;
} }
// end of nsPluginStreamToFile // end of nsPluginStreamToFile
@ -368,23 +356,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::ShowStatus(const char* message)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values) NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo *tinfo; nsIPluginTagInfo *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetAttributes(n, names, values); rv = tinfo->GetAttributes(n, names, values);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
n = 0; n = 0;
names = nsnull; names = nsnull;
values = nsnull; values = nsnull;
@ -395,23 +380,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttributes(PRUint16& n, const char*co
NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttribute(const char* name, const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttribute(const char* name, const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo *tinfo; nsIPluginTagInfo *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetAttribute(name, result); rv = tinfo->GetAttribute(name, result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = ""; *result = "";
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -419,19 +401,17 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttribute(const char* name, const cha
NS_IMETHODIMP nsPluginInstancePeerImpl::GetDOMElement(nsIDOMElement* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetDOMElement(nsIDOMElement* *result)
{ {
if (mOwner == nsnull) if (mOwner == nsnull) {
{
*result = nsnull; *result = nsnull;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetDOMElement(result); rv = tinfo->GetDOMElement(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
@ -441,23 +421,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetDOMElement(nsIDOMElement* *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagType(nsPluginTagType *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagType(nsPluginTagType *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetTagType(result); rv = tinfo->GetTagType(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = nsPluginTagType_Unknown; *result = nsPluginTagType_Unknown;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -465,23 +442,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagType(nsPluginTagType *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagText(const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagText(const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetTagText(result); rv = tinfo->GetTagText(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = ""; *result = "";
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -489,23 +463,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagText(const char* *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameters(PRUint16& n, const char*const*& names, const char*const*& values) NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameters(PRUint16& n, const char*const*& names, const char*const*& values)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetParameters(n, names, values); rv = tinfo->GetParameters(n, names, values);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
n = 0; n = 0;
names = nsnull; names = nsnull;
values = nsnull; values = nsnull;
@ -516,23 +487,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameters(PRUint16& n, const char*co
NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameter(const char* name, const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameter(const char* name, const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetParameter(name, result); rv = tinfo->GetParameter(name, result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = ""; *result = "";
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -540,23 +508,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameter(const char* name, const cha
NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentBase(const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentBase(const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetDocumentBase(result); rv = tinfo->GetDocumentBase(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = ""; *result = "";
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -564,23 +529,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentBase(const char* *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentEncoding(const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentEncoding(const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetDocumentEncoding(result); rv = tinfo->GetDocumentEncoding(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = ""; *result = "";
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -588,23 +550,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentEncoding(const char* *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetAlignment(const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetAlignment(const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetAlignment(result); rv = tinfo->GetAlignment(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = ""; *result = "";
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -612,23 +571,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetAlignment(const char* *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetWidth(PRUint32 *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetWidth(PRUint32 *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetWidth(result); rv = tinfo->GetWidth(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -636,23 +592,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetWidth(PRUint32 *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetHeight(PRUint32 *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetHeight(PRUint32 *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetHeight(result); rv = tinfo->GetHeight(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -660,23 +613,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetHeight(PRUint32 *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderVertSpace(PRUint32 *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderVertSpace(PRUint32 *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetBorderVertSpace(result); rv = tinfo->GetBorderVertSpace(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -684,23 +634,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderVertSpace(PRUint32 *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderHorizSpace(PRUint32 *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderHorizSpace(PRUint32 *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetBorderHorizSpace(result); rv = tinfo->GetBorderHorizSpace(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -708,23 +655,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderHorizSpace(PRUint32 *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetUniqueID(PRUint32 *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetUniqueID(PRUint32 *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIPluginTagInfo2 *tinfo; nsIPluginTagInfo2 *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo); rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetUniqueID(result); rv = tinfo->GetUniqueID(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -732,23 +676,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetUniqueID(PRUint32 *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetCode(const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetCode(const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIJVMPluginTagInfo *tinfo; nsIJVMPluginTagInfo *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo); rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetCode(result); rv = tinfo->GetCode(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -756,23 +697,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetCode(const char* *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetCodeBase(const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetCodeBase(const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIJVMPluginTagInfo *tinfo; nsIJVMPluginTagInfo *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo); rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetCodeBase(result); rv = tinfo->GetCodeBase(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -780,23 +718,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetCodeBase(const char* *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetArchive(const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetArchive(const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIJVMPluginTagInfo *tinfo; nsIJVMPluginTagInfo *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo); rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetArchive(result); rv = tinfo->GetArchive(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -804,23 +739,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetArchive(const char* *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetName(const char* *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetName(const char* *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIJVMPluginTagInfo *tinfo; nsIJVMPluginTagInfo *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo); rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetName(result); rv = tinfo->GetName(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -828,23 +760,20 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetName(const char* *result)
NS_IMETHODIMP nsPluginInstancePeerImpl::GetMayScript(PRBool *result) NS_IMETHODIMP nsPluginInstancePeerImpl::GetMayScript(PRBool *result)
{ {
if (nsnull != mOwner) if (nsnull != mOwner) {
{
nsIJVMPluginTagInfo *tinfo; nsIJVMPluginTagInfo *tinfo;
nsresult rv; nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo); rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv) if (NS_OK == rv) {
{
rv = tinfo->GetMayScript(result); rv = tinfo->GetMayScript(result);
NS_RELEASE(tinfo); NS_RELEASE(tinfo);
} }
return rv; return rv;
} }
else else {
{
*result = 0; *result = 0;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -917,8 +846,7 @@ nsresult nsPluginInstancePeerImpl::Initialize(nsIPluginInstanceOwner *aOwner,
aOwner->GetInstance(mInstance); aOwner->GetInstance(mInstance);
NS_IF_RELEASE(mInstance); NS_IF_RELEASE(mInstance);
if (nsnull != aMIMEType) if (nsnull != aMIMEType) {
{
mMIMEType = (nsMIMEType)PR_Malloc(PL_strlen(aMIMEType) + 1); mMIMEType = (nsMIMEType)PR_Malloc(PL_strlen(aMIMEType) + 1);
if (nsnull != mMIMEType) if (nsnull != mMIMEType)
@ -979,21 +907,3 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::ForceRedraw(void)
return mOwner->ForceRedraw(); return mOwner->ForceRedraw();
} }
/*void
nsPluginInstancePeerImpl::SetStopped()
{
mStopped = PR_TRUE;
}
void
nsPluginInstancePeerImpl::SetStarted()
{
mStopped = PR_FALSE;
}
void
nsPluginInstancePeerImpl::IsStopped(PRBool *result)
{
*result = mStopped;
}*/

Просмотреть файл

@ -46,7 +46,7 @@
class nsPluginInstancePeerImpl : public nsIPluginInstancePeer2, class nsPluginInstancePeerImpl : public nsIPluginInstancePeer2,
public nsIWindowlessPluginInstancePeer, public nsIWindowlessPluginInstancePeer,
public nsIPluginTagInfo2, public nsIPluginTagInfo2,
public nsIJVMPluginTagInfo public nsIJVMPluginTagInfo
@ -180,11 +180,6 @@ public:
nsresult GetOwner(nsIPluginInstanceOwner *&aOwner); nsresult GetOwner(nsIPluginInstanceOwner *&aOwner);
/* void SetStopped();
void SetStarted();
void IsStopped(PRBool *result);*/
private: private:
nsIPluginInstance *mInstance; //we don't add a ref to this nsIPluginInstance *mInstance; //we don't add a ref to this
nsIPluginInstanceOwner *mOwner; //we don't add a ref to this nsIPluginInstanceOwner *mOwner; //we don't add a ref to this