gecko-dev/modules/plugin/nglsrc/nsPluginInstancePeer.cpp

912 lines
19 KiB
C++
Raw Normal View History

1998-08-01 05:46:47 +00:00
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nscore.h"
1998-08-01 05:46:47 +00:00
#include "nsPluginInstancePeer.h"
#include "nsIPluginInstance.h"
1998-09-15 03:48:58 +00:00
#include <stdio.h>
#include "prmem.h"
1999-04-12 03:12:48 +00:00
#include "prthread.h"
1998-09-15 03:48:58 +00:00
#include "plstr.h"
#include "prprf.h"
#include "nsIFileStream.h"
#include "nsFileSpec.h"
#include "nsCOMPtr.h"
1998-08-01 05:46:47 +00:00
1999-04-07 05:20:54 +00:00
#if defined(OJI)
1999-03-24 05:40:02 +00:00
#include "nsIDocument.h"
#include "nsIScriptContextOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectOwner.h"
#endif
1999-03-24 05:40:02 +00:00
1999-01-25 09:00:42 +00:00
#ifdef XP_PC
#include "windows.h"
#include "winbase.h"
#endif
1999-04-12 03:12:48 +00:00
nsPluginInstancePeerImpl::nsPluginInstancePeerImpl()
1998-08-01 05:46:47 +00:00
{
1998-09-15 03:48:58 +00:00
NS_INIT_REFCNT();
mInstance = nsnull;
1998-09-15 03:48:58 +00:00
mOwner = nsnull;
mMIMEType = nsnull;
1998-08-01 05:46:47 +00:00
}
1999-04-12 03:12:48 +00:00
nsPluginInstancePeerImpl::~nsPluginInstancePeerImpl()
1998-08-01 05:46:47 +00:00
{
mInstance = nsnull;
1998-09-15 03:48:58 +00:00
mOwner = nsnull;
if (nsnull != mMIMEType)
{
PR_Free((void *)mMIMEType);
mMIMEType = nsnull;
}
1998-08-01 05:46:47 +00:00
}
static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
static NS_DEFINE_IID(kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID);
static NS_DEFINE_IID(kIJVMPluginTagInfoIID, NS_IJVMPLUGINTAGINFO_IID);
1998-08-01 05:46:47 +00:00
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
1999-05-27 23:20:09 +00:00
static NS_DEFINE_IID(kIWindowlessPluginInstancePeerIID, NS_IWINDOWLESSPLUGININSTANCEPEER_IID);//~~~
1998-08-01 05:46:47 +00:00
NS_IMPL_ADDREF(nsPluginInstancePeerImpl);
NS_IMPL_RELEASE(nsPluginInstancePeerImpl);
1999-04-12 03:12:48 +00:00
nsresult nsPluginInstancePeerImpl::QueryInterface(const nsIID& iid, void** instance)
1998-08-01 05:46:47 +00:00
{
if (instance == NULL)
return NS_ERROR_NULL_POINTER;
1999-03-25 03:31:37 +00:00
if (iid.Equals(nsIPluginInstancePeer::GetIID()) || iid.Equals(nsIPluginInstancePeer2::GetIID()))
1998-08-01 05:46:47 +00:00
{
1999-03-25 03:31:37 +00:00
*instance = (void *)(nsIPluginInstancePeer2*)this;
1998-08-01 05:46:47 +00:00
AddRef();
return NS_OK;
}
1999-05-27 23:20:09 +00:00
if (iid.Equals(kIWindowlessPluginInstancePeerIID))//~~~
{
*instance = (void *)(nsIWindowlessPluginInstancePeer*)this;
AddRef();
return NS_OK;
}
1998-08-01 05:46:47 +00:00
if (iid.Equals(kIPluginTagInfoIID))
{
1998-09-15 03:48:58 +00:00
*instance = (void *)(nsIPluginTagInfo *)this;
1998-08-01 05:46:47 +00:00
AddRef();
return NS_OK;
}
if (iid.Equals(kIPluginTagInfo2IID))
{
*instance = (void *)(nsIPluginTagInfo2 *)this;
AddRef();
return NS_OK;
}
if (iid.Equals(kIJVMPluginTagInfoIID))
{
*instance = (void *)(nsIJVMPluginTagInfo *)this;
AddRef();
return NS_OK;
}
1998-08-01 05:46:47 +00:00
if (iid.Equals(kISupportsIID))
{
*instance = (void *)(nsISupports *)(nsIPluginTagInfo *)this;
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetValue(nsPluginInstancePeerVariable variable, void *value)
1998-08-01 05:46:47 +00:00
{
1998-09-15 03:48:58 +00:00
printf("instance peer getvalue %d called\n", variable);
return NS_ERROR_FAILURE;
1998-08-01 05:46:47 +00:00
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetMIMEType(nsMIMEType *result)
1998-08-01 05:46:47 +00:00
{
1998-09-15 03:48:58 +00:00
if (nsnull == mMIMEType)
*result = "";
else
*result = mMIMEType;
1998-08-01 05:46:47 +00:00
return NS_OK;
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetMode(nsPluginMode *result)
1998-08-01 05:46:47 +00:00
{
1998-09-15 03:48:58 +00:00
if (nsnull != mOwner)
return mOwner->GetMode(result);
else
return NS_ERROR_FAILURE;
1998-08-01 05:46:47 +00:00
}
// nsPluginStreamToFile
// --------------------
// Used to handle NPN_NewStream() - writes the stream as received by the plugin
// to a file and at completion (NPN_DestroyStream), tells the browser to load it into
// a plugin-specified target
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
class nsPluginStreamToFile : public nsIOutputStream
{
public:
nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner);
virtual ~nsPluginStreamToFile();
NS_DECL_ISUPPORTS
// nsIOutputStream interface
NS_IMETHOD
Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
NS_IMETHOD Flush() {
return NS_OK;
}
// nsIBaseStream interface
NS_IMETHOD
Close(void);
protected:
char* mTarget;
nsFileURL mFileURL;
nsFileSpec mFileSpec;
nsCOMPtr<nsIFileOutputStream> mFileThing;
nsIPluginInstanceOwner* mOwner;
};
NS_IMPL_ADDREF(nsPluginStreamToFile);
NS_IMPL_RELEASE(nsPluginStreamToFile);
nsPluginStreamToFile::nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner)
: mTarget(PL_strdup(target))
, mFileURL(nsnull)
, mOwner(owner)
{
NS_INIT_REFCNT();
// open the file and prepare it for writing
char buf[400], tpath[300];
#ifdef XP_PC
::GetTempPath(sizeof(tpath), tpath);
PRInt32 len = PL_strlen(tpath);
if ((len > 0) && (tpath[len-1] != '\\'))
{
tpath[len] = '\\';
tpath[len+1] = 0;
}
1999-06-29 11:36:21 +00:00
#elif defined (XP_UNIX) || defined (XP_BEOS)
PL_strcpy(tpath, "/tmp/");
#else
tpath[0] = 0;
#endif // XP_PC
PR_snprintf(buf, sizeof(buf), "%s%08X.html", 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 the file
nsISupports* ourStream;
if (NS_FAILED(NS_NewTypicalOutputFileStream(&ourStream, mFileSpec)))
return;
mFileThing = do_QueryInterface(ourStream);
NS_RELEASE(ourStream);
mFileThing->Close();
// construct the URL we'll use later in calls to GetURL()
mFileURL = mFileSpec;
1999-03-13 06:39:17 +00:00
printf("File URL = %s\n", mFileURL.GetAsString());
}
nsPluginStreamToFile::~nsPluginStreamToFile()
{
if (nsnull != mTarget)
PL_strfree(mTarget);
}
nsresult nsPluginStreamToFile::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
if (nsnull == aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIOutputStreamIID))
{
*aInstancePtrResult = (void *)((nsIOutputStream *)this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP
nsPluginStreamToFile::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount)
{
// write the data to the file and update the target
1999-03-06 00:07:06 +00:00
nsCOMPtr<nsIFile> thing;
thing = do_QueryInterface(mFileThing);
thing->Open(mFileSpec, (PR_RDWR|PR_APPEND), 0700);
PRUint32 actualCount;
mFileThing->Write(aBuf, aCount, &actualCount);
mFileThing->Close();
1999-03-13 06:39:17 +00:00
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull);
return NS_OK;
}
NS_IMETHODIMP
nsPluginStreamToFile::Close(void)
{
1999-03-13 06:39:17 +00:00
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull);
return NS_OK;
}
// end of nsPluginStreamToFile
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result)
1998-08-01 05:46:47 +00:00
{
nsresult rv;
nsPluginStreamToFile* stream = new nsPluginStreamToFile(target, mOwner);
1999-07-30 23:51:53 +00:00
if(stream == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
rv = stream->QueryInterface(kIOutputStreamIID, (void **)result);
return rv;
1998-08-01 05:46:47 +00:00
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::ShowStatus(const char* message)
1998-08-01 05:46:47 +00:00
{
if (nsnull != mOwner)
return mOwner->ShowStatus(message);
else
return NS_ERROR_FAILURE;
1998-08-01 05:46:47 +00:00
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values)
1998-08-01 05:46:47 +00:00
{
1998-09-15 03:48:58 +00:00
if (nsnull != mOwner)
{
nsIPluginTagInfo *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetAttributes(n, names, values);
NS_RELEASE(tinfo);
}
return rv;
}
1998-09-15 03:48:58 +00:00
else
{
n = 0;
names = nsnull;
values = nsnull;
1998-09-15 03:48:58 +00:00
return NS_ERROR_FAILURE;
}
1998-08-01 05:46:47 +00:00
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttribute(const char* name, const char* *result)
1998-08-01 05:46:47 +00:00
{
1998-09-15 03:48:58 +00:00
if (nsnull != mOwner)
{
nsIPluginTagInfo *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetAttribute(name, result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = "";
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagType(nsPluginTagType *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetTagType(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = nsPluginTagType_Unknown;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagText(const char* *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetTagText(result);
NS_RELEASE(tinfo);
}
return rv;
}
1998-09-15 03:48:58 +00:00
else
{
*result = "";
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameters(PRUint16& n, const char*const*& names, const char*const*& values)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetParameters(n, names, values);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
n = 0;
names = nsnull;
values = nsnull;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameter(const char* name, const char* *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetParameter(name, result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = "";
return NS_ERROR_FAILURE;
}
}
NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentBase(const char* *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetDocumentBase(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = "";
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentEncoding(const char* *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetDocumentEncoding(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = "";
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetAlignment(const char* *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetAlignment(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = "";
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetWidth(PRUint32 *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetWidth(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetHeight(PRUint32 *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetHeight(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderVertSpace(PRUint32 *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetBorderVertSpace(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderHorizSpace(PRUint32 *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetBorderHorizSpace(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetUniqueID(PRUint32 *result)
{
if (nsnull != mOwner)
{
nsIPluginTagInfo2 *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetUniqueID(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetCode(const char* *result)
{
if (nsnull != mOwner)
{
nsIJVMPluginTagInfo *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetCode(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetCodeBase(const char* *result)
{
if (nsnull != mOwner)
{
nsIJVMPluginTagInfo *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetCodeBase(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetArchive(const char* *result)
{
if (nsnull != mOwner)
{
nsIJVMPluginTagInfo *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetArchive(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetName(const char* *result)
{
if (nsnull != mOwner)
{
nsIJVMPluginTagInfo *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetName(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetMayScript(PRBool *result)
{
if (nsnull != mOwner)
{
nsIJVMPluginTagInfo *tinfo;
nsresult rv;
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
if (NS_OK == rv)
{
rv = tinfo->GetMayScript(result);
NS_RELEASE(tinfo);
}
return rv;
}
else
{
*result = 0;
return NS_ERROR_FAILURE;
}
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::SetWindowSize(PRUint32 width, PRUint32 height)
1998-09-15 03:48:58 +00:00
{
printf("instance peer setwindowsize called\n");
return NS_OK;
}
1999-03-24 05:40:02 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSWindow(JSObject* *outJSWindow)
{
*outJSWindow = NULL;
nsresult rv = NS_ERROR_FAILURE;
1999-04-07 05:20:54 +00:00
#if defined(OJI)
1999-03-24 05:40:02 +00:00
nsIDocument* document = nsnull;
if (mOwner->GetDocument(&document) == NS_OK) {
nsIScriptContextOwner* contextOwner = document->GetScriptContextOwner();
if (nsnull != contextOwner) {
nsIScriptGlobalObject *global = nsnull;
contextOwner->GetScriptGlobalObject(&global);
nsIScriptContext* context = nsnull;
contextOwner->GetScriptContext(&context);
if (nsnull != global && nsnull != context) {
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
nsIScriptObjectOwner* window = nsnull;
if (global->QueryInterface(kIScriptObjectOwnerIID, (void **)&window) == NS_OK) {
rv = window->GetScriptObject(context, (void**)outJSWindow);
NS_RELEASE(window);
}
}
NS_IF_RELEASE(global);
NS_IF_RELEASE(context);
NS_RELEASE(contextOwner);
}
NS_RELEASE(document);
}
#endif
1999-03-24 05:40:02 +00:00
return rv;
}
1999-04-12 03:12:48 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSThread(PRUint32 *outThreadID)
{
*outThreadID = mThreadID;
return NS_OK;
}
1999-05-08 16:33:40 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext)
{
*outContext = NULL;
nsresult rv = NS_ERROR_FAILURE;
#if defined(OJI)
nsIDocument* document = nsnull;
if (mOwner->GetDocument(&document) == NS_OK) {
nsIScriptContextOwner* contextOwner = document->GetScriptContextOwner();
if (nsnull != contextOwner) {
nsIScriptContext* context = nsnull;
if (contextOwner->GetScriptContext(&context) == NS_OK) {
*outContext = (JSContext*) context->GetNativeContext();
NS_RELEASE(context);
rv = NS_OK;
}
NS_RELEASE(contextOwner);
}
NS_RELEASE(document);
}
#endif
return rv;
}
1999-04-12 03:12:48 +00:00
nsresult nsPluginInstancePeerImpl::Initialize(nsIPluginInstanceOwner *aOwner,
1998-09-15 03:48:58 +00:00
const nsMIMEType aMIMEType)
{
1999-01-25 09:00:42 +00:00
//don't add a ref to prevent circular references... MMP
1998-09-15 03:48:58 +00:00
mOwner = aOwner;
aOwner->GetInstance(mInstance);
//release this one too... MMP
NS_IF_RELEASE(mInstance);
if (nsnull != aMIMEType)
{
mMIMEType = (nsMIMEType)PR_Malloc(PL_strlen(aMIMEType) + 1);
if (nsnull != mMIMEType)
PL_strcpy((char *)mMIMEType, aMIMEType);
}
1999-04-12 03:12:48 +00:00
// record the thread we were created in.
mThreadID = PRUint32(PR_GetCurrentThread());
1998-08-01 05:46:47 +00:00
return NS_OK;
}
1998-09-15 03:48:58 +00:00
nsresult nsPluginInstancePeerImpl::SetOwner(nsIPluginInstanceOwner *aOwner)
{
// do not add refs to these objects to prevent circular references
mOwner = aOwner;
aOwner->GetInstance(mInstance);
NS_IF_RELEASE(mInstance);
return NS_OK;
}
1999-04-12 03:12:48 +00:00
nsresult nsPluginInstancePeerImpl::GetOwner(nsIPluginInstanceOwner *&aOwner)
1998-09-15 03:48:58 +00:00
{
aOwner = mOwner;
NS_IF_ADDREF(mOwner);
if (nsnull != mOwner)
return NS_OK;
else
return NS_ERROR_FAILURE;
}
1999-01-25 09:00:42 +00:00
NS_IMETHODIMP nsPluginInstancePeerImpl::InvalidateRect(nsPluginRect *invalidRect)
{
return NS_OK;
}
NS_IMETHODIMP nsPluginInstancePeerImpl::InvalidateRegion(nsPluginRegion invalidRegion)
{
return NS_OK;
}
NS_IMETHODIMP nsPluginInstancePeerImpl::ForceRedraw(void)
{
return NS_OK;
}
/*void
nsPluginInstancePeerImpl::SetStopped()
{
mStopped = PR_TRUE;
}
void
nsPluginInstancePeerImpl::SetStarted()
{
mStopped = PR_FALSE;
}
void
nsPluginInstancePeerImpl::IsStopped(PRBool *result)
{
*result = mStopped;
}*/