1999-08-20 13:51:02 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1999-08-20 13:51:02 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-08-20 13:51:02 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-08-20 13:51:02 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-08-20 13:51:02 +04:00
|
|
|
*/
|
|
|
|
#ifndef _NS_SCRIPT_SECURITY_MANAGER_H_
|
|
|
|
#define _NS_SCRIPT_SECURITY_MANAGER_H_
|
|
|
|
|
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "jsapi.h"
|
1999-09-07 06:54:19 +04:00
|
|
|
#include "nsIXPCSecurityManager.h"
|
1999-11-12 01:10:36 +03:00
|
|
|
#include "nsHashtable.h"
|
1999-11-20 10:28:34 +03:00
|
|
|
#include "nsDOMPropEnums.h"
|
2000-01-19 00:54:01 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-08-20 13:51:02 +04:00
|
|
|
|
2000-01-23 07:23:14 +03:00
|
|
|
class nsIPref;
|
|
|
|
|
1999-08-20 13:51:02 +04:00
|
|
|
#define NS_SCRIPTSECURITYMANAGER_CID \
|
|
|
|
{ 0x7ee2a4c0, 0x4b93, 0x17d3, \
|
|
|
|
{ 0xba, 0x18, 0x00, 0x60, 0xb0, 0xf1, 0x99, 0xa2 }}
|
|
|
|
|
1999-09-07 06:54:19 +04:00
|
|
|
class nsScriptSecurityManager : public nsIScriptSecurityManager,
|
|
|
|
public nsIXPCSecurityManager
|
|
|
|
{
|
1999-08-20 13:51:02 +04:00
|
|
|
public:
|
1999-08-30 01:58:42 +04:00
|
|
|
nsScriptSecurityManager();
|
|
|
|
virtual ~nsScriptSecurityManager();
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_CID_ACCESSOR(NS_SCRIPTSECURITYMANAGER_CID)
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISCRIPTSECURITYMANAGER
|
1999-09-07 06:54:19 +04:00
|
|
|
NS_DECL_NSIXPCSECURITYMANAGER
|
1999-08-30 01:58:42 +04:00
|
|
|
|
|
|
|
static nsScriptSecurityManager *
|
|
|
|
GetScriptSecurityManager();
|
|
|
|
|
1999-08-20 13:51:02 +04:00
|
|
|
private:
|
2000-01-19 00:54:01 +03:00
|
|
|
void
|
|
|
|
LookupPrincipal(nsCOMPtr<nsIPrincipal>* aPrincipal);
|
|
|
|
|
1999-08-30 01:58:42 +04:00
|
|
|
NS_IMETHOD
|
|
|
|
GetSubjectPrincipal(JSContext *aCx, nsIPrincipal **result);
|
|
|
|
|
|
|
|
NS_IMETHOD
|
|
|
|
GetObjectPrincipal(JSContext *aCx, JSObject *aObj, nsIPrincipal **result);
|
|
|
|
|
|
|
|
NS_IMETHOD
|
2000-02-02 03:22:58 +03:00
|
|
|
CheckPermissions(JSContext *aCx, JSObject *aObj, const char *aCapability);
|
|
|
|
|
1999-08-30 01:58:42 +04:00
|
|
|
PRInt32
|
2000-01-08 19:51:54 +03:00
|
|
|
GetSecurityLevel(nsIPrincipal *principal, nsDOMProp domProp,
|
2000-01-23 07:23:14 +03:00
|
|
|
PRBool isWrite, nsCString &capability);
|
1999-08-30 01:58:42 +04:00
|
|
|
|
1999-11-16 08:07:31 +03:00
|
|
|
NS_IMETHOD
|
2000-01-23 07:23:14 +03:00
|
|
|
GetPrefName(nsIPrincipal *principal, nsDOMProp domProp,
|
|
|
|
nsCString &result);
|
1999-09-01 04:54:35 +04:00
|
|
|
|
1999-09-07 06:54:19 +04:00
|
|
|
NS_IMETHOD
|
|
|
|
CheckXPCPermissions(JSContext *cx);
|
|
|
|
|
1999-11-12 01:10:36 +03:00
|
|
|
NS_IMETHOD
|
|
|
|
InitFromPrefs();
|
1999-08-30 01:58:42 +04:00
|
|
|
|
1999-11-25 08:28:18 +03:00
|
|
|
static void
|
|
|
|
enumeratePolicyCallback(const char *prefName, void *data);
|
|
|
|
|
2000-01-19 00:54:01 +03:00
|
|
|
static void
|
|
|
|
enumeratePrincipalsCallback(const char *prefName, void *data);
|
|
|
|
|
2000-01-06 03:59:18 +03:00
|
|
|
static int
|
|
|
|
JSEnabledPrefChanged(const char *pref, void *data);
|
|
|
|
|
2000-01-23 07:23:14 +03:00
|
|
|
nsObjectHashtable *mOriginToPolicyMap;
|
|
|
|
nsIPref *mPrefs;
|
1999-11-12 01:10:36 +03:00
|
|
|
nsIPrincipal *mSystemPrincipal;
|
|
|
|
nsSupportsHashtable *mPrincipals;
|
2000-01-06 03:59:18 +03:00
|
|
|
PRBool mIsJavaScriptEnabled;
|
2000-01-08 19:51:54 +03:00
|
|
|
PRBool mIsMailJavaScriptEnabled;
|
1999-11-25 08:28:18 +03:00
|
|
|
unsigned char hasPolicyVector[(NS_DOM_PROP_MAX >> 3) + 1];
|
|
|
|
unsigned char hasDomainPolicyVector[(NS_DOM_PROP_MAX >> 3) + 1];
|
1999-10-29 02:09:03 +04:00
|
|
|
};
|
|
|
|
|
1999-08-20 13:51:02 +04:00
|
|
|
#endif /*_NS_SCRIPT_SECURITY_MANAGER_H_*/
|