fix for bug #63466, r=mstoltz, sr=brendan, a=leaf
git-svn-id: svn://10.0.0.236/trunk@86811 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -184,9 +184,14 @@ nsCodebasePrincipal::Equals(nsIPrincipal *other, PRBool *result)
|
||||
if (NS_SUCCEEDED(rv) && PL_strcmp(otherScheme, myScheme) == 0)
|
||||
{
|
||||
|
||||
if (PL_strcmp(otherScheme, "imap") == 0 ||
|
||||
PL_strcmp(otherScheme, "mailbox") == 0 ||
|
||||
PL_strcmp(otherScheme, "news") == 0)
|
||||
if (PL_strcmp(otherScheme, "file") == 0)
|
||||
{
|
||||
// All file: urls are considered to have the same origin.
|
||||
*result = PR_TRUE;
|
||||
}
|
||||
else if (PL_strcmp(otherScheme, "imap") == 0 ||
|
||||
PL_strcmp(otherScheme, "mailbox") == 0 ||
|
||||
PL_strcmp(otherScheme, "news") == 0)
|
||||
{
|
||||
// Each message is a distinct trust domain; use the
|
||||
// whole spec for comparison
|
||||
|
||||
@@ -161,7 +161,7 @@ nsCLiveconnect::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
*/
|
||||
NS_METHOD
|
||||
nsCLiveconnect::GetMember(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize length, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj)
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
|
||||
{
|
||||
if(jEnv == NULL || obj == 0)
|
||||
{
|
||||
@@ -178,7 +178,7 @@ nsCLiveconnect::GetMember(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize l
|
||||
JSBool dummy_bool = PR_FALSE;
|
||||
JSErrorReporter saved_state = NULL;
|
||||
|
||||
jsj_env = jsj_enter_js(jEnv, NULL, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, pNSISecurityContext);
|
||||
jsj_env = jsj_enter_js(jEnv, mJavaClient, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, securitySupports);
|
||||
if (!jsj_env)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -217,7 +217,7 @@ done:
|
||||
*/
|
||||
NS_METHOD
|
||||
nsCLiveconnect::GetSlot(JNIEnv *jEnv, jsobject obj, jint slot, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj)
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
|
||||
{
|
||||
if(jEnv == NULL || obj == 0)
|
||||
{
|
||||
@@ -234,7 +234,7 @@ nsCLiveconnect::GetSlot(JNIEnv *jEnv, jsobject obj, jint slot, void* principalsA
|
||||
JSBool dummy_bool = PR_FALSE;
|
||||
JSErrorReporter saved_state = NULL;
|
||||
|
||||
jsj_env = jsj_enter_js(jEnv, NULL, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, pNSISecurityContext);
|
||||
jsj_env = jsj_enter_js(jEnv, mJavaClient, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, securitySupports);
|
||||
if (!jsj_env)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -268,7 +268,7 @@ done:
|
||||
*/
|
||||
NS_METHOD
|
||||
nsCLiveconnect::SetMember(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize length, jobject java_obj, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext)
|
||||
int numPrincipals, nsISupports *securitySupports)
|
||||
{
|
||||
if(jEnv == NULL || obj == 0)
|
||||
{
|
||||
@@ -282,7 +282,7 @@ nsCLiveconnect::SetMember(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize l
|
||||
jsval js_val;
|
||||
JSErrorReporter saved_state = NULL;
|
||||
|
||||
jsj_env = jsj_enter_js(jEnv, NULL, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, pNSISecurityContext);
|
||||
jsj_env = jsj_enter_js(jEnv, mJavaClient, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, securitySupports);
|
||||
if (!jsj_env)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -316,7 +316,7 @@ done:
|
||||
*/
|
||||
NS_METHOD
|
||||
nsCLiveconnect::SetSlot(JNIEnv *jEnv, jsobject obj, jint slot, jobject java_obj, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext)
|
||||
int numPrincipals, nsISupports *securitySupports)
|
||||
{
|
||||
if(jEnv == NULL || obj == 0)
|
||||
{
|
||||
@@ -330,7 +330,7 @@ nsCLiveconnect::SetSlot(JNIEnv *jEnv, jsobject obj, jint slot, jobject java_obj,
|
||||
jsval js_val;
|
||||
JSErrorReporter saved_state = NULL;
|
||||
|
||||
jsj_env = jsj_enter_js(jEnv, NULL, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, pNSISecurityContext);
|
||||
jsj_env = jsj_enter_js(jEnv, mJavaClient, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, securitySupports);
|
||||
if (!jsj_env)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -355,7 +355,7 @@ done:
|
||||
*/
|
||||
NS_METHOD
|
||||
nsCLiveconnect::RemoveMember(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize length, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext)
|
||||
int numPrincipals, nsISupports *securitySupports)
|
||||
{
|
||||
if(jEnv == NULL || obj == 0)
|
||||
{
|
||||
@@ -369,7 +369,7 @@ nsCLiveconnect::RemoveMember(JNIEnv *jEnv, jsobject obj, const jchar *name, jsiz
|
||||
jsval js_val;
|
||||
JSErrorReporter saved_state = NULL;
|
||||
|
||||
jsj_env = jsj_enter_js(jEnv, NULL, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, pNSISecurityContext);
|
||||
jsj_env = jsj_enter_js(jEnv, mJavaClient, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, securitySupports);
|
||||
if (!jsj_env)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -399,7 +399,7 @@ done:
|
||||
*/
|
||||
NS_METHOD
|
||||
nsCLiveconnect::Call(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize length, jobjectArray java_args, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj)
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
|
||||
{
|
||||
if(jEnv == NULL || obj == 0)
|
||||
{
|
||||
@@ -421,7 +421,7 @@ nsCLiveconnect::Call(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize length
|
||||
JSErrorReporter saved_state = NULL;
|
||||
jobject result = NULL;
|
||||
|
||||
jsj_env = jsj_enter_js(jEnv, NULL, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, pNSISecurityContext);
|
||||
jsj_env = jsj_enter_js(jEnv, mJavaClient, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, securitySupports);
|
||||
if (!jsj_env)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -478,7 +478,7 @@ done:
|
||||
|
||||
NS_METHOD
|
||||
nsCLiveconnect::Eval(JNIEnv *jEnv, jsobject obj, const jchar *script, jsize length, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj)
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
|
||||
{
|
||||
if(jEnv == NULL || obj == 0)
|
||||
{
|
||||
@@ -498,7 +498,7 @@ nsCLiveconnect::Eval(JNIEnv *jEnv, jsobject obj, const jchar *script, jsize leng
|
||||
JSPrincipals *principals = NULL;
|
||||
JSBool eval_succeeded = PR_FALSE;
|
||||
|
||||
jsj_env = jsj_enter_js(jEnv, NULL, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, pNSISecurityContext);
|
||||
jsj_env = jsj_enter_js(jEnv, mJavaClient, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, securitySupports);
|
||||
if (!jsj_env)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -511,15 +511,15 @@ nsCLiveconnect::Eval(JNIEnv *jEnv, jsobject obj, const jchar *script, jsize leng
|
||||
}
|
||||
|
||||
/* Set up security stuff */
|
||||
principals = NULL;
|
||||
if (JSJ_callbacks && JSJ_callbacks->get_JSPrincipals_from_java_caller)
|
||||
principals = JSJ_callbacks->get_JSPrincipals_from_java_caller(jEnv, cx, principalsArray, numPrincipals, pNSISecurityContext);
|
||||
codebase = principals ? (const char *)principals->codebase : NULL;
|
||||
principals = JSJ_callbacks->get_JSPrincipals_from_java_caller(jEnv, cx, principalsArray, numPrincipals, securitySupports);
|
||||
codebase = principals ? principals->codebase : NULL;
|
||||
|
||||
/* Have the JS engine evaluate the unicode string */
|
||||
eval_succeeded = JS_EvaluateUCScriptForPrincipals(cx, js_obj, principals,
|
||||
script, length,
|
||||
codebase, 0, &js_val);
|
||||
|
||||
if (!eval_succeeded)
|
||||
goto done;
|
||||
|
||||
@@ -528,6 +528,8 @@ nsCLiveconnect::Eval(JNIEnv *jEnv, jsobject obj, const jchar *script, jsize leng
|
||||
&dummy_cost, &result, &dummy_bool);
|
||||
|
||||
done:
|
||||
if (principals)
|
||||
JSPRINCIPALS_DROP(cx, principals);
|
||||
if (!jsj_exit_js(cx, jsj_env, saved_state))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -547,33 +549,32 @@ done:
|
||||
* in which a applet/bean resides.
|
||||
*/
|
||||
NS_METHOD
|
||||
nsCLiveconnect::GetWindow(JNIEnv *jEnv, void *java_applet_obj, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jsobject *pobj)
|
||||
nsCLiveconnect::GetWindow(JNIEnv *jEnv, void *pJavaObject, void* principalsArray[],
|
||||
int numPrincipals, nsISupports *securitySupports, jsobject *pobj)
|
||||
{
|
||||
if(jEnv == NULL || JSJ_callbacks == NULL)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// associate this Java client with this LiveConnect connection.
|
||||
mJavaClient = pJavaObject;
|
||||
|
||||
char *err_msg = NULL;
|
||||
JSContext *cx = NULL;
|
||||
JSObject *js_obj = NULL;
|
||||
JSErrorReporter saved_state = NULL;
|
||||
jobject java_obj = NULL;
|
||||
JSJavaThreadState *jsj_env = NULL;
|
||||
// int dummy_cost = 0; // unused
|
||||
// JSBool dummy_bool = PR_FALSE; // unused
|
||||
JSObjectHandle *handle = NULL;
|
||||
|
||||
jsj_env = jsj_enter_js(jEnv, java_applet_obj, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, pNSISecurityContext);
|
||||
jsj_env = jsj_enter_js(jEnv, mJavaClient, NULL, &cx, NULL, &saved_state, principalsArray, numPrincipals, securitySupports);
|
||||
if (!jsj_env)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
AutoPushJSContext autopush(cx);
|
||||
|
||||
err_msg = NULL;
|
||||
java_obj = NULL;
|
||||
js_obj = JSJ_callbacks->map_java_object_to_js_object(jEnv, java_applet_obj, &err_msg);
|
||||
js_obj = JSJ_callbacks->map_java_object_to_js_object(jEnv, mJavaClient, &err_msg);
|
||||
if (!js_obj) {
|
||||
if (err_msg) {
|
||||
JS_ReportError(cx, err_msg);
|
||||
@@ -582,7 +583,6 @@ nsCLiveconnect::GetWindow(JNIEnv *jEnv, void *java_applet_obj, void* principals
|
||||
goto done;
|
||||
}
|
||||
#ifdef PRESERVE_JSOBJECT_IDENTITY
|
||||
//*pjobj = java_obj;
|
||||
*pobj = (jint)js_obj;
|
||||
#else
|
||||
/* FIXME: to handle PRESERVE_JSOBJECT_IDENTITY case, this needs to
|
||||
@@ -646,7 +646,7 @@ nsCLiveconnect::ToString(JNIEnv *jEnv, jsobject obj, jstring *pjstring)
|
||||
jstring result = NULL;
|
||||
JSString *jsstr = NULL;
|
||||
|
||||
jsj_env = jsj_enter_js(jEnv, NULL, NULL, &cx, NULL, &saved_state, NULL, 0, NULL );
|
||||
jsj_env = jsj_enter_js(jEnv, mJavaClient, NULL, &cx, NULL, &saved_state, NULL, 0, NULL );
|
||||
if (!jsj_env)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -670,6 +670,7 @@ nsCLiveconnect::ToString(JNIEnv *jEnv, jsobject obj, jstring *pjstring)
|
||||
// from nsCLiveconnect:
|
||||
|
||||
nsCLiveconnect::nsCLiveconnect(nsISupports *aOuter)
|
||||
: mJavaClient(NULL)
|
||||
{
|
||||
NS_INIT_AGGREGATED(aOuter);
|
||||
#ifdef PRESERVE_JSOBJECT_IDENTITY
|
||||
@@ -680,4 +681,3 @@ nsCLiveconnect::nsCLiveconnect(nsISupports *aOuter)
|
||||
nsCLiveconnect::~nsCLiveconnect()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetMember(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize length, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj);
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj);
|
||||
|
||||
/**
|
||||
* get member of a Native JSObject for a given index.
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetSlot(JNIEnv *jEnv, jsobject obj, jint slot, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj);
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj);
|
||||
|
||||
/**
|
||||
* set member of a Native JSObject for a given name.
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
SetMember(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize length, jobject jobj, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext);
|
||||
int numPrincipals, nsISupports *securitySupports);
|
||||
|
||||
/**
|
||||
* set member of a Native JSObject for a given index.
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
SetSlot(JNIEnv *jEnv, jsobject obj, jint slot, jobject jobj, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext);
|
||||
int numPrincipals, nsISupports *securitySupports);
|
||||
|
||||
/**
|
||||
* remove member of a Native JSObject for a given name.
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
RemoveMember(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize length, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext);
|
||||
int numPrincipals, nsISupports *securitySupports);
|
||||
|
||||
/**
|
||||
* call a method of Native JSObject.
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Call(JNIEnv *jEnv, jsobject obj, const jchar *name, jsize length, jobjectArray jobjArr, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj);
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj);
|
||||
|
||||
/**
|
||||
* Evaluate a script with a Native JS Object representing scope.
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Eval(JNIEnv *jEnv, jsobject obj, const jchar *script, jsize length, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj);
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj);
|
||||
|
||||
/**
|
||||
* Get the window object for a plugin instance.
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetWindow(JNIEnv *jEnv, void *pJavaObject, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jsobject *pobj);
|
||||
int numPrincipals, nsISupports *securitySupports, jsobject *pobj);
|
||||
|
||||
/**
|
||||
* Get the window object for a plugin instance.
|
||||
@@ -186,6 +186,7 @@ public:
|
||||
virtual ~nsCLiveconnect(void);
|
||||
|
||||
protected:
|
||||
void* mJavaClient;
|
||||
};
|
||||
|
||||
#endif // nsCLiveconnect_h___
|
||||
|
||||
@@ -81,6 +81,17 @@ NSCanUnload(nsISupports* serviceMgr)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
JSJ_RegisterLiveConnectFactory()
|
||||
{
|
||||
nsCOMPtr<nsIFactory> factory = new nsCLiveconnectFactory;
|
||||
if (factory != NULL) {
|
||||
return nsComponentManager::RegisterFactory(kCLiveconnectCID, "LiveConnect",
|
||||
"@mozilla.org/liveconnect/liveconnect;1",
|
||||
factory, PR_TRUE);
|
||||
}
|
||||
return NS_ERROR_FACTORY_NOT_LOADED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsISupports
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetMember(JNIEnv *jEnv, jsobject jsobj, const jchar *name, jsize length, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj) = 0;
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj) = 0;
|
||||
|
||||
/**
|
||||
* get member of a Native JSObject for a given index.
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetSlot(JNIEnv *jEnv, jsobject jsobj, jint slot, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj) = 0;
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj) = 0;
|
||||
|
||||
/**
|
||||
* set member of a Native JSObject for a given name.
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
SetMember(JNIEnv *jEnv, jsobject jsobj, const jchar* name, jsize length, jobject jobj, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext) = 0;
|
||||
int numPrincipals, nsISupports *securitySupports) = 0;
|
||||
|
||||
/**
|
||||
* set member of a Native JSObject for a given index.
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
SetSlot(JNIEnv *jEnv, jsobject jsobj, jint slot, jobject jobj, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext) = 0;
|
||||
int numPrincipals, nsISupports *securitySupports) = 0;
|
||||
|
||||
/**
|
||||
* remove member of a Native JSObject for a given name.
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
RemoveMember(JNIEnv *jEnv, jsobject jsobj, const jchar* name, jsize length, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext) = 0;
|
||||
int numPrincipals, nsISupports *securitySupports) = 0;
|
||||
|
||||
/**
|
||||
* call a method of Native JSObject.
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Call(JNIEnv *jEnv, jsobject jsobj, const jchar* name, jsize length, jobjectArray jobjArr, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj) = 0;
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj) = 0;
|
||||
|
||||
/**
|
||||
* Evaluate a script with a Native JS Object representing scope.
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Eval(JNIEnv *jEnv, jsobject obj, const jchar *script, jsize length, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jobject *pjobj) = 0;
|
||||
int numPrincipals, nsISupports *securitySupports, jobject *pjobj) = 0;
|
||||
|
||||
/**
|
||||
* Get the window object for a plugin instance.
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetWindow(JNIEnv *jEnv, void *pJavaObject, void* principalsArray[],
|
||||
int numPrincipals, void *pNSISecurityContext, jsobject *pobj) = 0;
|
||||
int numPrincipals, nsISupports *securitySupports, jsobject *pobj) = 0;
|
||||
|
||||
/**
|
||||
* Get the window object for a plugin instance.
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
extern "C" int XP_PROGRESS_STARTING_JAVA;
|
||||
extern "C" int XP_PROGRESS_STARTING_JAVA_DONE;
|
||||
@@ -317,16 +319,36 @@ ConvertNSIPrincipalArrayToObject(JNIEnv *pJNIEnv, JSContext *pJSContext, void *
|
||||
static JSPrincipals* PR_CALLBACK
|
||||
get_JSPrincipals_from_java_caller_impl(JNIEnv *pJNIEnv, JSContext *pJSContext, void **ppNSIPrincipalArrayIN, int numPrincipals, void *pNSISecurityContext)
|
||||
{
|
||||
#if 0
|
||||
// TODO: FIX lm_taint.c to receive nsIPrincipals. Get help from Tom Pixley.
|
||||
void *pNSIPrincipalArrayObject = ConvertNSIPrincipalArrayToObject(pJNIEnv, pJSContext, ppNSIPrincipalArrayIN, numPrincipals, pNSISecurityContext);
|
||||
if (pNSIPrincipalArrayObject != NULL)
|
||||
{
|
||||
return LM_GetJSPrincipalsFromJavaCaller(pJSContext, pNSIPrincipalArrayObject, pNSISecurityContext);
|
||||
nsISupports* credentials = (nsISupports*) pNSISecurityContext;
|
||||
nsCOMPtr<nsISecurityContext> securityContext = do_QueryInterface(credentials);
|
||||
if (securityContext) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptSecurityManager> ssm = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
char codebase[512];
|
||||
rv = securityContext->GetOrigin(codebase, sizeof(codebase) - 1);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIURI> codebaseURI;
|
||||
rv = NS_NewURI(getter_AddRefs(codebaseURI), codebase);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
rv = ssm->GetCodebasePrincipal(codebaseURI, getter_AddRefs(principal));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
JSPrincipals* jsprincipals;
|
||||
principal->GetJSPrincipals(&jsprincipals);
|
||||
return jsprincipals;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(credentials);
|
||||
if (principal) {
|
||||
JSPrincipals* jsprincipals;
|
||||
principal->GetJSPrincipals(&jsprincipals);
|
||||
return jsprincipals;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// PR_ASSERT(PR_FALSE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -765,9 +765,7 @@ nsJVMManager::GetJVMStatus(void)
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#define JSJDLL "LiveConnect"
|
||||
#endif
|
||||
extern "C" nsresult JSJ_RegisterLiveConnectFactory(void);
|
||||
|
||||
PRBool
|
||||
nsJVMManager::MaybeStartupLiveConnect(void)
|
||||
@@ -776,18 +774,7 @@ nsJVMManager::MaybeStartupLiveConnect(void)
|
||||
return PR_TRUE;
|
||||
|
||||
do {
|
||||
#if 0
|
||||
// beard: this code is no longer necessary under Seamonkey, the
|
||||
// factory is already registered up front or automatically.
|
||||
static PRBool registeredLiveConnectFactory = PR_FALSE;
|
||||
if (!registeredLiveConnectFactory) {
|
||||
NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID);
|
||||
registeredLiveConnectFactory =
|
||||
(nsComponentManager::RegisterComponent(kCLiveconnectCID, NULL, NULL,
|
||||
(const char *)JSJDLL, PR_FALSE,
|
||||
PR_FALSE) == NS_OK);
|
||||
}
|
||||
#endif
|
||||
static PRBool registeredLiveConnectFactory = NS_SUCCEEDED(JSJ_RegisterLiveConnectFactory());
|
||||
if (IsLiveConnectEnabled() && StartupJVM() == nsJVMStatus_Running) {
|
||||
JVM_InitLCGlue();
|
||||
nsIJVMPlugin* plugin = GetJVMPlugin();
|
||||
|
||||
Reference in New Issue
Block a user