Added UpdatePrincipal function to support multiple signed scripts in a document. r=norris

This commit is contained in:
norris%netscape.com 2000-03-21 04:09:58 +00:00
Родитель c8d341bf6a
Коммит 9bc42a40c5
6 изменённых файлов: 80 добавлений и 0 удалений

Просмотреть файл

@ -121,6 +121,12 @@ public:
*/
NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal) = 0;
/**
* Update principal responsible for this document to the intersection
* of its previous value and aPrincipal.
*/
NS_IMETHOD UpdatePrincipal(nsIPrincipal **aPrincipal) = 0;
/**
* Return the LoadGroup for the document. May return null.
*/

Просмотреть файл

@ -84,6 +84,7 @@
#include "nsLayoutUtils.h"
#include "nsIScriptSecurityManager.h"
#include "nsIAggregatePrincipal.h"
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
@ -894,6 +895,33 @@ nsDocument::GetPrincipal(nsIPrincipal **aPrincipal)
return NS_OK;
}
NS_IMETHODIMP
nsDocument::UpdatePrincipal(nsIPrincipal **aNewPrincipal)
{
nsresult rv;
if (!mPrincipal) {
NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager,
NS_SCRIPTSECURITYMANAGER_PROGID, &rv);
if (NS_FAILED(rv))
return rv;
if (NS_FAILED(rv = securityManager->GetCodebasePrincipal(mDocumentURL,
&mPrincipal)))
return rv;
}
nsCOMPtr<nsIAggregatePrincipal> agg =
do_QueryInterface(mPrincipal, &rv);
if (NS_SUCCEEDED(rv))
{
rv = agg->Intersect(*aNewPrincipal);
if (NS_FAILED(rv)) return rv;
}
*aNewPrincipal = mPrincipal;
NS_ADDREF(*aNewPrincipal);
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetContentType(nsString& aContentType) const
{

Просмотреть файл

@ -143,6 +143,12 @@ public:
*/
NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal);
/**
* Update principal responsible for this document to the intersection
* of its previous value and aPrincipal, and return its new value.
*/
NS_IMETHOD UpdatePrincipal(nsIPrincipal **aPrincipal);
/**
* Return the content (mime) type of this document.
*/

Просмотреть файл

@ -121,6 +121,12 @@ public:
*/
NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal) = 0;
/**
* Update principal responsible for this document to the intersection
* of its previous value and aPrincipal.
*/
NS_IMETHOD UpdatePrincipal(nsIPrincipal **aPrincipal) = 0;
/**
* Return the LoadGroup for the document. May return null.
*/

Просмотреть файл

@ -84,6 +84,7 @@
#include "nsLayoutUtils.h"
#include "nsIScriptSecurityManager.h"
#include "nsIAggregatePrincipal.h"
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
@ -894,6 +895,33 @@ nsDocument::GetPrincipal(nsIPrincipal **aPrincipal)
return NS_OK;
}
NS_IMETHODIMP
nsDocument::UpdatePrincipal(nsIPrincipal **aNewPrincipal)
{
nsresult rv;
if (!mPrincipal) {
NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager,
NS_SCRIPTSECURITYMANAGER_PROGID, &rv);
if (NS_FAILED(rv))
return rv;
if (NS_FAILED(rv = securityManager->GetCodebasePrincipal(mDocumentURL,
&mPrincipal)))
return rv;
}
nsCOMPtr<nsIAggregatePrincipal> agg =
do_QueryInterface(mPrincipal, &rv);
if (NS_SUCCEEDED(rv))
{
rv = agg->Intersect(*aNewPrincipal);
if (NS_FAILED(rv)) return rv;
}
*aNewPrincipal = mPrincipal;
NS_ADDREF(*aNewPrincipal);
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetContentType(nsString& aContentType) const
{

Просмотреть файл

@ -143,6 +143,12 @@ public:
*/
NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal);
/**
* Update principal responsible for this document to the intersection
* of its previous value and aPrincipal, and return its new value.
*/
NS_IMETHOD UpdatePrincipal(nsIPrincipal **aPrincipal);
/**
* Return the content (mime) type of this document.
*/