diff --git a/mozilla/plugin/oji/MRJ/plugin/MRJPlugin.xml b/mozilla/plugin/oji/MRJ/plugin/MRJPlugin.xml index fc2c7f410fe..9363cfd6fb8 100644 --- a/mozilla/plugin/oji/MRJ/plugin/MRJPlugin.xml +++ b/mozilla/plugin/oji/MRJ/plugin/MRJPlugin.xml @@ -171,6 +171,15 @@ Recursivetrue HostFlagsAll + + SearchPath + Path:::::dist:netwerk: + PathFormatMacOS + PathRootProject + + Recursivetrue + HostFlagsAll + SearchPath Path:MacOS Support: @@ -180,6 +189,15 @@ Recursivetrue HostFlagsAll + + SearchPath + Path:::::xpcom:macbuild: + PathFormatMacOS + PathRootProject + + Recursivetrue + HostFlagsAll + SystemSearchPaths @@ -828,13 +846,13 @@ MWMerge_MacOS_copyResources1 MWMerge_MacOS_skipResources - i› - ñ8 - Ñ0 + + üêØ + - Perl_Prefix_Filename€A + Perl_Prefix_Filename MWCodeGen_PPC_structalignmentPPC @@ -1182,6 +1200,15 @@ Library Debug + + PathRelative + Project + :::::xpcom:macbuild: + :xpcom.shlb + MacOS + Library + Debug, WeakImport + @@ -1379,6 +1406,13 @@ :Universal:Libraries:StubLibraries:TextCommon MacOS + + PathRelative + Project + :::::xpcom:macbuild: + :xpcom.shlb + MacOS + @@ -2144,13 +2178,13 @@ MWMerge_MacOS_copyResources1 MWMerge_MacOS_skipResources - i› - ñ8 - Ñ0 + + üêØ + - Perl_Prefix_Filename€A + Perl_Prefix_Filename MWCodeGen_PPC_structalignmentPPC @@ -3071,13 +3105,13 @@ MWMerge_MacOS_copyResources1 MWMerge_MacOS_skipResources - i› - ñ8 - Ñ0 + + üêØ + - Perl_Prefix_Filename€A + Perl_Prefix_Filename MWCodeGen_PPC_structalignmentPPC @@ -4159,13 +4193,13 @@ MWMerge_MacOS_copyResources1 MWMerge_MacOS_skipResources - i› - ñ8 - Ñ0 + + üêØ + - Perl_Prefix_Filename€A + Perl_Prefix_Filename MWCodeGen_PPC_structalignmentMC68K @@ -5208,13 +5242,13 @@ MWMerge_MacOS_copyResources1 MWMerge_MacOS_skipResources - i› - ñ8 - Ñ0 + + üêØ + - Perl_Prefix_Filename€A + Perl_Prefix_Filename MWCodeGen_PPC_structalignmentPPC @@ -6436,13 +6470,13 @@ MWMerge_MacOS_copyResources1 MWMerge_MacOS_skipResources - i› - ñ8 - Ñ0 + + üêØ + - Perl_Prefix_Filename€A + Perl_Prefix_Filename MWCodeGen_PPC_structalignmentMC68K @@ -6940,6 +6974,14 @@ :NSStdLibStubs MacOS + + MRJPlugin + PathRelative + Project + :::::xpcom:macbuild: + :xpcom.shlb + MacOS + MRJPlugin PathRelative diff --git a/mozilla/plugin/oji/MRJ/plugin/Source/LiveConnectNativeMethods.cpp b/mozilla/plugin/oji/MRJ/plugin/Source/LiveConnectNativeMethods.cpp index 9e1c674dde6..9684d1698f6 100644 --- a/mozilla/plugin/oji/MRJ/plugin/Source/LiveConnectNativeMethods.cpp +++ b/mozilla/plugin/oji/MRJ/plugin/Source/LiveConnectNativeMethods.cpp @@ -20,34 +20,41 @@ */ /* - LiveConnectNativeMethods.cpp + LiveConnectNativeMethods.cpp */ +#include + #include "LiveConnectNativeMethods.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIPluginManager.h" #include "nsIJVMManager.h" #include "nsILiveconnect.h" -#include "nsISecurityContext.h" #include "nsIPluginInstancePeer2.h" +#include "nsIIOService.h" +#include "nsIURI.h" #include "MRJPlugin.h" #include "MRJContext.h" #include "MRJSession.h" +#include "MRJSecurityContext.h" #include "CSecureEnv.h" #include "JavaMessageQueue.h" #include "MRJMonitor.h" #include "NativeMonitor.h" #include "RunnableMixin.h" +#include "StringUtils.h" #include "netscape_javascript_JSObject.h" /* javah-generated headers */ extern nsIPluginManager* thePluginManager; -extern nsIServiceManager* theServiceManager; // needs to be in badaptor.cpp. +extern nsIServiceManager* theServiceManager; // needs to be in badaptor.cpp. static MRJPlugin* theJVMPlugin = NULL; static nsILiveconnect* theLiveConnectManager = NULL; +static nsIComponentManager* theComponentManager = NULL; static jclass netscape_javascript_JSObject = NULL; static jmethodID netscape_javascript_JSObject_JSObject; @@ -59,17 +66,23 @@ static jmethodID netscape_oji_JNIUtils_GetCurrentThread = NULL; static jmethodID netscape_oji_JNIUtils_GetCurrentClassLoader = NULL; static jmethodID netscape_oji_JNIUtils_GetObjectClassLoader = NULL; +extern "C" nsresult NS_GetGlobalComponentManager(nsIComponentManager* *result); + +static NS_DEFINE_IID(kLiveConnectCID, NS_CLIVECONNECT_CID); + nsresult InitLiveConnectSupport(MRJPlugin* jvmPlugin) { - theJVMPlugin = jvmPlugin; + theJVMPlugin = jvmPlugin; - NS_DEFINE_IID(kLiveConnectCID, NS_CLIVECONNECT_CID); - NS_DEFINE_IID(kILiveConnectIID, NS_ILIVECONNECT_IID); - nsresult result = theServiceManager->GetService(kLiveConnectCID, kILiveConnectIID, - (nsISupports**)&theLiveConnectManager); - if (result != NS_OK) - return result; - + if (&NS_GetGlobalComponentManager) { + NS_GetGlobalComponentManager(&theComponentManager); + } + + nsresult result = theServiceManager->GetService(kLiveConnectCID, NS_GET_IID(nsILiveconnect), + (nsISupports**)&theLiveConnectManager); + if (result != NS_OK) + return result; + // Manually load the required native methods. static JNINativeMethod nativeMethods[] = { "getMember", "(Ljava/lang/String;)Ljava/lang/Object;", (void*)&Java_netscape_javascript_JSObject_getMember, @@ -87,34 +100,34 @@ nsresult InitLiveConnectSupport(MRJPlugin* jvmPlugin) JNIEnv* env = NULL; nsrefcnt count = jvmPlugin->GetJNIEnv(&env); if (count > 0 && env != NULL) { - jclass classJSObject = env->FindClass("netscape/javascript/JSObject"); - if (classJSObject != NULL) { - // register LiveConnect native methods. - netscape_javascript_JSObject = (jclass) env->NewGlobalRef(classJSObject); - env->DeleteLocalRef(classJSObject); - - netscape_javascript_JSObject_JSObject = env->GetMethodID(netscape_javascript_JSObject, "", "(I)V"); - netscape_javascript_JSObject_internal = env->GetFieldID(netscape_javascript_JSObject, "internal", "I"); + jclass classJSObject = env->FindClass("netscape/javascript/JSObject"); + if (classJSObject != NULL) { + // register LiveConnect native methods. + netscape_javascript_JSObject = (jclass) env->NewGlobalRef(classJSObject); + env->DeleteLocalRef(classJSObject); + + netscape_javascript_JSObject_JSObject = env->GetMethodID(netscape_javascript_JSObject, "", "(I)V"); + netscape_javascript_JSObject_internal = env->GetFieldID(netscape_javascript_JSObject, "internal", "I"); - env->RegisterNatives(netscape_javascript_JSObject, nativeMethods, sizeof(nativeMethods) / sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - env->ExceptionClear(); - result = NS_ERROR_FAILURE; - } - } - - // load netscape.oji.JNIUtils class. - jclass classJNIUtils = env->FindClass("netscape/oji/JNIUtils"); - if (classJNIUtils != NULL) { - netscape_oji_JNIUtils = (jclass) env->NewGlobalRef(classJNIUtils); - env->DeleteLocalRef(classJNIUtils); - netscape_oji_JNIUtils_NewLocalRef = env->GetStaticMethodID(netscape_oji_JNIUtils, "NewLocalRef", "(Ljava/lang/Object;)Ljava/lang/Object;"); - netscape_oji_JNIUtils_GetCurrentThread = env->GetStaticMethodID(netscape_oji_JNIUtils, "GetCurrentThread", "()Ljava/lang/Object;"); - netscape_oji_JNIUtils_GetCurrentClassLoader = env->GetStaticMethodID(netscape_oji_JNIUtils, "GetCurrentClassLoader", "()Ljava/lang/Object;"); - netscape_oji_JNIUtils_GetObjectClassLoader = env->GetStaticMethodID(netscape_oji_JNIUtils, "GetObjectClassLoader", "(Ljava/lang/Object;)Ljava/lang/Object;"); - } - - jvmPlugin->ReleaseJNIEnv(env); + env->RegisterNatives(netscape_javascript_JSObject, nativeMethods, sizeof(nativeMethods) / sizeof(JNINativeMethod)); + if (env->ExceptionOccurred()) { + env->ExceptionClear(); + result = NS_ERROR_FAILURE; + } + } + + // load netscape.oji.JNIUtils class. + jclass classJNIUtils = env->FindClass("netscape/oji/JNIUtils"); + if (classJNIUtils != NULL) { + netscape_oji_JNIUtils = (jclass) env->NewGlobalRef(classJNIUtils); + env->DeleteLocalRef(classJNIUtils); + netscape_oji_JNIUtils_NewLocalRef = env->GetStaticMethodID(netscape_oji_JNIUtils, "NewLocalRef", "(Ljava/lang/Object;)Ljava/lang/Object;"); + netscape_oji_JNIUtils_GetCurrentThread = env->GetStaticMethodID(netscape_oji_JNIUtils, "GetCurrentThread", "()Ljava/lang/Object;"); + netscape_oji_JNIUtils_GetCurrentClassLoader = env->GetStaticMethodID(netscape_oji_JNIUtils, "GetCurrentClassLoader", "()Ljava/lang/Object;"); + netscape_oji_JNIUtils_GetObjectClassLoader = env->GetStaticMethodID(netscape_oji_JNIUtils, "GetObjectClassLoader", "(Ljava/lang/Object;)Ljava/lang/Object;"); + } + + jvmPlugin->ReleaseJNIEnv(env); } return result; @@ -122,90 +135,113 @@ nsresult InitLiveConnectSupport(MRJPlugin* jvmPlugin) nsresult ShutdownLiveConnectSupport() { - - if (theLiveConnectManager != NULL) { - theLiveConnectManager->Release(); - theLiveConnectManager = NULL; - } - - if (theJVMPlugin != NULL) { - theJVMPlugin = NULL; - } - - return NS_OK; + + if (theLiveConnectManager != NULL) { + theLiveConnectManager->Release(); + theLiveConnectManager = NULL; + } + + if (theJVMPlugin != NULL) { + theJVMPlugin = NULL; + } + + return NS_OK; } jobject Wrap_JSObject(JNIEnv* env, jsobject js_obj) { jmethodID constructorID = env->GetMethodID(netscape_javascript_JSObject, "", "(I)V"); - return env->NewObject(netscape_javascript_JSObject, constructorID, js_obj); + return env->NewObject(netscape_javascript_JSObject, constructorID, js_obj); } jsobject Unwrap_JSObject(JNIEnv* env, jobject java_wrapper_obj) { - return env->GetIntField(java_wrapper_obj, netscape_javascript_JSObject_internal); + return env->GetIntField(java_wrapper_obj, netscape_javascript_JSObject_internal); } static jobject NewLocalRef(JNIEnv* env, jobject global_ref) { - return env->CallStaticObjectMethod(netscape_oji_JNIUtils, netscape_oji_JNIUtils_NewLocalRef, global_ref); + return env->CallStaticObjectMethod(netscape_oji_JNIUtils, netscape_oji_JNIUtils_NewLocalRef, global_ref); } static jobject ToGlobalRef(JNIEnv* env, jobject localRef) { - jobject globalRef = env->NewGlobalRef(localRef); - env->DeleteLocalRef(localRef); - return globalRef; + jobject globalRef = env->NewGlobalRef(localRef); + env->DeleteLocalRef(localRef); + return globalRef; } static jobject ToLocalRef(JNIEnv* env, jobject globalRef) { - jobject localRef = NewLocalRef(env, globalRef); - env->DeleteGlobalRef(globalRef); - return localRef; + jobject localRef = NewLocalRef(env, globalRef); + env->DeleteGlobalRef(globalRef); + return localRef; } static jobject GetCurrentThread(JNIEnv* env) { - return env->CallStaticObjectMethod(netscape_oji_JNIUtils, netscape_oji_JNIUtils_GetCurrentThread); + return env->CallStaticObjectMethod(netscape_oji_JNIUtils, netscape_oji_JNIUtils_GetCurrentThread); } /** * Security Considerations. */ -class MRJSecurityContext : public nsISecurityContext { -public: - MRJSecurityContext(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD Implies(const char* target, const char* action, PRBool *bAllowedAccess); - NS_IMETHOD GetOrigin(char* buf, int len); - NS_IMETHOD GetCertificateID(char* buf, int len); -}; - -MRJSecurityContext::MRJSecurityContext() +static nsresult +NS_NewURI(nsIURI* *result, + const char* spec, + nsIURI* baseURI = nsnull) // pass in nsIIOService to optimize callers { - NS_INIT_REFCNT(); + nsIIOService* ioService; + static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); + nsresult rv = theServiceManager->GetService(kIOServiceCID, NS_GET_IID(nsIIOService), (nsISupports**)&ioService); + if (rv == NS_OK) + rv = ioService->NewURI(spec, baseURI, result); + NS_RELEASE(ioService); + return rv; +} + +MRJSecurityContext::MRJSecurityContext(const char* location) + : mLocation(nsnull), mConnection(nsnull) +{ + NS_INIT_REFCNT(); + + NS_NewURI(&mLocation, location, nsnull); + + if (theComponentManager) { + theComponentManager->CreateInstance(kLiveConnectCID, nsnull, NS_GET_IID(nsILiveconnect), + (void**)&mConnection); + } else { + mConnection = theLiveConnectManager; + NS_IF_ADDREF(mConnection); + } +} + +MRJSecurityContext::~MRJSecurityContext() +{ + NS_IF_RELEASE(mLocation); + NS_IF_RELEASE(mConnection); } // work around a bug in Metrowerks pre-processor. -static NS_DEFINE_IID(kISecurityContextIID, NS_ISECURITYCONTEXT_IID); -NS_IMPL_ISUPPORTS(MRJSecurityContext, kISecurityContextIID) +NS_IMPL_ISUPPORTS1(MRJSecurityContext, nsISecurityContext) NS_METHOD MRJSecurityContext::Implies(const char* target, const char* action, PRBool *bAllowedAccess) { - *bAllowedAccess = (target != NULL && action == NULL); - return NS_OK; + *bAllowedAccess = (target != NULL && action == NULL); + return NS_OK; } NS_METHOD MRJSecurityContext::GetOrigin(char* buf, int len) { - // ACTION: Implement me. - - return PR_FALSE; + char* origin = nsnull; + if (mLocation && NS_SUCCEEDED(mLocation->GetPrePath(&origin))) { + ::strncpy(buf, origin, len); + delete[] origin; + return NS_OK; + } + return NS_ERROR_FAILURE; } NS_METHOD @@ -213,24 +249,31 @@ MRJSecurityContext::GetCertificateID(char* buf, int len) { // ACTION: Implement me. - return PR_FALSE; + return NS_ERROR_NOT_IMPLEMENTED; } -static nsISecurityContext* newSecurityContext() +// NOTE: this a weak reference to the MRJSecurityContext associated with this +// plugin instance. The MRJSecurityContext is owned by the MRJContext. + +static MRJSecurityContext* getSecurityContext(MRJPluginInstance* pluginInstance) { - MRJSecurityContext* context = new MRJSecurityContext(); - NS_IF_ADDREF(context); - return context; + MRJContext* context = pluginInstance->getContext(); + MRJSecurityContext* securityContext = context->getSecurityContext(); + if (securityContext == NULL) { + securityContext = new MRJSecurityContext(context->getDocumentBase()); + context->setSecurityContext(securityContext); + } + return securityContext; } static jobject GetCurrentClassLoader(JNIEnv* env) { - return env->CallStaticObjectMethod(netscape_oji_JNIUtils, netscape_oji_JNIUtils_GetCurrentClassLoader); + return env->CallStaticObjectMethod(netscape_oji_JNIUtils, netscape_oji_JNIUtils_GetCurrentClassLoader); } static jobject GetObjectClassLoader(JNIEnv* env, jobject object) { - return env->CallStaticObjectMethod(netscape_oji_JNIUtils, netscape_oji_JNIUtils_GetObjectClassLoader, object); + return env->CallStaticObjectMethod(netscape_oji_JNIUtils, netscape_oji_JNIUtils_GetObjectClassLoader, object); } /** @@ -241,23 +284,23 @@ static jobject GetObjectClassLoader(JNIEnv* env, jobject object) */ static MRJPluginInstance* GetCurrentInstance(JNIEnv* env) { - MRJPluginInstance* pluginInstance = NULL; - jobject classLoader = GetCurrentClassLoader(env); - if (classLoader != NULL) { - pluginInstance = MRJPluginInstance::getInstances(); - while (pluginInstance != NULL) { - jobject applet; - pluginInstance->GetJavaObject(&applet); - jobject appletClassLoader = GetObjectClassLoader(env, applet); - jboolean sameClassLoader = env->IsSameObject(appletClassLoader, classLoader); - env->DeleteLocalRef(appletClassLoader); - if (sameClassLoader) - break; - pluginInstance = pluginInstance->getNextInstance(); - } - env->DeleteLocalRef(classLoader); - } - return pluginInstance; + MRJPluginInstance* pluginInstance = NULL; + jobject classLoader = GetCurrentClassLoader(env); + if (classLoader != NULL) { + pluginInstance = MRJPluginInstance::getInstances(); + while (pluginInstance != NULL) { + jobject applet; + pluginInstance->GetJavaObject(&applet); + jobject appletClassLoader = GetObjectClassLoader(env, applet); + jboolean sameClassLoader = env->IsSameObject(appletClassLoader, classLoader); + env->DeleteLocalRef(appletClassLoader); + if (sameClassLoader) + break; + pluginInstance = pluginInstance->getNextInstance(); + } + env->DeleteLocalRef(classLoader); + } + return pluginInstance; } /** @@ -265,62 +308,62 @@ static MRJPluginInstance* GetCurrentInstance(JNIEnv* env) */ class MessageRunnable : public JavaMessage, public RunnableMixin { public: - MessageRunnable(PRUint32 threadID, JavaMessage* msg); - - virtual void execute(JNIEnv* env); - - NS_IMETHOD Run(); + MessageRunnable(PRUint32 threadID, JavaMessage* msg); + + virtual void execute(JNIEnv* env); + + NS_IMETHOD Run(); private: - PRUint32 mThreadID; - JavaMessage* mMessage; + PRUint32 mThreadID; + JavaMessage* mMessage; }; MessageRunnable::MessageRunnable(PRUint32 threadID, JavaMessage* msg) - : mThreadID(threadID), mMessage(msg) + : mThreadID(threadID), mMessage(msg) { } void MessageRunnable::execute(JNIEnv* env) { - // because a spontaneous Java thread called us, we have to switch to the JavaScript thread - // to handle this request. - nsIThreadManager* threadManager = NULL; - if (theServiceManager->GetService(nsIJVMManager::GetCID(), NS_GET_IID(nsIThreadManager), (nsISupports**)&threadManager) == NS_OK) { - threadManager->PostEvent(mThreadID, this, PR_FALSE); - theServiceManager->ReleaseService(nsIJVMManager::GetCID(), threadManager); - } + // because a spontaneous Java thread called us, we have to switch to the JavaScript thread + // to handle this request. + nsIThreadManager* threadManager = NULL; + if (theServiceManager->GetService(nsIJVMManager::GetCID(), NS_GET_IID(nsIThreadManager), (nsISupports**)&threadManager) == NS_OK) { + threadManager->PostEvent(mThreadID, this, PR_FALSE); + theServiceManager->ReleaseService(nsIJVMManager::GetCID(), threadManager); + } } NS_IMETHODIMP MessageRunnable::Run() { - nsIJVMManager* javaManager = NULL; - if (theServiceManager->GetService(nsIJVMManager::GetCID(), NS_GET_IID(nsIJVMManager), (nsISupports**)&javaManager) == NS_OK) { - JNIEnv* proxyEnv = NULL; - if (javaManager->GetProxyJNI(&proxyEnv) == NS_OK && proxyEnv != NULL) - mMessage->execute(proxyEnv); - theServiceManager->ReleaseService(nsIJVMManager::GetCID(), javaManager); - } - return NS_OK; + nsIJVMManager* javaManager = NULL; + if (theServiceManager->GetService(nsIJVMManager::GetCID(), NS_GET_IID(nsIJVMManager), (nsISupports**)&javaManager) == NS_OK) { + JNIEnv* proxyEnv = NULL; + if (javaManager->GetProxyJNI(&proxyEnv) == NS_OK && proxyEnv != NULL) + mMessage->execute(proxyEnv); + theServiceManager->ReleaseService(nsIJVMManager::GetCID(), javaManager); + } + return NS_OK; } static PRUint32 getJavaScriptThread(JNIEnv* env) { - PRUint32 threadID = 0; - MRJPluginInstance* pluginInstance = GetCurrentInstance(env); - if (pluginInstance != NULL) { - nsIPluginInstancePeer* peer; - if (pluginInstance->GetPeer(&peer) == NS_OK) { - nsIPluginInstancePeer2* peer2 = NULL; - if (peer->QueryInterface(NS_GET_IID(nsIPluginInstancePeer2), &peer2) == NS_OK) { - if (peer2->GetJSThread(&threadID) != NS_OK) - threadID = 0; - NS_RELEASE(peer2); - } - NS_RELEASE(peer); - } - } - return threadID; + PRUint32 threadID = 0; + MRJPluginInstance* pluginInstance = GetCurrentInstance(env); + if (pluginInstance != NULL) { + nsIPluginInstancePeer* peer; + if (pluginInstance->GetPeer(&peer) == NS_OK) { + nsIPluginInstancePeer2* peer2 = NULL; + if (peer->QueryInterface(NS_GET_IID(nsIPluginInstancePeer2), &peer2) == NS_OK) { + if (peer2->GetJSThread(&threadID) != NS_OK) + threadID = 0; + NS_RELEASE(peer2); + } + NS_RELEASE(peer); + } + } + return threadID; } /** @@ -329,69 +372,69 @@ static PRUint32 getJavaScriptThread(JNIEnv* env) */ static void sendMessage(JNIEnv* env, JavaMessage* msg) { - // the main thread gets its own secure env, so it won't contend with other threads. this - // is needed to handle finalization, which seems to get called from the main thread sometimes. - if (env == theJVMPlugin->getSession()->getMainEnv()) { - static CSecureEnv* mainEnv = NULL; - if (mainEnv == NULL) { - mainEnv = new CSecureEnv(theJVMPlugin, NULL, env); - mainEnv->AddRef(); - } - mainEnv->setJavaEnv(env); - mainEnv->sendMessageFromJava(env, msg, true); - return; - } - - // If this is a call back into JavaScript from Java, there will be a secureEnv associated with this thread. - jobject thread = GetCurrentThread(env); - CSecureEnv* secureEnv = GetSecureJNI(env, thread); - env->DeleteLocalRef(thread); - if (secureEnv != NULL) { - secureEnv->sendMessageFromJava(env, msg); - } else { - // spontaneous call in from Java. this communicates with a shared server thread. this is *VERY* slow right now. - static MRJMonitor sharedMonitor(theJVMPlugin->getSession()); - // only 1 Java thread can use this at a time. - sharedMonitor.enter(); - { - static CSecureEnv* sharedEnv = NULL; - if (sharedEnv == NULL) { - sharedEnv = new CSecureEnv(theJVMPlugin, NULL, env); - sharedEnv->AddRef(); - } - sharedEnv->setJavaEnv(env); + // the main thread gets its own secure env, so it won't contend with other threads. this + // is needed to handle finalization, which seems to get called from the main thread sometimes. + if (env == theJVMPlugin->getSession()->getMainEnv()) { + static CSecureEnv* mainEnv = NULL; + if (mainEnv == NULL) { + mainEnv = new CSecureEnv(theJVMPlugin, NULL, env); + mainEnv->AddRef(); + } + mainEnv->setJavaEnv(env); + mainEnv->sendMessageFromJava(env, msg, true); + return; + } + + // If this is a call back into JavaScript from Java, there will be a secureEnv associated with this thread. + jobject thread = GetCurrentThread(env); + CSecureEnv* secureEnv = GetSecureJNI(env, thread); + env->DeleteLocalRef(thread); + if (secureEnv != NULL) { + secureEnv->sendMessageFromJava(env, msg); + } else { + // spontaneous call in from Java. this communicates with a shared server thread. this is *VERY* slow right now. + static MRJMonitor sharedMonitor(theJVMPlugin->getSession()); + // only 1 Java thread can use this at a time. + sharedMonitor.enter(); + { + static CSecureEnv* sharedEnv = NULL; + if (sharedEnv == NULL) { + sharedEnv = new CSecureEnv(theJVMPlugin, NULL, env); + sharedEnv->AddRef(); + } + sharedEnv->setJavaEnv(env); - // In the current Seamonkey architecture, there's really only one thread that JavaScript - // can execute in. We take advantage of that fact here. When we have a more multithreaded - // system, this will have to be revisited. - static PRUint32 theJavaScriptThread = getJavaScriptThread(env); - - // if the JavaScript thread is known, wrap the message in a MessageRunnable to handle - // the message in the JavaScript thread. - if (theJavaScriptThread != 0) { - MessageRunnable* runnableMsg = new MessageRunnable(theJavaScriptThread, msg); - NS_ADDREF(runnableMsg); - sharedEnv->sendMessageFromJava(env, runnableMsg); - NS_IF_RELEASE(runnableMsg); - } - } - sharedMonitor.exit(); - } + // In the current Seamonkey architecture, there's really only one thread that JavaScript + // can execute in. We take advantage of that fact here. When we have a more multithreaded + // system, this will have to be revisited. + static PRUint32 theJavaScriptThread = getJavaScriptThread(env); + + // if the JavaScript thread is known, wrap the message in a MessageRunnable to handle + // the message in the JavaScript thread. + if (theJavaScriptThread != 0) { + MessageRunnable* runnableMsg = new MessageRunnable(theJavaScriptThread, msg); + NS_ADDREF(runnableMsg); + sharedEnv->sendMessageFromJava(env, runnableMsg); + NS_IF_RELEASE(runnableMsg); + } + } + sharedMonitor.exit(); + } } static nsIPrincipal* newCodebasePrincipal(const char* codebaseURL) { - nsIPrincipal* principal = NULL; + nsIPrincipal* principal = NULL; #if 0 - nsICapsManager* capsManager = NULL; - static NS_DEFINE_IID(kICapsManagerIID, NS_ICAPSMANAGER_IID); - if (thePluginManager->QueryInterface(kICapsManagerIID, &capsManager) == NS_OK) { - if (capsManager->CreateCodebasePrincipal(codebaseURL, &principal) != NS_OK) - principal = NULL; - capsManager->Release(); - } + nsICapsManager* capsManager = NULL; + static NS_DEFINE_IID(kICapsManagerIID, NS_ICAPSMANAGER_IID); + if (thePluginManager->QueryInterface(kICapsManagerIID, &capsManager) == NS_OK) { + if (capsManager->CreateCodebasePrincipal(codebaseURL, &principal) != NS_OK) + principal = NULL; + capsManager->Release(); + } #endif - return principal; + return principal; } /****************** Implementation of methods of JSObject *******************/ @@ -403,25 +446,30 @@ static nsIPrincipal* newCodebasePrincipal(const char* codebaseURL) */ class GetMemberMessage : public JavaMessage { - jsobject mObject; - const jchar* mPropertyName; - jsize mLength; - jobject* mResultObject; + MRJPluginInstance* mPluginInstance; + jsobject mObject; + const jchar* mPropertyName; + jsize mLength; + jobject* mResultObject; public: - GetMemberMessage(jsobject js_obj, const jchar* propertyName, jsize nameLength, jobject* member) - : mObject(js_obj), mPropertyName(propertyName), mLength(nameLength), mResultObject(member) - { - } + GetMemberMessage(MRJPluginInstance* pluginInstance, jsobject js_obj, + const jchar* propertyName, jsize nameLength, jobject* member) + : mPluginInstance(pluginInstance), mObject(js_obj), mPropertyName(propertyName), + mLength(nameLength), mResultObject(member) + { + } - virtual void execute(JNIEnv* env) - { - jobject member; - nsresult result = theLiveConnectManager->GetMember(env, mObject, mPropertyName, mLength, NULL, 0, NULL, &member); - if (result == NS_OK) { - // convert reference to a global reference, in case we're switching threads. - *mResultObject = ToGlobalRef(env, member); - } - } + virtual void execute(JNIEnv* env) + { + MRJSecurityContext* securityContext = getSecurityContext(mPluginInstance); + nsILiveconnect* connection = securityContext->getConnection(); + jobject member; + nsresult result = connection->GetMember(env, mObject, mPropertyName, mLength, NULL, 0, NULL, &member); + if (result == NS_OK) { + // convert reference to a global reference, in case we're switching threads. + *mResultObject = ToGlobalRef(env, member); + } + } }; JNIEXPORT jobject JNICALL @@ -429,27 +477,33 @@ Java_netscape_javascript_JSObject_getMember(JNIEnv* env, jobject java_wrapper_obj, jstring property_name_jstr) { - if (property_name_jstr == NULL) { - env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null member name"); - return NULL; - } + if (property_name_jstr == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null member name"); + return NULL; + } - /* Get the Unicode string for the JS property name */ - jboolean is_copy; - const jchar* property_name_ucs2 = env->GetStringChars(property_name_jstr, &is_copy); - jsize property_name_len = env->GetStringLength(property_name_jstr); + MRJPluginInstance* pluginInstance = GetCurrentInstance(env); + if (pluginInstance == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)"); + return NULL; + } - jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); - jobject member = NULL; - GetMemberMessage msg(js_obj, property_name_ucs2, property_name_len, &member); - - sendMessage(env, &msg); + /* Get the Unicode string for the JS property name */ + jboolean is_copy; + const jchar* property_name_ucs2 = env->GetStringChars(property_name_jstr, &is_copy); + jsize property_name_len = env->GetStringLength(property_name_jstr); - // convert the resulting reference back to a local reference. - if (member != NULL) - member = ToLocalRef(env, member); - - env->ReleaseStringChars(property_name_jstr, property_name_ucs2); + jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); + jobject member = NULL; + + GetMemberMessage msg(pluginInstance, js_obj, property_name_ucs2, property_name_len, &member); + sendMessage(env, &msg); + + // convert the resulting reference back to a local reference. + if (member != NULL) + member = ToLocalRef(env, member); + + env->ReleaseStringChars(property_name_jstr, property_name_ucs2); return member; } @@ -461,24 +515,28 @@ Java_netscape_javascript_JSObject_getMember(JNIEnv* env, */ class GetSlotMessage : public JavaMessage { - jsobject mObject; - jint mSlot; - jobject* mResultObject; + MRJPluginInstance* mPluginInstance; + jsobject mObject; + jint mSlot; + jobject* mResultObject; public: - GetSlotMessage(jsobject js_obj, jint slot, jobject* member) - : mObject(js_obj), mSlot(slot), mResultObject(member) - { - } + GetSlotMessage(MRJPluginInstance* pluginInstance, jsobject js_obj, + jint slot, jobject* member) + : mPluginInstance(pluginInstance), mObject(js_obj), mSlot(slot), mResultObject(member) + { + } - virtual void execute(JNIEnv* env) - { - jobject member; - nsresult result = theLiveConnectManager->GetSlot(env, mObject, mSlot, NULL, 0, NULL, &member); - if (result == NS_OK) { - // convert reference to a global reference, in case we're switching threads. - *mResultObject = ToGlobalRef(env, member); - } - } + virtual void execute(JNIEnv* env) + { + MRJSecurityContext* securityContext = getSecurityContext(mPluginInstance); + nsILiveconnect* connection = securityContext->getConnection(); + jobject member; + nsresult result = connection->GetSlot(env, mObject, mSlot, NULL, 0, NULL, &member); + if (result == NS_OK) { + // convert reference to a global reference, in case we're switching threads. + *mResultObject = ToGlobalRef(env, member); + } + } }; JNIEXPORT jobject JNICALL @@ -486,13 +544,21 @@ Java_netscape_javascript_JSObject_getSlot(JNIEnv* env, jobject java_wrapper_obj, jint slot) { - jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); - jobject member = NULL; - GetSlotMessage msg(js_obj, slot, &member); - sendMessage(env, &msg); - // convert the resulting reference back to a local reference. - if (member != NULL) - member = ToLocalRef(env, member); + MRJPluginInstance* pluginInstance = GetCurrentInstance(env); + if (pluginInstance == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)"); + return NULL; + } + + jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); + jobject member = NULL; + + GetSlotMessage msg(pluginInstance, js_obj, slot, &member); + sendMessage(env, &msg); + + // convert the resulting reference back to a local reference. + if (member != NULL) + member = ToLocalRef(env, member); return member; } @@ -503,20 +569,24 @@ Java_netscape_javascript_JSObject_getSlot(JNIEnv* env, */ class SetMemberMessage : public JavaMessage { - jsobject mObject; - const jchar* mPropertyName; - jsize mLength; - jobject mJavaObject; + MRJPluginInstance* mPluginInstance; + jsobject mObject; + const jchar* mPropertyName; + jsize mLength; + jobject mJavaObject; public: - SetMemberMessage(jsobject js_obj, const jchar* propertyName, jsize nameLength, jobject java_obj) - : mObject(js_obj), mPropertyName(propertyName), mLength(nameLength), mJavaObject(java_obj) - { - } + SetMemberMessage(MRJPluginInstance* pluginInstance, jsobject js_obj, const jchar* propertyName, + jsize nameLength, jobject java_obj) + : mPluginInstance(pluginInstance), mObject(js_obj), mPropertyName(propertyName), mLength(nameLength), mJavaObject(java_obj) + { + } - virtual void execute(JNIEnv* env) - { - nsresult result = theLiveConnectManager->SetMember(env, mObject, mPropertyName, mLength, NULL, 0, NULL, mJavaObject); - } + virtual void execute(JNIEnv* env) + { + MRJSecurityContext* securityContext = getSecurityContext(mPluginInstance); + nsILiveconnect* connection = securityContext->getConnection(); + nsresult result = connection->SetMember(env, mObject, mPropertyName, mLength, mJavaObject, 0, NULL, securityContext); + } }; JNIEXPORT void JNICALL @@ -525,24 +595,30 @@ Java_netscape_javascript_JSObject_setMember(JNIEnv* env, jstring property_name_jstr, jobject java_obj) { - if (property_name_jstr == NULL) { - env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null member name"); - return; - } + if (property_name_jstr == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null member name"); + return; + } - /* Get the Unicode string for the JS property name */ - jboolean is_copy; - const jchar* property_name_ucs2 = env->GetStringChars(property_name_jstr, &is_copy); - jsize property_name_len = env->GetStringLength(property_name_jstr); - - jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); - java_obj = ToGlobalRef(env, java_obj); - SetMemberMessage msg(js_obj, property_name_ucs2, property_name_len, java_obj); - - sendMessage(env, &msg); - - env->DeleteGlobalRef(java_obj); - env->ReleaseStringChars(property_name_jstr, property_name_ucs2); + MRJPluginInstance* pluginInstance = GetCurrentInstance(env); + if (pluginInstance == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)"); + return; + } + + /* Get the Unicode string for the JS property name */ + jboolean is_copy; + const jchar* property_name_ucs2 = env->GetStringChars(property_name_jstr, &is_copy); + jsize property_name_len = env->GetStringLength(property_name_jstr); + + jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); + java_obj = ToGlobalRef(env, java_obj); + + SetMemberMessage msg(pluginInstance, js_obj, property_name_ucs2, property_name_len, java_obj); + sendMessage(env, &msg); + + env->DeleteGlobalRef(java_obj); + env->ReleaseStringChars(property_name_jstr, property_name_ucs2); } /* @@ -552,19 +628,22 @@ Java_netscape_javascript_JSObject_setMember(JNIEnv* env, */ class SetSlotMessage : public JavaMessage { - jsobject mObject; - jint mSlot; - jobject mJavaObject; + MRJPluginInstance* mPluginInstance; + jsobject mObject; + jint mSlot; + jobject mJavaObject; public: - SetSlotMessage(jsobject js_obj, jint slot, jobject java_obj) - : mObject(js_obj), mSlot(slot), mJavaObject(java_obj) - { - } + SetSlotMessage(MRJPluginInstance* pluginInstance, jsobject js_obj, jint slot, jobject java_obj) + : mPluginInstance(pluginInstance), mObject(js_obj), mSlot(slot), mJavaObject(java_obj) + { + } - virtual void execute(JNIEnv* env) - { - nsresult result = theLiveConnectManager->SetSlot(env, mObject, mSlot, NULL, 0, NULL, mJavaObject); - } + virtual void execute(JNIEnv* env) + { + MRJSecurityContext* securityContext = getSecurityContext(mPluginInstance); + nsILiveconnect* connection = securityContext->getConnection(); + nsresult result = connection->SetSlot(env, mObject, mSlot, mJavaObject, 0, NULL, securityContext); + } }; JNIEXPORT void JNICALL @@ -573,11 +652,18 @@ Java_netscape_javascript_JSObject_setSlot(JNIEnv* env, jint slot, jobject java_obj) { - jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); - java_obj = ToGlobalRef(env, java_obj); - SetSlotMessage msg(js_obj, slot, java_obj); - sendMessage(env, &msg); - env->DeleteGlobalRef(java_obj); + MRJPluginInstance* pluginInstance = GetCurrentInstance(env); + if (pluginInstance == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)"); + return; + } + + jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); + java_obj = ToGlobalRef(env, java_obj); + + SetSlotMessage msg(pluginInstance, js_obj, slot, java_obj); + sendMessage(env, &msg); + env->DeleteGlobalRef(java_obj); } /* @@ -587,19 +673,24 @@ Java_netscape_javascript_JSObject_setSlot(JNIEnv* env, */ class RemoveMemberMessage : public JavaMessage { - jsobject mObject; - const jchar* mPropertyName; - jsize mLength; + MRJPluginInstance* mPluginInstance; + jsobject mObject; + const jchar* mPropertyName; + jsize mLength; public: - RemoveMemberMessage(jsobject obj, const jchar* propertyName, jsize length) - : mObject(obj), mPropertyName(propertyName), mLength(length) - { - } + RemoveMemberMessage(MRJPluginInstance* pluginInstance, jsobject obj, + const jchar* propertyName, jsize length) + : mPluginInstance(pluginInstance), mObject(obj), + mPropertyName(propertyName), mLength(length) + { + } - virtual void execute(JNIEnv* env) - { - nsresult result = theLiveConnectManager->RemoveMember(env, mObject, mPropertyName, mLength, NULL, 0, NULL); - } + virtual void execute(JNIEnv* env) + { + MRJSecurityContext* securityContext = getSecurityContext(mPluginInstance); + nsILiveconnect* connection = securityContext->getConnection(); + nsresult result = connection->RemoveMember(env, mObject, mPropertyName, mLength, NULL, 0, NULL); + } }; JNIEXPORT void JNICALL @@ -607,56 +698,30 @@ Java_netscape_javascript_JSObject_removeMember(JNIEnv* env, jobject java_wrapper_obj, jstring property_name_jstr) { - if (property_name_jstr == NULL) { - env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null member name"); - return; - } + if (property_name_jstr == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null member name"); + return; + } - /* Get the Unicode string for the JS property name */ - jboolean is_copy; - const jchar* property_name_ucs2 = env->GetStringChars(property_name_jstr, &is_copy); - jsize property_name_len = env->GetStringLength(property_name_jstr); + MRJPluginInstance* pluginInstance = GetCurrentInstance(env); + if (pluginInstance == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)"); + return; + } - jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); - RemoveMemberMessage msg(js_obj, property_name_ucs2, property_name_len); - - sendMessage(env, &msg); - - env->ReleaseStringChars(property_name_jstr, property_name_ucs2); + /* Get the Unicode string for the JS property name */ + jboolean is_copy; + const jchar* property_name_ucs2 = env->GetStringChars(property_name_jstr, &is_copy); + jsize property_name_len = env->GetStringLength(property_name_jstr); + + jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); + RemoveMemberMessage msg(pluginInstance, js_obj, property_name_ucs2, property_name_len); + + sendMessage(env, &msg); + + env->ReleaseStringChars(property_name_jstr, property_name_ucs2); } -class CallMessage : public JavaMessage { - jsobject mObject; - const jchar* mFunctionName; - jsize mLength; - jobjectArray mJavaArgs; - jobject* mJavaResult; - const char* mCodebaseURL; -public: - CallMessage(jsobject obj, const jchar* functionName, jsize length, jobjectArray javaArgs, jobject* javaResult, const char* codebaseURL) - : mObject(obj), mFunctionName(functionName), mLength(length), - mJavaArgs(javaArgs), mJavaResult(javaResult), mCodebaseURL(codebaseURL) - { - } - - virtual void execute(JNIEnv* env) - { - /* If we have an applet, try to create a codebase principle. */ - nsIPrincipal* principal = NULL; - nsISecurityContext* context = NULL; - if (mCodebaseURL != NULL) { - principal = newCodebasePrincipal(mCodebaseURL); - context = newSecurityContext(); - } - jobject jresult = NULL; - nsresult result = theLiveConnectManager->Call(env, mObject, mFunctionName, mLength, mJavaArgs, &principal, (principal != NULL ? 1 : 0), context, &jresult); - NS_IF_RELEASE(principal); - NS_IF_RELEASE(context); - if (result == NS_OK) - *mJavaResult = ToGlobalRef(env, jresult); - } -}; - /* * Class: netscape_javascript_JSObject * Method: call @@ -666,35 +731,62 @@ JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_call(JNIEnv* env, jobject java_wrapper_obj, jstring function_name_jstr, jobjectArray java_args) { - if (function_name_jstr == NULL) { - env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null function name"); - return NULL; - } + if (function_name_jstr == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null function name"); + return NULL; + } - /* Try to determine which plugin instance is responsible for this thread. This is done by checking class loaders. */ - const char* codebaseURL = NULL; - MRJPluginInstance* pluginInstance = GetCurrentInstance(env); - if (pluginInstance != NULL) - codebaseURL = pluginInstance->getContext()->getDocumentBase(); + class CallMessage : public JavaMessage { + MRJPluginInstance* mPluginInstance; + jsobject mObject; + const jchar* mFunctionName; + jsize mLength; + jobjectArray mJavaArgs; + jobject* mJavaResult; + public: + CallMessage(MRJPluginInstance* pluginInstance, jsobject obj, const jchar* functionName, + jsize length, jobjectArray javaArgs, jobject* javaResult) + : mPluginInstance(pluginInstance), mObject(obj), mFunctionName(functionName), + mLength(length), mJavaArgs(javaArgs), mJavaResult(javaResult) + { + } - /* Get the Unicode string for the JS function name */ - jboolean is_copy; - const jchar* function_name_ucs2 = env->GetStringChars(function_name_jstr, &is_copy); - jsize function_name_len = env->GetStringLength(function_name_jstr); + virtual void execute(JNIEnv* env) + { + /* If we have an applet, try to create a codebase principle. */ + MRJSecurityContext* securityContext = getSecurityContext(mPluginInstance); + nsILiveconnect* connection = securityContext->getConnection(); + jobject jresult = NULL; + nsresult result = connection->Call(env, mObject, mFunctionName, mLength, mJavaArgs, NULL, 0, securityContext, &jresult); + if (result == NS_OK) + *mJavaResult = ToGlobalRef(env, jresult); + } + }; - jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); - jobject jresult = NULL; + /* Try to determine which plugin instance is responsible for this thread. This is done by checking class loaders. */ + MRJPluginInstance* pluginInstance = GetCurrentInstance(env); + if (pluginInstance == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)"); + return NULL; + } - CallMessage msg(js_obj, function_name_ucs2, function_name_len, java_args, &jresult, codebaseURL); + /* Get the Unicode string for the JS function name */ + jboolean is_copy; + const jchar* function_name_ucs2 = env->GetStringChars(function_name_jstr, &is_copy); + jsize function_name_len = env->GetStringLength(function_name_jstr); - sendMessage(env, &msg); + jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); + jobject jresult = NULL; - env->ReleaseStringChars(function_name_jstr, function_name_ucs2); + CallMessage msg(pluginInstance, js_obj, function_name_ucs2, function_name_len, java_args, &jresult); + sendMessage(env, &msg); - if (jresult != NULL) - jresult = ToLocalRef(env, jresult); + env->ReleaseStringChars(function_name_jstr, function_name_ucs2); - return jresult; + if (jresult != NULL) + jresult = ToLocalRef(env, jresult); + + return jresult; } /* @@ -707,63 +799,65 @@ Java_netscape_javascript_JSObject_eval(JNIEnv* env, jobject java_wrapper_obj, jstring script_jstr) { - /* Get the Unicode string for the JS function name */ - if (script_jstr == NULL) { - env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null script string"); - return NULL; - } - jboolean is_copy; - const jchar* script_ucs2 = env->GetStringChars(script_jstr, &is_copy); - jsize script_len = env->GetStringLength(script_jstr); + /* Get the Unicode string for the JS function name */ + if (script_jstr == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null script string"); + return NULL; + } + jboolean is_copy; + const jchar* script_ucs2 = env->GetStringChars(script_jstr, &is_copy); + jsize script_len = env->GetStringLength(script_jstr); - /* unwrap the JS object from the Java object. */ - jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); - jobject jresult = NULL; - + /* unwrap the JS object from the Java object. */ + jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); + jobject jresult = NULL; + #ifdef MRJPLUGIN_4X - nsresult status = theLiveConnectManager->Eval(env, js_obj, script_ucs2, script_len, NULL, 0, NULL, &jresult); + nsresult status = theLiveConnectManager->Eval(env, js_obj, script_ucs2, script_len, NULL, 0, NULL, &jresult); #else - class EvalMessage : public JavaMessage { - JNIEnv* mEnv; - jsobject mObject; - const jchar* mScript; - jsize mLength; - jobject* mJavaResult; - public: - EvalMessage(jsobject obj, const jchar* script, jsize length, jobject* javaResult) - : mObject(obj), mScript(script), mLength(length), mJavaResult(javaResult) - { - } + class EvalMessage : public JavaMessage { + MRJPluginInstance* mPluginInstance; + jsobject mObject; + const jchar* mScript; + jsize mLength; + jobject* mJavaResult; + public: + EvalMessage(MRJPluginInstance* pluginInstance, jsobject obj, const jchar* script, jsize length, jobject* javaResult) + : mPluginInstance(pluginInstance), mObject(obj), mScript(script), mLength(length), mJavaResult(javaResult) + { + } - virtual void execute(JNIEnv* env) - { - jobject jresult = NULL; - nsresult result = theLiveConnectManager->Eval(env, mObject, mScript, mLength, NULL, 0, NULL, &jresult); - if (result == NS_OK && jresult != NULL) - *mJavaResult = ToGlobalRef(env, jresult); - } - }; + virtual void execute(JNIEnv* env) + { + jobject jresult = NULL; + MRJSecurityContext* securityContext = getSecurityContext(mPluginInstance); + nsILiveconnect* connection = securityContext->getConnection(); + nsresult result = connection->Eval(env, mObject, mScript, mLength, NULL, 0, securityContext, &jresult); + if (result == NS_OK && jresult != NULL) + *mJavaResult = ToGlobalRef(env, jresult); + } + }; - /* determine the plugin instance so we can obtain its codebase. */ - // beard: should file a bug with Apple that JMJNIToAWTContext doesn't work. - // MRJPluginInstance* pluginInstance = theJVMPlugin->getPluginInstance(env); - MRJPluginInstance* pluginInstance = GetCurrentInstance(env); - if (pluginInstance == NULL) { - env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)"); - return NULL; - } - - EvalMessage msg(js_obj, script_ucs2, script_len, &jresult); - sendMessage(env, &msg); - - if (jresult != NULL) - jresult = ToLocalRef(env, jresult); - + /* determine the plugin instance so we can obtain its codebase. */ + // beard: should file a bug with Apple that JMJNIToAWTContext doesn't work. + // MRJPluginInstance* pluginInstance = theJVMPlugin->getPluginInstance(env); + MRJPluginInstance* pluginInstance = GetCurrentInstance(env); + if (pluginInstance == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)"); + return NULL; + } + + EvalMessage msg(pluginInstance, js_obj, script_ucs2, script_len, &jresult); + sendMessage(env, &msg); + + if (jresult != NULL) + jresult = ToLocalRef(env, jresult); + #endif - env->ReleaseStringChars(script_jstr, script_ucs2); + env->ReleaseStringChars(script_jstr, script_ucs2); - return jresult; + return jresult; } /* @@ -774,34 +868,44 @@ Java_netscape_javascript_JSObject_eval(JNIEnv* env, JNIEXPORT jstring JNICALL Java_netscape_javascript_JSObject_toString(JNIEnv* env, jobject java_wrapper_obj) { - /* unwrap the JS object from the Java object. */ - jstring jresult = NULL; - jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); + /* unwrap the JS object from the Java object. */ + jstring jresult = NULL; + jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj); - class ToStringMessage : public JavaMessage { - jsobject mObject; - jstring* mStringResult; - public: - ToStringMessage(jsobject js_obj, jstring* stringResult) - : mObject(js_obj), mStringResult(stringResult) - { - } + class ToStringMessage : public JavaMessage { + MRJPluginInstance* mPluginInstance; + jsobject mObject; + jstring* mStringResult; + public: + ToStringMessage(MRJPluginInstance* pluginInstance, jsobject js_obj, jstring* stringResult) + : mPluginInstance(pluginInstance), mObject(js_obj), mStringResult(stringResult) + { + } - virtual void execute(JNIEnv* env) - { - jstring jresult = NULL; - nsresult status = theLiveConnectManager->ToString(env, mObject, &jresult); - if (status == NS_OK && jresult != NULL) - *mStringResult = (jstring) ToGlobalRef(env, jresult); - } - } msg(js_obj, &jresult); - - sendMessage(env, &msg); - - if (jresult != NULL) - jresult = (jstring) ToLocalRef(env, jresult); - - return jresult; + virtual void execute(JNIEnv* env) + { + MRJSecurityContext* securityContext = getSecurityContext(mPluginInstance); + nsILiveconnect* connection = securityContext->getConnection(); + jstring jresult = NULL; + nsresult status = connection->ToString(env, mObject, &jresult); + if (status == NS_OK && jresult != NULL) + *mStringResult = (jstring) ToGlobalRef(env, jresult); + } + }; + + MRJPluginInstance* pluginInstance = GetCurrentInstance(env); + if (pluginInstance == NULL) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)"); + return NULL; + } + + ToStringMessage msg(pluginInstance, js_obj, &jresult); + sendMessage(env, &msg); + + if (jresult != NULL) + jresult = (jstring) ToLocalRef(env, jresult); + + return jresult; } /* @@ -815,37 +919,45 @@ Java_netscape_javascript_JSObject_getWindow(JNIEnv* env, jclass js_object_class, jobject java_applet_obj) { - MRJPluginInstance* pluginInstance = theJVMPlugin->getPluginInstance(java_applet_obj); - if (pluginInstance != NULL) { + MRJPluginInstance* pluginInstance = theJVMPlugin->getPluginInstance(java_applet_obj); + if (pluginInstance != NULL) { #ifdef MRJPLUGIN_4X - // keep an extra reference to the plugin instance, until it is finalized. - jobject jwindow = Wrap_JSObject(env, jsobject(pluginInstance)); - return jwindow; + // keep an extra reference to the plugin instance, until it is finalized. + jobject jwindow = Wrap_JSObject(env, jsobject(pluginInstance)); + return jwindow; #else - class GetWindowMessage : public JavaMessage { - nsIPluginInstance* mPluginInstance; - jsobject* mWindowResult; - public: - GetWindowMessage(nsIPluginInstance* pluginInstance, jsobject* windowResult) - : mPluginInstance(pluginInstance), mWindowResult(windowResult) - { - } + class GetWindowMessage : public JavaMessage { + MRJPluginInstance* mPluginInstance; + jsobject* mWindowResult; + public: + GetWindowMessage(MRJPluginInstance* pluginInstance, jsobject* windowResult) + : mPluginInstance(pluginInstance), mWindowResult(windowResult) + { + NS_ADDREF(pluginInstance); + } + + ~GetWindowMessage() + { + NS_RELEASE(mPluginInstance); + } - virtual void execute(JNIEnv* env) - { - nsresult status = theLiveConnectManager->GetWindow(env,mPluginInstance, NULL, 0, NULL, mWindowResult); - } - }; + virtual void execute(JNIEnv* env) + { + MRJSecurityContext* securityContext = getSecurityContext(mPluginInstance); + nsILiveconnect* connection = securityContext->getConnection(); + nsresult status = connection->GetWindow(env, mPluginInstance, NULL, 0, securityContext, mWindowResult); + } + }; - jsobject jswindow = NULL; - GetWindowMessage msg(pluginInstance, &jswindow); - sendMessage(env, &msg); - pluginInstance->Release(); - if (jswindow != NULL) - return Wrap_JSObject(env, jswindow); + jsobject jswindow = NULL; + GetWindowMessage msg(pluginInstance, &jswindow); + sendMessage(env, &msg); + + if (jswindow != NULL) + return Wrap_JSObject(env, jswindow); #endif - } - return NULL; + } + return NULL; } /* @@ -857,27 +969,27 @@ Java_netscape_javascript_JSObject_getWindow(JNIEnv* env, JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_finalize(JNIEnv* env, jobject java_wrapper_obj) { - jsobject jsobj = Unwrap_JSObject(env, java_wrapper_obj); + jsobject jsobj = Unwrap_JSObject(env, java_wrapper_obj); #ifdef MRJPLUGIN_4X - MRJPluginInstance* pluginInstance = (MRJPluginInstance*)jsobj; - NS_IF_RELEASE(pluginInstance); + MRJPluginInstance* pluginInstance = (MRJPluginInstance*)jsobj; + NS_IF_RELEASE(pluginInstance); #else - class FinalizeMessage : public JavaMessage { - jsobject m_jsobj; - public: - FinalizeMessage(jsobject jsobj) - : m_jsobj(jsobj) - { - } + class FinalizeMessage : public JavaMessage { + jsobject m_jsobj; + public: + FinalizeMessage(jsobject jsobj) + : m_jsobj(jsobj) + { + } - virtual void execute(JNIEnv* env) - { - nsresult result = theLiveConnectManager->FinalizeJSObject(env, m_jsobj); - } - }; - - FinalizeMessage msg(jsobj); - sendMessage(env, &msg); + virtual void execute(JNIEnv* env) + { + nsresult result = theLiveConnectManager->FinalizeJSObject(env, m_jsobj); + } + }; + + FinalizeMessage msg(jsobj); + sendMessage(env, &msg); #endif } diff --git a/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.cp b/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.cp index bae78555906..c6a4c00006a 100644 --- a/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.cp +++ b/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.cp @@ -47,6 +47,7 @@ #include "nsIPluginManager2.h" #include "nsIPluginInstancePeer.h" #include "nsIJVMPluginTagInfo.h" +#include "MRJSecurityContext.h" #include @@ -87,7 +88,7 @@ MRJContext::MRJContext(MRJSession* session, MRJPluginInstance* instance) : mPluginInstance(instance), mSession(session), mSessionRef(session->getSessionRef()), mPeer(NULL), mLocator(NULL), mContext(NULL), mViewer(NULL), mViewerFrame(NULL), mIsActive(false), mPluginWindow(NULL), mPluginClipping(NULL), mPluginPort(NULL), - mDocumentBase(NULL), mAppletHTML(NULL), mPage(NULL) + mDocumentBase(NULL), mAppletHTML(NULL), mPage(NULL), mSecurityContext(NULL) { instance->GetPeer(&mPeer); @@ -148,6 +149,11 @@ MRJContext::~MRJContext() delete[] mAppletHTML; mAppletHTML = NULL; } + + if (mSecurityContext != NULL) { + mSecurityContext->Release(); + mSecurityContext = NULL; + } } static char* slashify(char* url) @@ -1652,6 +1658,18 @@ const char* MRJContext::getAppletHTML() return mAppletHTML; } +void MRJContext::setSecurityContext(MRJSecurityContext* context) +{ + NS_ADDREF(context); + NS_IF_RELEASE(mSecurityContext); + mSecurityContext = context; +} + +MRJSecurityContext* MRJContext::getSecurityContext() +{ + return mSecurityContext; +} + MRJPage* MRJContext::findPage(const MRJPageAttributes& attributes) { MRJPage* page = MRJPage::getFirstPage(); diff --git a/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.h b/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.h index db9cb5a997f..73c042e5025 100644 --- a/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.h +++ b/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.h @@ -48,6 +48,7 @@ struct nsPluginWindow; class MRJFrame; class MRJPage; struct MRJPageAttributes; +class MRJSecurityContext; struct nsPluginPoint { PRInt32 x; @@ -101,6 +102,9 @@ public: void setAppletHTML(const char* appletHTML, nsPluginTagType tagType); const char* getAppletHTML(); + void setSecurityContext(MRJSecurityContext* context); + MRJSecurityContext* getSecurityContext(); + private: void localToFrame(Point* pt); void ensureValidPort(); @@ -145,4 +149,5 @@ private: char* mDocumentBase; char* mAppletHTML; MRJPage* mPage; + MRJSecurityContext* mSecurityContext; }; diff --git a/mozilla/plugin/oji/MRJ/plugin/Source/nsLiveConnect.cpp b/mozilla/plugin/oji/MRJ/plugin/Source/nsLiveConnect.cpp index 0237e89227a..db899448355 100644 --- a/mozilla/plugin/oji/MRJ/plugin/Source/nsLiveConnect.cpp +++ b/mozilla/plugin/oji/MRJ/plugin/Source/nsLiveConnect.cpp @@ -20,7 +20,7 @@ */ /* - nsLiveConnect.cpp + nsLiveConnect.cpp */ #include "nsLiveconnect.h" @@ -33,103 +33,103 @@ extern nsIPluginManager* thePluginManager; const InterfaceInfo nsLiveconnect::sInterfaces[] = { - { NS_ILIVECONNECT_IID, INTERFACE_OFFSET(nsLiveconnect, nsILiveconnect) }, - { NS_IPLUGINSTREAMLISTENER_IID, INTERFACE_OFFSET(nsLiveconnect, nsIPluginStreamListener) }, + { NS_ILIVECONNECT_IID, INTERFACE_OFFSET(nsLiveconnect, nsILiveconnect) }, + { NS_IPLUGINSTREAMLISTENER_IID, INTERFACE_OFFSET(nsLiveconnect, nsIPluginStreamListener) }, }; const UInt32 nsLiveconnect::kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo); nsLiveconnect::nsLiveconnect() - : SupportsMixin(this, sInterfaces, kInterfaceCount), - mJavaScriptMonitor(NULL), mScript(NULL), mResult(NULL) + : SupportsMixin(this, sInterfaces, kInterfaceCount), + mJavaScriptMonitor(NULL), mScript(NULL), mResult(NULL) { } nsLiveconnect::~nsLiveconnect() { - if (mJavaScriptMonitor != NULL) - delete mJavaScriptMonitor; + if (mJavaScriptMonitor != NULL) + delete mJavaScriptMonitor; } static char* u2c(const jchar *ustr, jsize length) { - char* result = new char[length + 1]; - if (result != NULL) { - char* cstr = result; - while (length-- > 0) { - *cstr++ = (char) *ustr++; - } - *cstr = '\0'; - } - return result; + char* result = new char[length + 1]; + if (result != NULL) { + char* cstr = result; + while (length-- > 0) { + *cstr++ = (char) *ustr++; + } + *cstr = '\0'; + } + return result; } const char* kJavaScriptPrefix = "javascript:"; -NS_METHOD +NS_METHOD nsLiveconnect::Eval(JNIEnv *env, jsobject obj, const jchar *script, jsize length, void* principalsArray[], - int numPrincipals, void *securityContext, jobject *outResult) + int numPrincipals, nsISupports *securitySupports, jobject *outResult) { - MRJPluginInstance* pluginInstance = (MRJPluginInstance*) obj; - nsIPluginStreamListener* listener = this; + MRJPluginInstance* pluginInstance = (MRJPluginInstance*) obj; + nsIPluginStreamListener* listener = this; - if (mJavaScriptMonitor == NULL) - mJavaScriptMonitor = new MRJMonitor(pluginInstance->getSession()); + if (mJavaScriptMonitor == NULL) + mJavaScriptMonitor = new MRJMonitor(pluginInstance->getSession()); - mJavaScriptMonitor->enter(); + mJavaScriptMonitor->enter(); - while (mScript != NULL) { - // some other thread is evaluating a script. - mJavaScriptMonitor->wait(); - } - - // convert the script to ASCII, construct a "javascript:" URL. - char* cscript = u2c(script, length); - mScript = new char[strlen(kJavaScriptPrefix) + length + 1]; - strcpy(mScript, kJavaScriptPrefix); - strcat(mScript, cscript); - delete[] cscript; - nsresult result = thePluginManager->GetURL((nsIPluginInstance*)pluginInstance, mScript, NULL, listener); - - // need to block until the result is ready. - mJavaScriptMonitor->wait(); - - // default result is NULL, in case JavaScript returns undefined value. - *outResult = NULL; + while (mScript != NULL) { + // some other thread is evaluating a script. + mJavaScriptMonitor->wait(); + } + + // convert the script to ASCII, construct a "javascript:" URL. + char* cscript = u2c(script, length); + mScript = new char[strlen(kJavaScriptPrefix) + length + 1]; + strcpy(mScript, kJavaScriptPrefix); + strcat(mScript, cscript); + delete[] cscript; + nsresult result = thePluginManager->GetURL((nsIPluginInstance*)pluginInstance, mScript, NULL, listener); + + // need to block until the result is ready. + mJavaScriptMonitor->wait(); + + // default result is NULL, in case JavaScript returns undefined value. + *outResult = NULL; - // result should now be ready, convert it to a Java string and return. - if (mResult != NULL) { - *outResult = env->NewStringUTF(mResult); - delete[] mResult; - mResult = NULL; - } - - delete[] mScript; - mScript = NULL; - - mJavaScriptMonitor->notifyAll(); - - mJavaScriptMonitor->exit(); - - return NS_OK; + // result should now be ready, convert it to a Java string and return. + if (mResult != NULL) { + *outResult = env->NewStringUTF(mResult); + delete[] mResult; + mResult = NULL; + } + + delete[] mScript; + mScript = NULL; + + mJavaScriptMonitor->notifyAll(); + + mJavaScriptMonitor->exit(); + + return NS_OK; } NS_METHOD nsLiveconnect::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length) { - // hopefully all our data is available. - mResult = new char[length + 1]; - if (mResult != NULL) { - if (input->Read(mResult, length, &length) == NS_OK) { - // We've delayed processing the applet tag, because we - // don't know the location of the curren document yet. - mResult[length] = '\0'; - } - } - return NS_OK; + // hopefully all our data is available. + mResult = new char[length + 1]; + if (mResult != NULL) { + if (input->Read(mResult, length, &length) == NS_OK) { + // We've delayed processing the applet tag, because we + // don't know the location of the curren document yet. + mResult[length] = '\0'; + } + } + return NS_OK; } NS_METHOD nsLiveconnect::OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status) { - // the stream has been closed, notify any waiting Java threads. - mJavaScriptMonitor->notifyAll(); - return NS_OK; + // the stream has been closed, notify any waiting Java threads. + mJavaScriptMonitor->notifyAll(); + return NS_OK; } diff --git a/mozilla/plugin/oji/MRJ/plugin/Source/nsLiveConnect.h b/mozilla/plugin/oji/MRJ/plugin/Source/nsLiveConnect.h index f50cf981aa6..ad4511040ab 100644 --- a/mozilla/plugin/oji/MRJ/plugin/Source/nsLiveConnect.h +++ b/mozilla/plugin/oji/MRJ/plugin/Source/nsLiveConnect.h @@ -20,7 +20,7 @@ */ /* - nsLiveConnect.h + nsLiveConnect.h */ #pragma once @@ -32,14 +32,14 @@ class MRJMonitor; class nsLiveconnect : public nsILiveconnect, - public nsIPluginStreamListener, - private SupportsMixin { + public nsIPluginStreamListener, + private SupportsMixin { public: - DECL_SUPPORTS_MIXIN - - nsLiveconnect(); - virtual ~nsLiveconnect(); - + DECL_SUPPORTS_MIXIN + + nsLiveconnect(); + virtual ~nsLiveconnect(); + /** * get member of a Native JSObject for a given name. * @@ -52,10 +52,10 @@ public: */ NS_IMETHOD GetMember(JNIEnv *env, jsobject jsobj, const jchar *name, jsize length, void* principalsArray[], - int numPrincipals, void *securityContext, jobject *pjobj) - { - return NS_ERROR_NOT_IMPLEMENTED; - } + int numPrincipals, nsISupports *securitySupports, jobject *pjobj) + { + return NS_ERROR_NOT_IMPLEMENTED; + } /** * get member of a Native JSObject for a given index. @@ -67,10 +67,10 @@ public: */ NS_IMETHOD GetSlot(JNIEnv *env, jsobject jsobj, jint slot, void* principalsArray[], - int numPrincipals, void *securityContext, jobject *pjobj) - { - return NS_ERROR_NOT_IMPLEMENTED; - } + int numPrincipals, nsISupports *securitySupports, jobject *pjobj) + { + return NS_ERROR_NOT_IMPLEMENTED; + } /** * set member of a Native JSObject for a given name. @@ -83,10 +83,10 @@ public: */ NS_IMETHOD SetMember(JNIEnv *env, jsobject jsobj, const jchar* name, jsize length, jobject jobj, void* principalsArray[], - int numPrincipals, void *securityContext) - { - return NS_ERROR_NOT_IMPLEMENTED; - } + int numPrincipals, nsISupports *securitySupports) + { + return NS_ERROR_NOT_IMPLEMENTED; + } /** * set member of a Native JSObject for a given index. @@ -99,10 +99,10 @@ public: */ NS_IMETHOD SetSlot(JNIEnv *env, jsobject jsobj, jint slot, jobject jobj, void* principalsArray[], - int numPrincipals, void *securityContext) - { - return NS_ERROR_NOT_IMPLEMENTED; - } + int numPrincipals, nsISupports *securitySupports) + { + return NS_ERROR_NOT_IMPLEMENTED; + } /** * remove member of a Native JSObject for a given name. @@ -112,10 +112,10 @@ public: */ NS_IMETHOD RemoveMember(JNIEnv *env, jsobject jsobj, const jchar* name, jsize length, void* principalsArray[], - int numPrincipals, void *securityContext) - { - return NS_ERROR_NOT_IMPLEMENTED; - } + int numPrincipals, nsISupports *securitySupports) + { + return NS_ERROR_NOT_IMPLEMENTED; + } /** * call a method of Native JSObject. @@ -127,10 +127,10 @@ public: */ NS_IMETHOD Call(JNIEnv *env, jsobject jsobj, const jchar* name, jsize length, jobjectArray jobjArr, void* principalsArray[], - int numPrincipals, void *securityContext, jobject *pjobj) - { - return NS_ERROR_NOT_IMPLEMENTED; - } + int numPrincipals, nsISupports *securitySupports, jobject *pjobj) + { + return NS_ERROR_NOT_IMPLEMENTED; + } /** * Evaluate a script with a Native JS Object representing scope. @@ -141,9 +141,9 @@ public: * @param script - Script to be executed. * @param pjobj - return value. */ - NS_IMETHOD + NS_IMETHOD Eval(JNIEnv *env, jsobject obj, const jchar *script, jsize length, void* principalsArray[], - int numPrincipals, void *securityContext, jobject *outResult); + int numPrincipals, nsISupports *securitySupports, jobject *outResult); /** * Get the window object for a plugin instance. @@ -156,10 +156,10 @@ public: */ NS_IMETHOD GetWindow(JNIEnv *env, void *pJavaObject, void* principalsArray[], - int numPrincipals, void *securityContext, jsobject *pobj) - { - return NS_ERROR_NOT_IMPLEMENTED; - } + int numPrincipals, nsISupports *securitySupports, jsobject *pobj) + { + return NS_ERROR_NOT_IMPLEMENTED; + } /** * Finalize a JSObject instance. @@ -169,9 +169,9 @@ public: */ NS_IMETHOD FinalizeJSObject(JNIEnv *env, jsobject jsobj) - { - return NS_ERROR_NOT_IMPLEMENTED; - } + { + return NS_ERROR_NOT_IMPLEMENTED; + } /** * Convert a JSObject to a string. @@ -182,12 +182,12 @@ public: */ NS_IMETHOD ToString(JNIEnv *env, jsobject obj, jstring *pjstring) - { - return NS_ERROR_NOT_IMPLEMENTED; - } + { + return NS_ERROR_NOT_IMPLEMENTED; + } - // nsIPluginStreamListener implementation. - + // nsIPluginStreamListener implementation. + /** * Notify the observer that the URL has started to load. This method is * called only once, at the beginning of a URL load.

@@ -198,7 +198,7 @@ public: NS_IMETHOD OnStartBinding(nsIPluginStreamInfo* pluginInfo) { - return NS_OK; + return NS_OK; } /** @@ -217,9 +217,9 @@ public: NS_IMETHOD OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName) { - return NS_ERROR_NOT_IMPLEMENTED; - } - + return NS_ERROR_NOT_IMPLEMENTED; + } + /** * Notify the observer that the URL has finished loading. This method is * called once when the networking library has finished processing the @@ -234,22 +234,22 @@ public: NS_IMETHOD OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status); - /** - * What is this method supposed to do? - */ + /** + * What is this method supposed to do? + */ NS_IMETHOD GetStreamType(nsPluginStreamType *result) { - *result = nsPluginStreamType_Normal; - return NS_OK; + *result = nsPluginStreamType_Normal; + return NS_OK; } private: - MRJMonitor* mJavaScriptMonitor; - char* mScript; - char* mResult; + MRJMonitor* mJavaScriptMonitor; + char* mScript; + char* mResult; - // support for SupportsMixin. - static const InterfaceInfo sInterfaces[]; - static const UInt32 kInterfaceCount; + // support for SupportsMixin. + static const InterfaceInfo sInterfaces[]; + static const UInt32 kInterfaceCount; };