зеркало из https://github.com/mozilla/pjs.git
Reimplement the Components.[ID,Exception,Constructor] properties in C++. These
things were completely unusable due to security restriction in anything besides xpcshell. This fixes bug 26879 and helps a lot for bug 8700 because is reduces the work done for JSContext creation. Also, ease the burden of xptcall porters by doing IS_COMPONENT for all unix platforms. r=mccabe
This commit is contained in:
Родитель
d49fa56f57
Коммит
047f41715b
|
@ -65,7 +65,7 @@ interface nsIXPCSecurityManager : nsISupports
|
|||
|
||||
/**
|
||||
* For each of these hooks returning NS_OK means 'let the action continue'.
|
||||
* returning *anything* else means 'veto the action'. XPConnect will do its
|
||||
* Returning an error code means 'veto the action'. XPConnect will do its
|
||||
* best to fail silently if the action is vetoed. The implementor of this
|
||||
* interface is responsible for setting a JS exception into the JSContext
|
||||
* if that is appropriate.
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
#define NS_ERROR_XPC_CANT_ADD_PROP_TO_WRAPPED_NATIVE GENERATE_XPC_FAILURE(46)
|
||||
#define NS_ERROR_XPC_CALL_TO_SCRIPTABLE_FAILED GENERATE_XPC_FAILURE(47)
|
||||
#define NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED GENERATE_XPC_FAILURE(48)
|
||||
#define NS_ERROR_XPC_BAD_ID_STRING GENERATE_XPC_FAILURE(49)
|
||||
#define NS_ERROR_XPC_BAD_INITIALIZER_NAME GENERATE_XPC_FAILURE(50)
|
||||
|
||||
// any new errors here should have an associated entry added in xpc.msg
|
||||
/***************************************************************************/
|
||||
|
|
|
@ -35,41 +35,101 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
#include "xpcexception.idl"
|
||||
#include "xpcjsid.idl"
|
||||
#include "nsIComponentManager.idl"
|
||||
|
||||
/**
|
||||
* interface of Components.interfaces
|
||||
* (interesting stuff only reflected into JavaScript)
|
||||
*/
|
||||
[scriptable, uuid(4b62a640-d26c-11d2-9842-006008962422)]
|
||||
interface nsIXPCInterfaces : nsISupports
|
||||
interface nsIXPCComponents_Interfaces : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* interface of Components.classes
|
||||
* (interesting stuff only reflected into JavaScript)
|
||||
*/
|
||||
[scriptable, uuid(978ff520-d26c-11d2-9842-006008962422)]
|
||||
interface nsIXPCClasses : nsISupports
|
||||
interface nsIXPCComponents_Classes : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* interface of Components.classesByID
|
||||
* (interesting stuff only reflected into JavaScript)
|
||||
*/
|
||||
[scriptable, uuid(336a9590-4d19-11d3-9893-006008962422)]
|
||||
interface nsIXPCClassesByID : nsISupports
|
||||
interface nsIXPCComponents_ClassesByID : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* interface of Components.results
|
||||
* (interesting stuff only reflected into JavaScript)
|
||||
*/
|
||||
[scriptable, uuid(2fc229a0-5860-11d3-9899-006008962422)]
|
||||
interface nsIXPCResults : nsISupports
|
||||
interface nsIXPCComponents_Results : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* interface of Components.ID
|
||||
* (interesting stuff only reflected into JavaScript)
|
||||
*/
|
||||
[scriptable, uuid(7994a6e0-e028-11d3-8f5d-0010a4e73d9a)]
|
||||
interface nsIXPCComponents_ID : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* interface of Components.Exception
|
||||
* (interesting stuff only reflected into JavaScript)
|
||||
*/
|
||||
[scriptable, uuid(5bf039c0-e028-11d3-8f5d-0010a4e73d9a)]
|
||||
interface nsIXPCComponents_Exception : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* interface of Components.Constructor
|
||||
* (interesting stuff only reflected into JavaScript)
|
||||
*/
|
||||
[scriptable, uuid(88655640-e028-11d3-8f5d-0010a4e73d9a)]
|
||||
interface nsIXPCComponents_Constructor : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* interface of object returned by Components.Constructor
|
||||
* (additional interesting stuff only reflected into JavaScript)
|
||||
*/
|
||||
[scriptable, uuid(c814ca20-e0dc-11d3-8f5f-0010a4e73d9a)]
|
||||
interface nsIXPCConstructor : nsISupports
|
||||
{
|
||||
readonly attribute nsIJSCID classID;
|
||||
readonly attribute nsIJSIID interfaceID;
|
||||
readonly attribute string initializer;
|
||||
};
|
||||
|
||||
/**
|
||||
* interface of JavaScript's 'Components' object
|
||||
*/
|
||||
[scriptable, uuid(42624f80-d26c-11d2-9842-006008962422)]
|
||||
interface nsIXPCComponents : nsISupports
|
||||
{
|
||||
readonly attribute nsIXPCInterfaces interfaces;
|
||||
readonly attribute nsIXPCClasses classes;
|
||||
readonly attribute nsIXPCClassesByID classesByID;
|
||||
readonly attribute nsIJSStackFrameLocation stack;
|
||||
readonly attribute nsIXPCResults results;
|
||||
readonly attribute nsIComponentManager manager;
|
||||
readonly attribute nsIXPCComponents_Interfaces interfaces;
|
||||
readonly attribute nsIXPCComponents_Classes classes;
|
||||
readonly attribute nsIXPCComponents_ClassesByID classesByID;
|
||||
readonly attribute nsIJSStackFrameLocation stack;
|
||||
readonly attribute nsIXPCComponents_Results results;
|
||||
readonly attribute nsIComponentManager manager;
|
||||
|
||||
readonly attribute nsIXPCComponents_ID ID;
|
||||
readonly attribute nsIXPCComponents_Exception Exception;
|
||||
readonly attribute nsIXPCComponents_Constructor Constructor;
|
||||
|
||||
/* 'lastResult' is accessable via JavaScript only */
|
||||
/* 'returnCode' is accessable via JavaScript only */
|
||||
/* 'Exception' is accessable via JavaScript only */
|
||||
/* 'ID' is accessable via JavaScript only */
|
||||
|
||||
};
|
||||
|
|
|
@ -70,100 +70,7 @@ CPPSRCS = \
|
|||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
# XXX hackage!
|
||||
# only copy the .so to components dir on platforms where xptcall is supported
|
||||
|
||||
# Unixish x86
|
||||
ifneq (,$(filter SunOS Linux FreeBSD NetBSD BSD_OS,$(OS_ARCH)))
|
||||
ifeq (86,$(findstring 86,$(OS_TEST)))
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Neutrino Cross-Compiled for x86
|
||||
ifneq (,$(filter NTO,$(OS_TARGET)))
|
||||
ifeq (86,$(findstring 86,$(OS_TEST)))
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Solaris/sparc
|
||||
ifeq ($(OS_ARCH),SunOS)
|
||||
ifneq (86,$(findstring 86,$(OS_TEST)))
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Linux/sparc
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
ifeq ($(OS_TEST),sparc)
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Linux/alpha
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
ifeq ($(OS_TEST),alpha)
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Linux/PPC
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
ifeq ($(OS_TEST),ppc)
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# NetBSD/m68k
|
||||
ifeq ($(OS_ARCH),NetBSD)
|
||||
ifneq (,$(filter amiga atari hp300 mac68k mvme68k next68k sun3 sun3x x68k,$(OS_TEST)))
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# BeOS/Intel
|
||||
ifeq ($(OS_ARCH),BeOS)
|
||||
ifeq ($(OS_TEST),BePC)
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# HPUX
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
ifneq ($(CC),gcc)
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# AIX
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
|
||||
# IRIX
|
||||
ifeq ($(OS_ARCH),IRIX)
|
||||
ifneq ($(basename $(OS_RELEASE)),5)
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# OpenVMS (Alpha only at this point)
|
||||
ifeq ($(OS_ARCH),OpenVMS)
|
||||
ifeq ($(CPU_ARCH),Alpha)
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Linux or NetBSD ARM
|
||||
ifneq (,$(filter Linux NetBSD,$(OS_ARCH)))
|
||||
ifeq (arm,$(findstring arm,$(OS_TEST)))
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
ifeq (sa110,$(findstring sa110,$(OS_TEST)))
|
||||
IS_COMPONENT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# this is automatically discovered under BeOS
|
||||
ifneq ($(OS_ARCH),BeOS)
|
||||
|
|
|
@ -86,6 +86,8 @@ XPC_MSG_DEF(NS_ERROR_XPC_CANT_SET_READ_ONLY_METHOD , "Property is an interf
|
|||
XPC_MSG_DEF(NS_ERROR_XPC_CANT_ADD_PROP_TO_WRAPPED_NATIVE, "Can not add property to WrappedNative object")
|
||||
XPC_MSG_DEF(NS_ERROR_XPC_CALL_TO_SCRIPTABLE_FAILED , "Call to nsIXPCScriptable interface for WrappedNative failed unexpecedly")
|
||||
XPC_MSG_DEF(NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED , "JavaScript component does not have a method named:")
|
||||
XPC_MSG_DEF(NS_ERROR_XPC_BAD_ID_STRING , "Bad ID string")
|
||||
XPC_MSG_DEF(NS_ERROR_XPC_BAD_INITIALIZER_NAME , "Bad initializer name in Constructor - Component has no method with that name")
|
||||
|
||||
/* common global codes (from nsError.h) */
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -58,10 +58,14 @@ class XPCJSThrower;
|
|||
class XPCJSStack;
|
||||
class XPCNativeMemberDescriptor;
|
||||
|
||||
class nsXPCInterfaces;
|
||||
class nsXPCClasses;
|
||||
class nsXPCClassesByID;
|
||||
class nsXPCResults;
|
||||
|
||||
class nsXPCComponents;
|
||||
class nsXPCComponents_Interfaces;
|
||||
class nsXPCComponents_Classes;
|
||||
class nsXPCComponents_ClassesByID;
|
||||
class nsXPCComponents_Results;
|
||||
class nsXPCComponents_ID;
|
||||
class nsXPCComponents_Exception;
|
||||
class nsXPCComponents_Constructor;
|
||||
class nsXPCConstructor;
|
||||
|
||||
#endif /* xpcforwards_h___ */
|
||||
|
|
|
@ -536,6 +536,9 @@ public:
|
|||
Native2WrappedNativeMap*
|
||||
GetWrappedNativeMap() const {return mWrappedNativeMap;}
|
||||
|
||||
nsXPCComponents*
|
||||
GetComponents() const {return mComponents;}
|
||||
|
||||
static nsXPCWrappedNativeScope*
|
||||
FindInJSObjectScope(XPCContext* xpcc, JSObject* obj);
|
||||
|
||||
|
@ -544,7 +547,7 @@ public:
|
|||
|
||||
JSBool IsValid() const {return mRuntime != nsnull;}
|
||||
|
||||
nsXPCWrappedNativeScope(XPCContext* xpcc);
|
||||
nsXPCWrappedNativeScope(XPCContext* xpcc, nsXPCComponents* comp);
|
||||
virtual ~nsXPCWrappedNativeScope();
|
||||
private:
|
||||
nsXPCWrappedNativeScope(); // not implemented
|
||||
|
@ -554,6 +557,7 @@ private:
|
|||
|
||||
XPCJSRuntime* mRuntime;
|
||||
Native2WrappedNativeMap* mWrappedNativeMap;
|
||||
nsXPCComponents* mComponents;
|
||||
nsXPCWrappedNativeScope* mNext;
|
||||
};
|
||||
|
||||
|
@ -1155,7 +1159,8 @@ private:
|
|||
class nsXPCException : public nsIXPCException
|
||||
{
|
||||
public:
|
||||
// all the interface method declarations...
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_XPCEXCEPTION_CID)
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIXPCEXCEPTION
|
||||
|
||||
|
@ -1227,6 +1232,8 @@ extern JSBool xpc_InitWrappedNativeJSOps();
|
|||
class nsJSID : public nsIJSID
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_JS_ID_CID)
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIJSID
|
||||
|
||||
|
@ -1371,11 +1378,14 @@ private:
|
|||
nsXPCComponents();
|
||||
|
||||
private:
|
||||
nsXPCInterfaces* mInterfaces;
|
||||
nsXPCClasses* mClasses;
|
||||
nsXPCClassesByID* mClassesByID;
|
||||
nsXPCResults* mResults;
|
||||
PRBool mCreating;
|
||||
nsXPCComponents_Interfaces* mInterfaces;
|
||||
nsXPCComponents_Classes* mClasses;
|
||||
nsXPCComponents_ClassesByID* mClassesByID;
|
||||
nsXPCComponents_Results* mResults;
|
||||
nsXPCComponents_ID* mID;
|
||||
nsXPCComponents_Exception* mException;
|
||||
nsXPCComponents_Constructor* mConstructor;
|
||||
PRBool mCreating;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
|
@ -41,13 +41,15 @@ nsXPCWrappedNativeScope* nsXPCWrappedNativeScope::gScopes = nsnull;
|
|||
|
||||
NS_IMPL_ISUPPORTS1(nsXPCWrappedNativeScope, nsIXPCWrappedNativeScope)
|
||||
|
||||
nsXPCWrappedNativeScope::nsXPCWrappedNativeScope(XPCContext* xpcc)
|
||||
nsXPCWrappedNativeScope::nsXPCWrappedNativeScope(XPCContext* xpcc,
|
||||
nsXPCComponents* comp)
|
||||
: mRuntime(xpcc->GetRuntime()),
|
||||
mWrappedNativeMap(Native2WrappedNativeMap::newMap(XPC_NATIVE_MAP_SIZE)),
|
||||
mComponents(comp),
|
||||
mNext(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
NS_IF_ADDREF(mComponents);
|
||||
// add ourselves to the scopes list
|
||||
{ // scoped lock
|
||||
nsAutoLock lock(mRuntime->GetMapLock());
|
||||
|
@ -83,6 +85,7 @@ nsXPCWrappedNativeScope::~nsXPCWrappedNativeScope()
|
|||
}
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(mComponents);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
Загрузка…
Ссылка в новой задаче