mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 18:51:28 +00:00
Added UpdatePrincipal function to support multiple signed scripts in a document. r=norris
This commit is contained in:
parent
d655019842
commit
0ac075877f
@ -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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user