@@ -7415,53 +7415,31 @@ def needsConst(a):
74157415 self.cgRoot.append(call)
74167416
74177417 if needsSubjectPrincipal:
7418- needsNonSystemPrincipal = (
7419- "needsNonSystemSubjectPrincipal" in extendedAttributes)
7420- if needsNonSystemPrincipal:
7421- checkPrincipal = dedent(
7422- """
7423- if (nsContentUtils::IsSystemPrincipal(principal)) {
7424- principal = nullptr;
7425- }
7426- """)
7427- else:
7428- checkPrincipal = ""
7429-
7430- getPrincipal = fill(
7418+ getPrincipal = dedent(
74317419 """
74327420 JSCompartment* compartment = js::GetContextCompartment(cx);
74337421 MOZ_ASSERT(compartment);
74347422 JSPrincipals* principals = JS_GetCompartmentPrincipals(compartment);
7435- nsIPrincipal* principal = nsJSPrincipals::get(principals);
7436- ${checkPrincipal}
7437- """,
7438- checkPrincipal=checkPrincipal)
7423+ """)
74397424
74407425 if descriptor.interface.isExposedInAnyWorker():
74417426 self.cgRoot.prepend(CGGeneric(fill(
74427427 """
74437428 Maybe<nsIPrincipal*> subjectPrincipal;
74447429 if (NS_IsMainThread()) {
74457430 $*{getPrincipal}
7446- subjectPrincipal.emplace(principal );
7431+ subjectPrincipal.emplace(nsJSPrincipals::get(principals) );
74477432 }
74487433 """,
74497434 getPrincipal=getPrincipal)))
74507435 else:
7451- if needsNonSystemPrincipal:
7452- principalType = "nsIPrincipal*";
7453- else:
7454- principalType = "NonNull<nsIPrincipal>"
7455-
74567436 self.cgRoot.prepend(CGGeneric(fill(
74577437 """
7458- ${principalType} subjectPrincipal;
7459- {
7460- $*{getPrincipal}
7461- subjectPrincipal = principal;
7462- }
7438+ $*{getPrincipal}
7439+ // Initializing a nonnull is pretty darn annoying...
7440+ NonNull<nsIPrincipal> subjectPrincipal;
7441+ subjectPrincipal = static_cast<nsIPrincipal*>(nsJSPrincipals::get(principals));
74637442 """,
7464- principalType=principalType,
74657443 getPrincipal=getPrincipal)))
74667444
74677445 if isFallible or canOOM:
@@ -14302,18 +14280,8 @@ def dictionaryHasChromeOnly(dictionary):
1430214280 dictionary = dictionary.parent
1430314281 return False
1430414282
14305- def needsNonSystemPrincipal(member):
14306- return (
14307- member.getExtendedAttribute("NeedsSubjectPrincipal") == ["NonSystem"] or
14308- member.getExtendedAttribute("SetterNeedsSubjectPrincipal") == ["NonSystem"] or
14309- member.getExtendedAttribute("GetterNeedsSubjectPrincipal") == ["NonSystem"])
14310-
14311- def descriptorNeedsNonSystemPrincipal(d):
14312- return any(needsNonSystemPrincipal(m) for m in d.interface.members)
14313-
1431414283 bindingHeaders["nsContentUtils.h"] = (
1431514284 any(descriptorHasChromeOnly(d) for d in descriptors) or
14316- any(descriptorNeedsNonSystemPrincipal(d) for d in descriptors) or
1431714285 any(dictionaryHasChromeOnly(d) for d in dictionaries))
1431814286 hasNonEmptyDictionaries = any(
1431914287 len(dict.members) > 0 for dict in dictionaries)
@@ -14732,8 +14700,6 @@ def getArgs(self, returnType, argList):
1473214700 # Cheat and assume self.descriptorProvider is a descriptor
1473314701 if self.descriptorProvider.interface.isExposedInAnyWorker():
1473414702 args.append(Argument("Maybe<nsIPrincipal*>", "aSubjectPrincipal"))
14735- elif 'needsNonSystemSubjectPrincipal' in self.extendedAttrs:
14736- args.append(Argument("nsIPrincipal*", "aPrincipal"))
1473714703 else:
1473814704 args.append(Argument("nsIPrincipal&", "aPrincipal"))
1473914705 # And the caller type, if desired.
0 commit comments