2003-10-22 02:11:49 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-08-20 13:51:02 +04:00
|
|
|
/* describes principals by their orginating uris*/
|
2003-10-22 02:11:49 +04:00
|
|
|
|
|
|
|
#ifndef nsJSPrincipals_h__
|
|
|
|
#define nsJSPrincipals_h__
|
1999-08-20 13:51:02 +04:00
|
|
|
#include "jsapi.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
|
2015-05-11 23:16:36 +03:00
|
|
|
class nsJSPrincipals : public nsIPrincipal, public JSPrincipals
|
2003-10-22 02:11:49 +04:00
|
|
|
{
|
2015-05-11 23:16:36 +03:00
|
|
|
public:
|
|
|
|
/* SpiderMonkey security callbacks. */
|
2013-08-09 02:53:04 +04:00
|
|
|
static bool Subsume(JSPrincipals *jsprin, JSPrincipals *other);
|
2012-03-09 13:48:50 +04:00
|
|
|
static void Destroy(JSPrincipals *jsprin);
|
1999-08-20 13:51:02 +04:00
|
|
|
|
2012-03-09 13:48:50 +04:00
|
|
|
/*
|
|
|
|
* Get a weak reference to nsIPrincipal associated with the given JS
|
2015-05-11 23:16:36 +03:00
|
|
|
* principal, and vice-versa.
|
2012-03-09 13:48:50 +04:00
|
|
|
*/
|
|
|
|
static nsJSPrincipals* get(JSPrincipals *principals) {
|
|
|
|
nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principals);
|
|
|
|
MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
static nsJSPrincipals* get(nsIPrincipal *principal) {
|
|
|
|
nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principal);
|
|
|
|
MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2015-05-11 23:16:36 +03:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override;
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release(void) override;
|
|
|
|
|
2012-03-09 13:48:50 +04:00
|
|
|
nsJSPrincipals() {
|
|
|
|
refcount = 0;
|
|
|
|
setDebugToken(DEBUG_TOKEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a string that can be used as JS script filename in error reports.
|
|
|
|
*/
|
|
|
|
virtual void GetScriptLocation(nsACString &aStr) = 0;
|
|
|
|
static const uint32_t DEBUG_TOKEN = 0x0bf41760;
|
2015-05-11 23:16:36 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsJSPrincipals() {
|
|
|
|
setDebugToken(0);
|
|
|
|
}
|
|
|
|
|
1999-08-20 13:51:02 +04:00
|
|
|
};
|
|
|
|
|
2003-10-22 02:11:49 +04:00
|
|
|
#endif /* nsJSPrincipals_h__ */
|