Bug 997987 - Remove nsIScriptSecurityManager::GetCxSubjectPrincipal. r=Ms2ger

This commit is contained in:
Bobby Holley 2014-05-06 15:43:02 -07:00
Родитель 507c29aa81
Коммит 9c988d6c40
6 изменённых файлов: 7 добавлений и 45 удалений

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

@ -11,7 +11,7 @@ interface nsIChannel;
interface nsIDocShell;
interface nsIDomainPolicy;
[scriptable, uuid(4c087cc3-e0cc-4ec3-88df-8d68f3023b45)]
[scriptable, uuid(176f2aed-fb78-4420-b372-07ab2c4c04c3)]
interface nsIScriptSecurityManager : nsIXPCSecurityManager
{
/**
@ -193,14 +193,6 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager
}
%}
/**
* Same as getSubjectPrincipal(), only faster. cx must *never* be
* passed null, and it must be the context on the top of the
* context stack. Does *not* reference count the returned
* principal.
*/
[noscript,notxpcom] nsIPrincipal getCxSubjectPrincipal(in JSContextPtr cx);
const unsigned long NO_APP_ID = 0;
const unsigned long UNKNOWN_APP_ID = 4294967295; // UINT32_MAX
const unsigned long SAFEBROWSING_APP_ID = 4294967294; // UINT32_MAX - 1

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

@ -318,20 +318,6 @@ nsScriptSecurityManager::IsSystemPrincipal(nsIPrincipal* aPrincipal,
return NS_OK;
}
NS_IMETHODIMP_(nsIPrincipal *)
nsScriptSecurityManager::GetCxSubjectPrincipal(JSContext *cx)
{
NS_ASSERTION(cx == GetCurrentJSContext(),
"Uh, cx is not the current JS context!");
nsresult rv = NS_ERROR_FAILURE;
nsIPrincipal *principal = GetSubjectPrincipal(cx, &rv);
if (NS_FAILED(rv))
return nullptr;
return principal;
}
/////////////////////////////
// nsScriptSecurityManager //
/////////////////////////////

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

@ -6106,20 +6106,10 @@ nsContentUtils::GetContentSecurityPolicy(JSContext* aCx,
nsIContentSecurityPolicy** aCSP)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
// Get the security manager
nsCOMPtr<nsIScriptSecurityManager> ssm = nsContentUtils::GetSecurityManager();
if (!ssm) {
NS_ERROR("Failed to get security manager service");
return false;
}
nsCOMPtr<nsIPrincipal> subjectPrincipal = ssm->GetCxSubjectPrincipal(aCx);
NS_ASSERTION(subjectPrincipal, "Failed to get subjectPrincipal");
MOZ_ASSERT(aCx == GetCurrentJSContext());
nsCOMPtr<nsIContentSecurityPolicy> csp;
nsresult rv = subjectPrincipal->GetCsp(getter_AddRefs(csp));
nsresult rv = GetSubjectPrincipal()->GetCsp(getter_AddRefs(csp));
if (NS_FAILED(rv)) {
NS_ERROR("CSP: Failed to get CSP from principal.");
return false;

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

@ -160,7 +160,7 @@ nsLocation::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
}
}
owner = do_QueryInterface(ssm->GetCxSubjectPrincipal(cx));
owner = nsContentUtils::GetSubjectPrincipal();
}
// Create load info

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

@ -3717,6 +3717,7 @@ WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindow* aWindow,
using namespace mozilla::dom::workers::scriptloader;
MOZ_ASSERT(aCx);
MOZ_ASSERT_IF(NS_IsMainThread(), aCx == nsContentUtils::GetCurrentJSContext());
if (aWindow) {
AssertIsOnMainThread();
@ -3913,10 +3914,6 @@ WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindow* aWindow,
MOZ_ASSERT(loadInfo.mPrincipal);
MOZ_ASSERT(isChrome || !loadInfo.mDomain.IsEmpty());
// XXXbent Use subject principal here instead of the one we already have?
nsCOMPtr<nsIPrincipal> subjectPrincipal = ssm->GetCxSubjectPrincipal(aCx);
MOZ_ASSERT(subjectPrincipal);
if (!nsContentUtils::GetContentSecurityPolicy(aCx,
getter_AddRefs(loadInfo.mCSP))) {
NS_WARNING("Failed to get CSP!");

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

@ -203,10 +203,6 @@ CreateXMLHttpRequest(JSContext *cx, unsigned argc, jsval *vp)
if (!ssm)
return false;
nsIPrincipal *subjectPrincipal = ssm->GetCxSubjectPrincipal(cx);
if (!subjectPrincipal)
return false;
RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
MOZ_ASSERT(global);
@ -215,7 +211,8 @@ CreateXMLHttpRequest(JSContext *cx, unsigned argc, jsval *vp)
nsCOMPtr<nsIGlobalObject> iglobal = do_QueryInterface(sop);
nsCOMPtr<nsIXMLHttpRequest> xhr = new nsXMLHttpRequest();
nsresult rv = xhr->Init(subjectPrincipal, nullptr, iglobal, nullptr);
nsresult rv = xhr->Init(nsContentUtils::GetSubjectPrincipal(), nullptr,
iglobal, nullptr);
if (NS_FAILED(rv))
return false;