Bug 774585 - Add GetDocShellCodebasePrincipal to nsIScriptSecurityManager. r=mounir

This commit is contained in:
Jonas Sicking 2012-07-20 00:06:24 -07:00
parent 1887aa86ce
commit c10568d0b9
4 changed files with 40 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#include "nsIXPCSecurityManager.idl"
interface nsIURI;
interface nsIChannel;
interface nsIDocShell;
[scriptable, uuid(75a7afe3-d7c9-46fe-b305-ae686457bc7f)]
interface nsIScriptSecurityManager : nsIXPCSecurityManager
@ -162,6 +163,14 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager
in unsigned long appId,
in boolean inMozBrowser);
/**
* Returns a principal that has the appId and inMozBrowser of the docshell
* inside a mozbrowser frame.
* @param docShell to get appId/inMozBrowser from.
*/
nsIPrincipal getDocShellCodebasePrincipal(in nsIURI uri,
in nsIDocShell docShell);
/**
* Returns a principal with that has the same origin as uri and is not part
* of an appliction.

View File

@ -2005,6 +2005,22 @@ nsScriptSecurityManager::GetAppCodebasePrincipal(nsIURI* aURI,
return GetCodebasePrincipalInternal(aURI, aAppId, aInMozBrowser, aPrincipal);
}
NS_IMETHODIMP
nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
nsIDocShell* aDocShell,
nsIPrincipal** aPrincipal)
{
MOZ_ASSERT(aDocShell);
PRUint32 appId;
bool isInBrowserElement;
aDocShell->GetAppId(&appId);
aDocShell->GetIsInBrowserElement(&isInBrowserElement);
return GetCodebasePrincipalInternal(aURI, appId, isInBrowserElement,
aPrincipal);
}
nsresult
nsScriptSecurityManager::GetCodebasePrincipalInternal(nsIURI *aURI,
PRUint32 aAppId,

View File

@ -788,6 +788,14 @@ FullTrustSecMan::GetAppCodebasePrincipal(nsIURI *aURI,
return GetCodebasePrincipal(aURI, _retval);
}
NS_IMETHODIMP
FullTrustSecMan::GetDocShellCodebasePrincipal(nsIURI *aURI,
nsIDocShell* aDocShell,
nsIPrincipal **_retval)
{
return GetCodebasePrincipal(aURI, _retval);
}
NS_IMETHODIMP
FullTrustSecMan::RequestCapability(nsIPrincipal *principal,
const char *capability,

View File

@ -1408,6 +1408,13 @@ FullTrustSecMan::GetAppCodebasePrincipal(nsIURI *aURI, PRUint32 aAppId, bool aIn
return GetCodebasePrincipal(aURI, _retval);
}
/* [noscript] nsIPrincipal getDocShellCodebasePrincipal (in nsIURI aURI, nsIDocShell docShell); */
NS_IMETHODIMP
FullTrustSecMan::GetDocShellCodebasePrincipal(nsIURI *aURI, nsIDocShell* aDocShell, nsIPrincipal **_retval)
{
return GetCodebasePrincipal(aURI, _retval);
}
/* [noscript] short requestCapability (in nsIPrincipal principal, in string capability); */
NS_IMETHODIMP
FullTrustSecMan::RequestCapability(nsIPrincipal *principal,