/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththisfile,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
switch (aPrincipalInfo.type()) { case PrincipalInfo::TSystemPrincipalInfo: {
principal = SystemPrincipal::Get(); if (NS_WARN_IF(!principal)) { return Err(NS_ERROR_NOT_INITIALIZED);
}
return principal;
}
case PrincipalInfo::TNullPrincipalInfo: { const NullPrincipalInfo& info = aPrincipalInfo.get_NullPrincipalInfo();
nsCOMPtr<nsIURI> domain; if (info.domain()) {
rv = NS_NewURI(getter_AddRefs(domain), *info.domain()); if (NS_WARN_IF(NS_FAILED(rv))) { return Err(rv);
}
}
principal =
BasePrincipal::CreateContentPrincipal(uri, info.attrs(), domain); if (NS_WARN_IF(!principal)) { return Err(NS_ERROR_NULL_POINTER);
}
// Origin must match what the_new_principal.getOrigin returns.
nsAutoCString originNoSuffix;
rv = principal->GetOriginNoSuffix(originNoSuffix); if (NS_WARN_IF(NS_FAILED(rv))) { return Err(rv);
}
if (NS_WARN_IF(!info.originNoSuffix().Equals(originNoSuffix))) { return Err(NS_ERROR_FAILURE);
}
if (!info.baseDomain().IsVoid()) {
nsAutoCString baseDomain;
rv = principal->GetBaseDomain(baseDomain); if (NS_WARN_IF(NS_FAILED(rv))) { return Err(rv);
}
if (NS_WARN_IF(!info.baseDomain().Equals(baseDomain))) { return Err(NS_ERROR_FAILURE);
}
} return principal;
}
case PrincipalInfo::TExpandedPrincipalInfo: { const ExpandedPrincipalInfo& info =
aPrincipalInfo.get_ExpandedPrincipalInfo();
for (uint32_t i = 0; i < info.allowlist().Length(); i++) { auto principalOrErr = PrincipalInfoToPrincipal(info.allowlist()[i]); if (NS_WARN_IF(principalOrErr.isErr())) {
nsresult ret = principalOrErr.unwrapErr(); return Err(ret);
} // append that principal to the allowlist
allowlist.AppendElement(principalOrErr.unwrap());
}
if (aPrincipal->IsSystemPrincipal()) {
*aPrincipalInfo = SystemPrincipalInfo(); return NS_OK;
}
// might be an expanded principal auto* basePrin = BasePrincipal::Cast(aPrincipal); if (basePrin->Is<ExpandedPrincipal>()) { auto* expanded = basePrin->As<ExpandedPrincipal>();
for (auto& prin : expanded->AllowList()) {
rv = PrincipalToPrincipalInfo(prin, &info, aSkipBaseDomain); if (NS_WARN_IF(NS_FAILED(rv))) { return rv;
} // append that spec to the allowlist
allowlistInfo.AppendElement(info);
}
Maybe<nsCString> domain; if (domainUri) {
domain.emplace();
rv = domainUri->GetSpec(domain.ref()); if (NS_WARN_IF(NS_FAILED(rv))) { return rv;
}
}
// This attribute is not crucial.
nsCString baseDomain; if (aSkipBaseDomain) {
baseDomain.SetIsVoid(true);
} else { if (NS_FAILED(aPrincipal->GetBaseDomain(baseDomain))) { // No warning here. Some principal URLs do not have a base-domain.
baseDomain.SetIsVoid(true);
}
}
auto triggeringPrincipalOrErr =
PrincipalInfoToPrincipal(loadInfoArgs.triggeringPrincipalInfo()); if (NS_WARN_IF(triggeringPrincipalOrErr.isErr())) { return triggeringPrincipalOrErr.unwrapErr();
}
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
triggeringPrincipalOrErr.unwrap();
nsCOMPtr<nsIPrincipal> principalToInherit;
nsCOMPtr<nsIPrincipal> flattenedPrincipalToInherit; if (loadInfoArgs.principalToInheritInfo().isSome()) { auto principalToInheritOrErr =
PrincipalInfoToPrincipal(loadInfoArgs.principalToInheritInfo().ref()); if (NS_WARN_IF(principalToInheritOrErr.isErr())) { return principalToInheritOrErr.unwrapErr();
}
flattenedPrincipalToInherit = principalToInheritOrErr.unwrap();
}
if (XRE_IsContentProcess()) { auto targetBrowsingContextId = loadInfoArgs.frameBrowsingContextID()
? loadInfoArgs.frameBrowsingContextID()
: loadInfoArgs.browsingContextID(); if (RefPtr<BrowsingContext> bc =
BrowsingContext::Get(targetBrowsingContextId)) { auto [originalTriggeringPrincipal, originalPrincipalToInherit] =
bc->GetTriggeringAndInheritPrincipalsForCurrentLoad();
// If we received this message from a content process, reset // triggeringRemoteType to the process which sent us the message. If the // parent sent us the message, we trust it to provide the correct triggering // remote type. // // This means that the triggering remote type will be reset if a LoadInfo is // bounced through a content process, as the LoadInfo can no longer be // validated to be coming from the originally specified remote type.
nsCString triggeringRemoteType = loadInfoArgs.triggeringRemoteType(); if (aOriginRemoteType != NOT_REMOTE_TYPE &&
aOriginRemoteType != triggeringRemoteType) {
triggeringRemoteType = aOriginRemoteType;
}
RedirectHistoryArray redirectChain; for (const RedirectHistoryEntryInfo& entryInfo :
loadInfoArgs.redirectChain()) {
nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
RHEntryInfoToRHEntry(entryInfo);
NS_ENSURE_TRUE(redirectHistoryEntry, NS_ERROR_UNEXPECTED);
redirectChain.AppendElement(redirectHistoryEntry.forget());
}
nsTArray<nsCOMPtr<nsIPrincipal>> ancestorPrincipals;
nsTArray<uint64_t> ancestorBrowsingContextIDs; if (XRE_IsParentProcess() &&
(nsContentUtils::InternalContentPolicyTypeToExternal(
loadInfoArgs.contentPolicyType()) !=
ExtContentPolicy::TYPE_DOCUMENT)) { // Only fill out ancestor principals and browsing context IDs when we // are deserializing LoadInfoArgs to be LoadInfo for a subresource
RefPtr<BrowsingContext> parentBC =
BrowsingContext::Get(loadInfoArgs.browsingContextID()); if (parentBC) {
LoadInfo::ComputeAncestors(parentBC->Canonical(), ancestorPrincipals,
ancestorBrowsingContextIDs);
}
} else { // Fill out (possibly redacted) ancestor principals for // Location.ancestorOrigins for (constauto& principalInfo : loadInfoArgs.ancestorOrigins()) { if (principalInfo.isNothing()) {
ancestorPrincipals.AppendElement(nullptr);
} else { auto principal = PrincipalInfoToPrincipal(principalInfo.value()); // If this operation fail, we censor the origin.
ancestorPrincipals.AppendElement(principal.unwrapOr(nullptr));
}
}
}
Maybe<ClientInfo> clientInfo; if (loadInfoArgs.clientInfo().isSome()) {
clientInfo.emplace(ClientInfo(loadInfoArgs.clientInfo().ref()));
}
Maybe<ClientInfo> reservedClientInfo; if (loadInfoArgs.reservedClientInfo().isSome()) {
reservedClientInfo.emplace(
ClientInfo(loadInfoArgs.reservedClientInfo().ref()));
}
Maybe<ClientInfo> initialClientInfo; if (loadInfoArgs.initialClientInfo().isSome()) {
initialClientInfo.emplace(
ClientInfo(loadInfoArgs.initialClientInfo().ref()));
}
// We can have an initial client info or a reserved client info, but not both.
MOZ_DIAGNOSTIC_ASSERT(reservedClientInfo.isNothing() ||
initialClientInfo.isNothing());
NS_ENSURE_TRUE(
reservedClientInfo.isNothing() || initialClientInfo.isNothing(),
NS_ERROR_UNEXPECTED);
Maybe<ServiceWorkerDescriptor> controller; if (loadInfoArgs.controller().isSome()) {
controller.emplace(
ServiceWorkerDescriptor(loadInfoArgs.controller().ref()));
}
Maybe<RFPTargetSet> overriddenFingerprintingSettings; if (loadInfoArgs.overriddenFingerprintingSettings().isSome()) {
overriddenFingerprintingSettings.emplace(
loadInfoArgs.overriddenFingerprintingSettings().ref());
}
// Restore the loadingContext for frames using the BrowsingContext's // embedder element. Note that this only works if the embedder is // same-process, so won't be fission compatible.
nsCOMPtr<nsINode> loadingContext;
RefPtr<BrowsingContext> frameBrowsingContext =
BrowsingContext::Get(loadInfoArgs.frameBrowsingContextID()); if (frameBrowsingContext) {
loadingContext = frameBrowsingContext->GetEmbedderElement();
}
Maybe<bool> isThirdPartyContextToTopWindow; if (loadInfoArgs.isThirdPartyContextToTopWindow().isSome()) {
isThirdPartyContextToTopWindow.emplace(
loadInfoArgs.isThirdPartyContextToTopWindow().ref());
}
nsCOMPtr<nsIInterceptionInfo> interceptionInfo; if (loadInfoArgs.interceptionInfo().isSome()) { const InterceptionInfoArg& interceptionInfoArg =
loadInfoArgs.interceptionInfo().ref();
nsCOMPtr<nsIPrincipal> triggeringPrincipal; if (interceptionInfoArg.triggeringPrincipalInfo().isSome()) { auto triggeringPrincipalOrErr = PrincipalInfoToPrincipal(
interceptionInfoArg.triggeringPrincipalInfo().ref()); if (NS_WARN_IF(triggeringPrincipalOrErr.isErr())) { return triggeringPrincipalOrErr.unwrapErr();
}
triggeringPrincipal = triggeringPrincipalOrErr.unwrap();
}
loadInfoArgs.initialSecurityCheckDone(),
loadInfoArgs.isInThirdPartyContext(), isThirdPartyContextToTopWindow,
loadInfoArgs.originAttributes(),
std::move(redirectChainIncludingInternalRedirects),
std::move(redirectChain), std::move(ancestorPrincipals),
ancestorBrowsingContextIDs, loadInfoArgs.corsUnsafeHeaders(),
loadInfoArgs.loadTriggeredFromExternal(), loadInfoArgs.cspNonce(),
loadInfoArgs.integrityMetadata(), // This function is only called for moving LoadInfo across processes. // Same-document navigation won't cross process boundaries. /* aIsSameDocumentNavigation */ false, overriddenFingerprintingSettings,
loadingContext, loadInfoArgs.unstrippedURI(), interceptionInfo,
loadInfoArgs.schemelessInput(), loadInfoArgs.userNavigationInvolvement());
// There should only be at most one reserved or initial ClientInfo. if (NS_WARN_IF(reservedClientInfo.isSome() && initialClientInfo.isSome())) { return NS_ERROR_FAILURE;
}
// If we received no reserved or initial ClientInfo, then we must not // already have one set. There are no use cases where this should // happen and we don't have a way to clear the current value. if (NS_WARN_IF(reservedClientInfo.isNothing() &&
initialClientInfo.isNothing() &&
(aLoadInfo->GetReservedClientInfo().isSome() ||
aLoadInfo->GetInitialClientInfo().isSome()))) { return NS_ERROR_FAILURE;
}
if (reservedClientInfo.isSome()) { // We need to override here instead of simply set the value. This // allows us to change the reserved client. This is necessary when // the ClientChannelHelper created a new reserved client in the // child-side of the redirect.
aLoadInfo->OverrideReservedClientInfoInParent(reservedClientInfo.ref());
} elseif (initialClientInfo.isSome()) {
aLoadInfo->SetInitialClientInfo(initialClientInfo.ref());
}
aLoadInfo->ClearController(); auto& controller = aForwarderArgs.controller(); if (controller.isSome()) {
aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
}
uint32_t blockingReason = aForwarderArgs.requestBlockingReason(); if (blockingReason) { // We only want to override when non-null, so that any earlier set non-null // value is not reverted to 0.
aLoadInfo->SetRequestBlockingReason(blockingReason);
}
return NS_OK;
}
} // namespace ipc
} // namespace mozilla
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.19 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.