зеркало из https://github.com/mozilla/gecko-dev.git
Adding initial bit for the JS security system
This commit is contained in:
Родитель
326a6e59f2
Коммит
ec365a7a8c
|
@ -24,4 +24,5 @@ nsIScriptGlobalObject.h
|
|||
nsIScriptEventListener.h
|
||||
nsIDOMScriptObjectFactory.h
|
||||
nsIDOMNativeObjectRegistry.h
|
||||
nsDOMCID.h
|
||||
nsDOMCID.h
|
||||
nsIScriptSecurityManager.h
|
|
@ -31,6 +31,7 @@ EXPORTS = \
|
|||
nsIDOMScriptObjectFactory.h \
|
||||
nsIDOMNativeObjectRegistry.h \
|
||||
nsDOMCID.h \
|
||||
nsIScriptSecurityManager.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = dom
|
||||
|
|
|
@ -36,6 +36,7 @@ EXPORTS = \
|
|||
nsIDOMScriptObjectFactory.h \
|
||||
nsIDOMNativeObjectRegistry.h \
|
||||
nsDOMCID.h \
|
||||
nsIScriptSecurityManager.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
|
|
@ -23,7 +23,7 @@ DEFINES=-D_IMPL_NS_DOM
|
|||
EXPORTS=nsIScriptContext.h nsIJSScriptObject.h nsIScriptObjectOwner.h \
|
||||
nsIScriptGlobalObject.h nsIScriptContextOwner.h \
|
||||
nsIScriptEventListener.h nsIDOMScriptObjectFactory.h \
|
||||
nsIDOMNativeObjectRegistry.h nsDOMCID.h
|
||||
nsIDOMNativeObjectRegistry.h nsDOMCID.h nsIScriptSecurityManager.h
|
||||
|
||||
MODULE=dom
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "jsapi.h"
|
||||
|
||||
class nsIScriptGlobalObject;
|
||||
class nsIScriptSecurityManager;
|
||||
|
||||
#define NS_ISCRIPTCONTEXT_IID \
|
||||
{ /* 8f6bca7d-ce42-11d1-b724-00600891d8c9 */ \
|
||||
|
@ -115,6 +116,12 @@ public:
|
|||
* @return NS_OK if the method is successful
|
||||
*/
|
||||
virtual nsresult GC() = 0;
|
||||
|
||||
/**
|
||||
* Get the security manager for this context.
|
||||
* @return NS_OK if the method is successful
|
||||
*/
|
||||
NS_IMETHOD GetSecurityManager(nsIScriptSecurityManager** aInstancePtr) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIScriptSecurityManager_h__
|
||||
#define nsIScriptSecurityManager_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
|
||||
/*
|
||||
* Event listener interface.
|
||||
*/
|
||||
|
||||
#define NS_ISCRIPTSECURITYMANAGER_IID \
|
||||
{ /* 58df5780-8006-11d2-bd91-00805f8ae3f4 */ \
|
||||
0x58df5780, 0x8006, 0x11d2, \
|
||||
{0xbd, 0x91, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
|
||||
|
||||
class nsIScriptSecurityManager : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Checks script access to the property/method in question
|
||||
*/
|
||||
|
||||
NS_IMETHOD CheckScriptAccess(nsIScriptContext* aContext, PRBool* aResult) = 0;
|
||||
|
||||
};
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptSecurityManager(nsIScriptSecurityManager ** aInstancePtrResult);
|
||||
|
||||
#endif // nsIScriptSecurityManager_h__
|
|
@ -34,6 +34,7 @@ CPPSRCS = \
|
|||
nsGlobalWindow.cpp \
|
||||
nsLocation.cpp \
|
||||
nsFrameList.cpp \
|
||||
nsJSSecurityManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
|
|
@ -39,6 +39,7 @@ CPPSRCS = \
|
|||
nsGlobalWindow.cpp \
|
||||
nsLocation.cpp \
|
||||
nsFrameList.cpp \
|
||||
nsJSSecurityManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
|
|
@ -31,6 +31,7 @@ CPPSRCS = \
|
|||
nsGlobalWindow.cpp \
|
||||
nsLocation.cpp \
|
||||
nsFrameList.cpp \
|
||||
nsJSSecurityManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
@ -46,6 +47,7 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsJSLocation.obj \
|
||||
.\$(OBJDIR)\nsFrameList.obj \
|
||||
.\$(OBJDIR)\nsJSWindowCollection.obj \
|
||||
.\$(OBJDIR)\nsJSSecurityManager.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor \
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
|
||||
const uint32 gGCSize = 4L * 1024L * 1024L;
|
||||
const size_t gStackSize = 8192;
|
||||
|
@ -181,6 +182,12 @@ nsJSContext::GC()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJSContext::GetSecurityManager(nsIScriptSecurityManager** aInstancePtr)
|
||||
{
|
||||
return NS_NewScriptSecurityManager(aInstancePtr);
|
||||
}
|
||||
|
||||
nsJSEnvironment *nsJSEnvironment::sTheEnvironment = nsnull;
|
||||
|
||||
// Class to manage destruction of the singleton
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define nsJSEnvironment_h___
|
||||
|
||||
#include "nsIScriptContext.h"
|
||||
class nsIScriptSecurityManager;
|
||||
|
||||
class nsJSContext : public nsIScriptContext {
|
||||
private:
|
||||
|
@ -42,6 +43,7 @@ public:
|
|||
const char *aName);
|
||||
virtual nsresult RemoveReference(void *aSlot, void *aScriptObject);
|
||||
virtual nsresult GC();
|
||||
NS_IMETHOD GetSecurityManager(nsIScriptSecurityManager** aInstancePtr);
|
||||
};
|
||||
|
||||
class nsJSEnvironment {
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsJSSecurityManager.h"
|
||||
|
||||
static NS_DEFINE_IID(kIScriptSecurityManagerIID, NS_ISCRIPTSECURITYMANAGER_IID);
|
||||
|
||||
nsJSSecurityManager::nsJSSecurityManager()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsJSSecurityManager::~nsJSSecurityManager()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsJSSecurityManager, kIScriptSecurityManagerIID)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJSSecurityManager::CheckScriptAccess(nsIScriptContext* aContext, PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptSecurityManager(nsIScriptSecurityManager ** aInstancePtrResult)
|
||||
{
|
||||
nsIScriptSecurityManager* it = new nsJSSecurityManager();
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIScriptSecurityManagerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsJSSecurityManager_h___
|
||||
#define nsJSSecurityManager_h___
|
||||
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsJSSecurityManager : public nsIScriptSecurityManager {
|
||||
public:
|
||||
nsJSSecurityManager();
|
||||
~nsJSSecurityManager();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CheckScriptAccess(nsIScriptContext* aContext, PRBool* aResult);
|
||||
};
|
||||
|
||||
#endif /* nsJSSecurityManager_h___ */
|
Загрузка…
Ссылка в новой задаче