Bug 998002 - Rename nsContentUtils::Get{Subject,Object}Principal to nsContentUtils::{Subject,Object}Principal. r=bholley

This commit is contained in:
Nick Lebedev 2014-05-13 11:58:00 +02:00
parent 566ca0b5ea
commit b7223435b4
32 changed files with 69 additions and 68 deletions

View File

@ -337,7 +337,7 @@ bool
nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(JSContext *cx)
{
MOZ_ASSERT(cx == nsContentUtils::GetCurrentJSContext());
nsCOMPtr<nsIPrincipal> subjectPrincipal = nsContentUtils::GetSubjectPrincipal();
nsCOMPtr<nsIPrincipal> subjectPrincipal = nsContentUtils::SubjectPrincipal();
nsCOMPtr<nsIContentSecurityPolicy> csp;
nsresult rv = subjectPrincipal->GetCsp(getter_AddRefs(csp));
NS_ASSERTION(NS_SUCCEEDED(rv), "CSP: Failed to get CSP from principal.");
@ -393,7 +393,7 @@ nsScriptSecurityManager::CheckSameOrigin(JSContext* cx,
MOZ_ASSERT_IF(cx, cx == nsContentUtils::GetCurrentJSContext());
// Get a principal from the context
nsIPrincipal* sourcePrincipal = nsContentUtils::GetSubjectPrincipal();
nsIPrincipal* sourcePrincipal = nsContentUtils::SubjectPrincipal();
if (sourcePrincipal == mSystemPrincipal)
{
// This is a system (chrome) script, so allow access
@ -470,7 +470,7 @@ nsScriptSecurityManager::CheckLoadURIFromScript(JSContext *cx, nsIURI *aURI)
{
// Get principal of currently executing script.
MOZ_ASSERT(cx == nsContentUtils::GetCurrentJSContext());
nsIPrincipal* principal = nsContentUtils::GetSubjectPrincipal();
nsIPrincipal* principal = nsContentUtils::SubjectPrincipal();
nsresult rv = CheckLoadURIWithPrincipal(principal, aURI,
nsIScriptSecurityManager::STANDARD);
if (NS_SUCCEEDED(rv)) {
@ -1046,7 +1046,7 @@ nsScriptSecurityManager::CanCreateWrapper(JSContext *cx,
//-- Access denied, report an error
NS_ConvertUTF8toUTF16 strName("CreateWrapperDenied");
nsAutoCString origin;
nsIPrincipal* subjectPrincipal = nsContentUtils::GetSubjectPrincipal();
nsIPrincipal* subjectPrincipal = nsContentUtils::SubjectPrincipal();
GetPrincipalDomainOrigin(subjectPrincipal, origin);
NS_ConvertUTF8toUTF16 originUnicode(origin);
NS_ConvertUTF8toUTF16 classInfoName(objClassInfo.GetName());

View File

@ -478,14 +478,11 @@ public:
// Returns the subject principal. Guaranteed to return non-null. May only
// be called when nsContentUtils is initialized.
static nsIPrincipal* GetSubjectPrincipal();
static nsIPrincipal* SubjectPrincipal();
// Returns the principal of the given JS object. This should never be null
// for any object in the XPConnect runtime.
//
// In general, being interested in the principal of an object is enough to
// guarantee that the return value is non-null.
static nsIPrincipal* GetObjectPrincipal(JSObject* aObj);
// Returns the prinipal of the given JS object. This may only be called on
// the main thread for objects from the main thread's JSRuntime.
static nsIPrincipal* ObjectPrincipal(JSObject* aObj);
static nsresult GenerateStateKey(nsIContent* aContent,
const nsIDocument* aDocument,

View File

@ -388,7 +388,7 @@ DOMParser::Constructor(const GlobalObject& aOwner,
{
nsRefPtr<DOMParser> domParser = new DOMParser(aOwner.GetAsSupports());
rv = domParser->InitInternal(aOwner.GetAsSupports(),
nsContentUtils::GetSubjectPrincipal(),
nsContentUtils::SubjectPrincipal(),
nullptr, nullptr);
if (rv.Failed()) {
return nullptr;
@ -446,7 +446,7 @@ DOMParser::Init(nsIPrincipal* aPrincipal, nsIURI* aDocumentURI,
nsCOMPtr<nsIPrincipal> principal = aPrincipal;
if (!principal && !aDocumentURI) {
principal = nsContentUtils::GetSubjectPrincipal();
principal = nsContentUtils::SubjectPrincipal();
}
rv = Init(principal, aDocumentURI, aBaseURI,

View File

@ -1573,7 +1573,7 @@ nsContentUtils::CanCallerAccess(nsIDOMNode *aNode)
bool
nsContentUtils::CanCallerAccess(nsINode* aNode)
{
return CanCallerAccess(GetSubjectPrincipal(), aNode->NodePrincipal());
return CanCallerAccess(SubjectPrincipal(), aNode->NodePrincipal());
}
// static
@ -1585,7 +1585,7 @@ nsContentUtils::CanCallerAccess(nsPIDOMWindow* aWindow)
aWindow->GetCurrentInnerWindow() : aWindow);
NS_ENSURE_TRUE(scriptObject, false);
return CanCallerAccess(GetSubjectPrincipal(), scriptObject->GetPrincipal());
return CanCallerAccess(SubjectPrincipal(), scriptObject->GetPrincipal());
}
//static
@ -1687,7 +1687,7 @@ bool
nsContentUtils::IsCallerChrome()
{
MOZ_ASSERT(NS_IsMainThread());
if (GetSubjectPrincipal() == sSystemPrincipal) {
if (SubjectPrincipal() == sSystemPrincipal) {
return true;
}
@ -2315,7 +2315,7 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
// static
nsIPrincipal*
nsContentUtils::GetSubjectPrincipal()
nsContentUtils::SubjectPrincipal()
{
JSContext* cx = GetCurrentJSContext();
if (!cx) {
@ -2330,8 +2330,11 @@ nsContentUtils::GetSubjectPrincipal()
// static
nsIPrincipal*
nsContentUtils::GetObjectPrincipal(JSObject* aObj)
nsContentUtils::ObjectPrincipal(JSObject* aObj)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(JS_GetObjectRuntime(aObj) == CycleCollectedJSRuntime::Get()->Runtime());
// This is duplicated from nsScriptSecurityManager. We don't call through there
// because the API unnecessarily requires a JSContext for historical reasons.
JSCompartment *compartment = js::GetObjectCompartment(aObj);
@ -6062,7 +6065,7 @@ nsContentUtils::GetContentSecurityPolicy(JSContext* aCx,
MOZ_ASSERT(aCx == GetCurrentJSContext());
nsCOMPtr<nsIContentSecurityPolicy> csp;
nsresult rv = GetSubjectPrincipal()->GetCsp(getter_AddRefs(csp));
nsresult rv = SubjectPrincipal()->GetCsp(getter_AddRefs(csp));
if (NS_FAILED(rv)) {
NS_ERROR("CSP: Failed to get CSP from principal.");
return false;

View File

@ -6358,7 +6358,7 @@ nsIDocument::LoadBindingDocument(const nsAString& aURI, ErrorResult& rv)
// It's just designed to preserve the old semantics during a mass-conversion
// patch.
nsCOMPtr<nsIPrincipal> subjectPrincipal =
nsContentUtils::GetCurrentJSContext() ? nsContentUtils::GetSubjectPrincipal()
nsContentUtils::GetCurrentJSContext() ? nsContentUtils::SubjectPrincipal()
: NodePrincipal();
BindingManager()->LoadBindingDocument(this, uri, subjectPrincipal);
}

View File

@ -48,7 +48,7 @@ nsElementFrameLoaderOwner::GetContentDocument()
nsIDocument *doc = win->GetDoc();
// Return null for cross-origin contentDocument.
if (!nsContentUtils::GetSubjectPrincipal()->
if (!nsContentUtils::SubjectPrincipal()->
SubsumesConsideringDomain(doc->NodePrincipal())) {
return nullptr;
}

View File

@ -3193,7 +3193,7 @@ nsObjectLoadingContent::GetContentDocument()
}
// Return null for cross-origin contentDocument.
if (!nsContentUtils::GetSubjectPrincipal()->SubsumesConsideringDomain(sub_doc->NodePrincipal())) {
if (!nsContentUtils::SubjectPrincipal()->SubsumesConsideringDomain(sub_doc->NodePrincipal())) {
return nullptr;
}

View File

@ -1713,7 +1713,7 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsIURI** aU
nsGenericHTMLElement::IsScrollGrabAllowed(JSContext*, JSObject*)
{
// Only allow scroll grabbing in chrome and certified apps.
nsIPrincipal* prin = nsContentUtils::GetSubjectPrincipal();
nsIPrincipal* prin = nsContentUtils::SubjectPrincipal();
return nsContentUtils::IsSystemPrincipal(prin) ||
prin->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED;
}

View File

@ -2849,7 +2849,7 @@ nsHTMLDocument::SetDesignMode(const nsAString & aDesignMode)
void
nsHTMLDocument::SetDesignMode(const nsAString& aDesignMode, ErrorResult& rv)
{
if (!nsContentUtils::GetSubjectPrincipal()->Subsumes(NodePrincipal())) {
if (!nsContentUtils::SubjectPrincipal()->Subsumes(NodePrincipal())) {
rv.Throw(NS_ERROR_DOM_PROP_ACCESS_DENIED);
return;
}

View File

@ -8673,7 +8673,7 @@ nsDocShell::CheckLoadingPermissions()
return NS_ERROR_UNEXPECTED;
}
if (nsContentUtils::GetSubjectPrincipal()->Subsumes(p)) {
if (nsContentUtils::SubjectPrincipal()->Subsumes(p)) {
// Same origin, permit load
return NS_OK;
}

View File

@ -2277,7 +2277,7 @@ Navigator::HasWifiManagerSupport(JSContext* /* unused */,
// to use nsContentUtils::GetObjectPrincipal to get the principal
// and test directly with permission manager.
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(aGlobal);
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aGlobal);
nsCOMPtr<nsIPermissionManager> permMgr =
services::GetPermissionManager();

View File

@ -148,7 +148,7 @@ URL::CreateObjectURLInternal(const GlobalObject& aGlobal, nsISupports* aObject,
const objectURLOptions& aOptions,
nsString& aResult, ErrorResult& aError)
{
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::GetObjectPrincipal(aGlobal.Get());
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::ObjectPrincipal(aGlobal.Get());
nsCString url;
nsresult rv = nsHostObjectProtocolHandler::AddDataEntry(aScheme, aObject,
@ -181,7 +181,7 @@ URL::CreateObjectURLInternal(const GlobalObject& aGlobal, nsISupports* aObject,
void
URL::RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aURL)
{
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(aGlobal.Get());
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aGlobal.Get());
NS_LossyConvertUTF16toASCII asciiurl(aURL);

View File

@ -21,7 +21,7 @@ ShouldExposeChildWindow(nsString& aNameBeingResolved, nsIDOMWindow *aChild)
// If we're same-origin with the child, go ahead and expose it.
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aChild);
NS_ENSURE_TRUE(sop, false);
if (nsContentUtils::GetSubjectPrincipal()->Equals(sop->GetPrincipal())) {
if (nsContentUtils::SubjectPrincipal()->Equals(sop->GetPrincipal())) {
return true;
}

View File

@ -2030,7 +2030,7 @@ nsGlobalWindow::SetInitialPrincipalToSubject()
FORWARD_TO_OUTER_VOID(SetInitialPrincipalToSubject, ());
// First, grab the subject principal.
nsCOMPtr<nsIPrincipal> newWindowPrincipal = nsContentUtils::GetSubjectPrincipal();
nsCOMPtr<nsIPrincipal> newWindowPrincipal = nsContentUtils::SubjectPrincipal();
// Now, if we're about to use the system principal or an nsExpandedPrincipal,
// make sure we're not using it for a content docshell.
@ -6084,7 +6084,7 @@ nsGlobalWindow::MakeScriptDialogTitle(nsAString &aOutTitle)
// Try to get a host from the running principal -- this will do the
// right thing for javascript: and data: documents.
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::GetSubjectPrincipal();
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::SubjectPrincipal();
nsCOMPtr<nsIURI> uri;
nsresult rv = principal->GetURI(getter_AddRefs(uri));
// Note - The check for the current JSContext here isn't necessarily sensical.
@ -7622,8 +7622,8 @@ JSObject* nsGlobalWindow::CallerGlobal()
// .source attribute. So we fall back to the compartment global there.
JS::Rooted<JSObject*> incumbentGlobal(cx, &IncumbentJSGlobal());
JS::Rooted<JSObject*> compartmentGlobal(cx, JS::CurrentGlobalOrNull(cx));
nsIPrincipal* incumbentPrin = nsContentUtils::GetObjectPrincipal(incumbentGlobal);
nsIPrincipal* compartmentPrin = nsContentUtils::GetObjectPrincipal(compartmentGlobal);
nsIPrincipal* incumbentPrin = nsContentUtils::ObjectPrincipal(incumbentGlobal);
nsIPrincipal* compartmentPrin = nsContentUtils::ObjectPrincipal(compartmentGlobal);
return incumbentPrin->EqualsConsideringDomain(compartmentPrin) ? incumbentGlobal
: compartmentGlobal;
}
@ -8093,7 +8093,7 @@ nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
nsContentUtils::GetSecurityManager();
MOZ_ASSERT(ssm);
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::GetSubjectPrincipal();
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::SubjectPrincipal();
MOZ_ASSERT(principal);
uint32_t appId;
@ -8778,7 +8778,7 @@ nsGlobalWindow::GetFrameElement(ErrorResult& aError)
if (aError.Failed() || !element) {
return nullptr;
}
if (!nsContentUtils::GetSubjectPrincipal()->
if (!nsContentUtils::SubjectPrincipal()->
SubsumesConsideringDomain(element->NodePrincipal())) {
return nullptr;
}
@ -8962,7 +8962,7 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument,
}
nsRefPtr<DialogValueHolder> argHolder =
new DialogValueHolder(nsContentUtils::GetSubjectPrincipal(), aArgument);
new DialogValueHolder(nsContentUtils::SubjectPrincipal(), aArgument);
// Before bringing up the window/dialog, unsuppress painting and flush
// pending reflows.
@ -11761,7 +11761,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
// chrome privileges on content windows, but we do allow setTimeouts running
// with content privileges on chrome windows (where they can't do very much,
// of course).
nsCOMPtr<nsIPrincipal> subjectPrincipal = nsContentUtils::GetSubjectPrincipal();
nsCOMPtr<nsIPrincipal> subjectPrincipal = nsContentUtils::SubjectPrincipal();
nsCOMPtr<nsIPrincipal> ourPrincipal = GetPrincipal();
if (ourPrincipal->Subsumes(subjectPrincipal)) {
timeout->mPrincipal = subjectPrincipal;
@ -13490,7 +13490,7 @@ nsGlobalWindow::GetDialogArguments(JSContext* aCx, ErrorResult& aError)
JS::Rooted<JSObject*> wrapper(aCx, GetWrapper());
JSAutoCompartment ac(aCx, wrapper);
JS::Rooted<JS::Value> args(aCx);
mDialogArguments->Get(aCx, wrapper, nsContentUtils::GetSubjectPrincipal(),
mDialogArguments->Get(aCx, wrapper, nsContentUtils::SubjectPrincipal(),
&args, aError);
return args;
}
@ -13503,7 +13503,7 @@ nsGlobalModalWindow::GetDialogArguments(nsIVariant **aArguments)
// This does an internal origin check, and returns undefined if the subject
// does not subsumes the origin of the arguments.
return mDialogArguments->Get(nsContentUtils::GetSubjectPrincipal(), aArguments);
return mDialogArguments->Get(nsContentUtils::SubjectPrincipal(), aArguments);
}
JS::Value
@ -13519,7 +13519,7 @@ nsGlobalWindow::GetReturnValue(JSContext* aCx, ErrorResult& aError)
if (mReturnValue) {
JS::Rooted<JSObject*> wrapper(aCx, GetWrapper());
JSAutoCompartment ac(aCx, wrapper);
mReturnValue->Get(aCx, wrapper, nsContentUtils::GetSubjectPrincipal(),
mReturnValue->Get(aCx, wrapper, nsContentUtils::SubjectPrincipal(),
&returnValue, aError);
}
return returnValue;
@ -13536,7 +13536,7 @@ nsGlobalModalWindow::GetReturnValue(nsIVariant **aRetVal)
variant.forget(aRetVal);
return NS_OK;
}
return mReturnValue->Get(nsContentUtils::GetSubjectPrincipal(), aRetVal);
return mReturnValue->Get(nsContentUtils::SubjectPrincipal(), aRetVal);
}
void
@ -13555,7 +13555,7 @@ nsGlobalWindow::SetReturnValue(JSContext* aCx,
nsContentUtils::XPConnect()->JSToVariant(aCx, aReturnValue,
getter_AddRefs(returnValue));
if (!aError.Failed()) {
mReturnValue = new DialogValueHolder(nsContentUtils::GetSubjectPrincipal(),
mReturnValue = new DialogValueHolder(nsContentUtils::SubjectPrincipal(),
returnValue);
}
}
@ -13565,7 +13565,7 @@ nsGlobalModalWindow::SetReturnValue(nsIVariant *aRetVal)
{
FORWARD_TO_OUTER_MODAL_CONTENT_WINDOW(SetReturnValue, (aRetVal), NS_OK);
mReturnValue = new DialogValueHolder(nsContentUtils::GetSubjectPrincipal(),
mReturnValue = new DialogValueHolder(nsContentUtils::SubjectPrincipal(),
aRetVal);
return NS_OK;
}

View File

@ -14,5 +14,5 @@ nsIGlobalObject::PrincipalOrNull()
if (NS_WARN_IF(!global))
return nullptr;
return nsContentUtils::GetObjectPrincipal(global);
return nsContentUtils::ObjectPrincipal(global);
}

View File

@ -2882,7 +2882,8 @@ AsmJSCacheOpenEntryForRead(JS::Handle<JSObject*> aGlobal,
const uint8_t** aMemory,
intptr_t *aHandle)
{
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(aGlobal);
nsIPrincipal* principal =
nsJSPrincipals::get(JS_GetCompartmentPrincipals(js::GetObjectCompartment(aGlobal)));
return asmjscache::OpenEntryForRead(principal, aBegin, aLimit, aSize, aMemory,
aHandle);
}
@ -2896,7 +2897,8 @@ AsmJSCacheOpenEntryForWrite(JS::Handle<JSObject*> aGlobal,
uint8_t** aMemory,
intptr_t* aHandle)
{
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(aGlobal);
nsIPrincipal* principal =
nsJSPrincipals::get(JS_GetCompartmentPrincipals(js::GetObjectCompartment(aGlobal)));
return asmjscache::OpenEntryForWrite(principal, aInstalled, aBegin, aEnd,
aSize, aMemory, aHandle);
}

View File

@ -160,7 +160,7 @@ nsLocation::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
}
}
owner = nsContentUtils::GetSubjectPrincipal();
owner = nsContentUtils::SubjectPrincipal();
}
// Create load info
@ -921,7 +921,7 @@ nsLocation::CallerSubsumes()
return false;
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(outer);
bool subsumes = false;
nsresult rv = nsContentUtils::GetSubjectPrincipal()->SubsumesConsideringDomain(sop->GetPrincipal(), &subsumes);
nsresult rv = nsContentUtils::SubjectPrincipal()->SubsumesConsideringDomain(sop->GetPrincipal(), &subsumes);
NS_ENSURE_SUCCESS(rv, false);
return subsumes;
}

View File

@ -2177,7 +2177,7 @@ IsInPrivilegedApp(JSContext* aCx, JSObject* aObj)
return GetWorkerPrivateFromContext(aCx)->IsInPrivilegedApp();
}
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(aObj);
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aObj);
uint16_t appStatus = principal->GetAppStatus();
return (appStatus == nsIPrincipal::APP_STATUS_CERTIFIED ||
appStatus == nsIPrincipal::APP_STATUS_PRIVILEGED) ||
@ -2192,7 +2192,7 @@ IsInCertifiedApp(JSContext* aCx, JSObject* aObj)
return GetWorkerPrivateFromContext(aCx)->IsInCertifiedApp();
}
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(aObj);
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aObj);
return principal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED ||
Preferences::GetBool("dom.ignore_webidl_scope_checks", false);
}

View File

@ -66,7 +66,7 @@ CallbackObject::CallSetup::CallSetup(CallbackObject* aCallback,
// do anything that might perturb the relevant state.
nsIPrincipal* webIDLCallerPrincipal = nullptr;
if (aIsJSImplementedWebIDL) {
webIDLCallerPrincipal = nsContentUtils::GetSubjectPrincipal();
webIDLCallerPrincipal = nsContentUtils::SubjectPrincipal();
}
// We need to produce a useful JSContext here. Ideally one that the callback

View File

@ -594,7 +594,7 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
(mEventType != NS_DRAGDROP_DROP && mEventType != NS_DRAGDROP_DRAGDROP &&
mEventType != NS_PASTE &&
!nsContentUtils::IsCallerChrome())) {
principal = nsContentUtils::GetSubjectPrincipal();
principal = nsContentUtils::SubjectPrincipal();
}
uint32_t count = item.Length();
@ -624,7 +624,7 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
nsIPrincipal* dataPrincipal = sp->GetPrincipal();
NS_ENSURE_TRUE(dataPrincipal, NS_ERROR_DOM_SECURITY_ERR);
if (!principal) {
principal = nsContentUtils::GetSubjectPrincipal();
principal = nsContentUtils::SubjectPrincipal();
}
bool equals = false;
NS_ENSURE_TRUE(NS_SUCCEEDED(principal->Equals(dataPrincipal, &equals)) && equals,
@ -696,7 +696,7 @@ DataTransfer::MozSetDataAt(const nsAString& aFormat, nsIVariant* aData,
}
return SetDataWithPrincipal(aFormat, aData, aIndex,
nsContentUtils::GetSubjectPrincipal());
nsContentUtils::SubjectPrincipal());
}
void
@ -749,7 +749,7 @@ DataTransfer::MozClearDataAtHelper(const nsAString& aFormat, uint32_t aIndex,
nsAutoString format;
GetRealFormat(aFormat, format);
nsIPrincipal* principal = nsContentUtils::GetSubjectPrincipal();
nsIPrincipal* principal = nsContentUtils::SubjectPrincipal();
// if the format is empty, clear all formats
bool clearall = format.IsEmpty();

View File

@ -114,7 +114,7 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent)
bool isMainThread = event->IsMainThreadEvent();
bool isChromeHandler =
isMainThread ?
nsContentUtils::GetObjectPrincipal(
nsContentUtils::ObjectPrincipal(
GetTypedEventHandler().Ptr()->CallbackPreserveColor()) ==
nsContentUtils::GetSystemPrincipal() :
mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();

View File

@ -908,7 +908,7 @@ Promise::MaybeReportRejected()
if (MOZ_LIKELY(NS_IsMainThread())) {
win =
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(obj));
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(obj);
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(obj);
isChromeError = nsContentUtils::IsSystemPrincipal(principal);
} else {
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();

View File

@ -251,7 +251,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
if (!useSandbox) {
//-- Don't outside a sandbox unless the script principal subsumes the
// principal of the context.
nsIPrincipal* objectPrincipal = nsContentUtils::GetObjectPrincipal(globalJSObject);
nsIPrincipal* objectPrincipal = nsContentUtils::ObjectPrincipal(globalJSObject);
bool subsumes;
rv = principal->Subsumes(objectPrincipal, &subsumes);

View File

@ -242,7 +242,7 @@ DOMStorage::CanUseStorage(DOMStorage* aStorage)
// chrome can always use aStorage regardless of permission preferences
nsCOMPtr<nsIPrincipal> subjectPrincipal =
nsContentUtils::GetSubjectPrincipal();
nsContentUtils::SubjectPrincipal();
if (nsContentUtils::IsSystemPrincipal(subjectPrincipal)) {
return true;
}

View File

@ -1253,7 +1253,7 @@ txMozillaXSLTProcessor::Initialize(nsISupports* aOwner, JSContext* cx,
JSObject* obj, const JS::CallArgs& args)
{
MOZ_ASSERT(nsContentUtils::GetCurrentJSContext());
return Init(nsContentUtils::GetSubjectPrincipal());
return Init(nsContentUtils::SubjectPrincipal());
}
NS_IMETHODIMP

View File

@ -661,7 +661,7 @@ nsresult nsWebBrowserFind::SearchInFrame(nsIDOMWindow* aWindow,
nsCOMPtr<nsIDocument> theDoc = do_QueryInterface(domDoc);
if (!theDoc) return NS_ERROR_FAILURE;
if (!nsContentUtils::GetSubjectPrincipal()->Subsumes(theDoc->NodePrincipal())) {
if (!nsContentUtils::SubjectPrincipal()->Subsumes(theDoc->NodePrincipal())) {
return NS_ERROR_DOM_PROP_ACCESS_DENIED;
}

View File

@ -791,7 +791,7 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
// It's just designed to preserve old semantics during a mass-conversion
// patch.
nsCOMPtr<nsIPrincipal> subjectPrincipal =
nsContentUtils::GetCurrentJSContext() ? nsContentUtils::GetSubjectPrincipal()
nsContentUtils::GetCurrentJSContext() ? nsContentUtils::SubjectPrincipal()
: nullptr;
if (windowIsNew) {

View File

@ -208,7 +208,7 @@ CreateXMLHttpRequest(JSContext *cx, unsigned argc, jsval *vp)
nsCOMPtr<nsIGlobalObject> iglobal = do_QueryInterface(sop);
nsCOMPtr<nsIXMLHttpRequest> xhr = new nsXMLHttpRequest();
nsresult rv = xhr->Init(nsContentUtils::GetSubjectPrincipal(), nullptr,
nsresult rv = xhr->Init(nsContentUtils::SubjectPrincipal(), nullptr,
iglobal, nullptr);
if (NS_FAILED(rv))
return false;

View File

@ -3631,7 +3631,7 @@ nsXPCComponents_Utils::GetObjectPrincipal(HandleValue val, JSContext *cx,
obj = js::CheckedUnwrap(obj);
MOZ_ASSERT(obj);
nsCOMPtr<nsIPrincipal> prin = nsContentUtils::GetObjectPrincipal(obj);
nsCOMPtr<nsIPrincipal> prin = nsContentUtils::ObjectPrincipal(obj);
prin.forget(result);
return NS_OK;
}

View File

@ -1386,8 +1386,7 @@ XPCJSRuntime::InterruptCallback(JSContext *cx)
// returning to the event loop. See how long it's been, and what the limit
// is.
TimeDuration duration = TimeStamp::NowLoRes() - self->mSlowScriptCheckpoint;
bool chrome =
nsContentUtils::IsSystemPrincipal(nsContentUtils::GetSubjectPrincipal());
bool chrome = nsContentUtils::IsCallerChrome();
const char *prefName = chrome ? "dom.max_chrome_script_run_time"
: "dom.max_script_run_time";
int32_t limit = Preferences::GetInt(prefName, chrome ? 20 : 10);

View File

@ -1615,7 +1615,7 @@ nsCSSStyleSheet::DidDirty()
nsresult
nsCSSStyleSheet::SubjectSubsumesInnerPrincipal()
{
nsCOMPtr<nsIPrincipal> subjectPrincipal = nsContentUtils::GetSubjectPrincipal();
nsCOMPtr<nsIPrincipal> subjectPrincipal = nsContentUtils::SubjectPrincipal();
if (subjectPrincipal->Subsumes(mInner->mPrincipal)) {
return NS_OK;
}

View File

@ -210,7 +210,7 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
// and then blowing it away with a second one, which can cause problems for the
// top-level chrome window case. See bug 789773.
if (nsContentUtils::IsInitialized()) { // Sometimes this happens really early See bug 793370.
rv = mDocShell->CreateAboutBlankContentViewer(nsContentUtils::GetSubjectPrincipal());
rv = mDocShell->CreateAboutBlankContentViewer(nsContentUtils::SubjectPrincipal());
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(!!doc, NS_ERROR_FAILURE);