Attachment #630200: Part 3 - Pull subject principals directly off the compartment. v2 for bug #754202

View | Details | Raw Unified | Return to bug 754202
Collapse All | Expand All

(-)a/caps/src/nsScriptSecurityManager.cpp (-3 / +10 lines)
Line     Link Here 
 Lines 2359-2377   nsScriptSecurityManager::GetPrincipalAndFrame(JSContext *cx, Link Here 
2359
2359
2360
    return nsnull;
2360
    return nsnull;
2361
}
2361
}
2362
2362
2363
nsIPrincipal*
2363
nsIPrincipal*
2364
nsScriptSecurityManager::GetSubjectPrincipal(JSContext *cx,
2364
nsScriptSecurityManager::GetSubjectPrincipal(JSContext *cx,
2365
                                             nsresult* rv)
2365
                                             nsresult* rv)
2366
{
2366
{
2367
    NS_PRECONDITION(rv, "Null out param");
2367
    *rv = NS_OK;
2368
    JSStackFrame *fp;
2368
    JSCompartment *compartment = js::GetContextCompartment(cx);
2369
    return GetPrincipalAndFrame(cx, &fp, rv);
2369
2370
    // The context should always be in a compartment, either one it has entered
2371
    // or the one associated with its global. If there's no compartment, bail.
2372
    if (!compartment)
2373
        return nsnull;
2374
2375
    JSPrincipals *principals = JS_GetCompartmentPrincipals(compartment);
2376
    return nsJSPrincipals::get(principals);
2370
}
2377
}
2371
2378
2372
NS_IMETHODIMP
2379
NS_IMETHODIMP
2373
nsScriptSecurityManager::GetObjectPrincipal(JSContext *aCx, JSObject *aObj,
2380
nsScriptSecurityManager::GetObjectPrincipal(JSContext *aCx, JSObject *aObj,
2374
                                            nsIPrincipal **result)
2381
                                            nsIPrincipal **result)
2375
{
2382
{
2376
    *result = doGetObjectPrincipal(aObj);
2383
    *result = doGetObjectPrincipal(aObj);
2377
    if (!*result)
2384
    if (!*result)

Return to bug 754202