Bug 1510569 - Use nsIPrincipal and nsIContentSecurityPolicy in WebProgressLocationChangeData directly r=nika

Now that there is an {IPDL}ParamTraits implementation for nsIPrincipal* and
nsIContentSecurityPolicy*, we need not manually transform it to/form a
PrincipalInfo/CSPInfo ourselves.

Differential Revision: https://phabricator.services.mozilla.com/D36637

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Barret Rennie 2019-08-21 18:26:08 +00:00
Родитель 015c35ed0d
Коммит d8feee727d
3 изменённых файлов: 13 добавлений и 49 удалений

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

@ -3592,31 +3592,12 @@ NS_IMETHODIMP BrowserChild::OnLocationChange(nsIWebProgress* aWebProgress,
locationChangeData->charsetAutodetected() =
docShell->GetCharsetAutodetected();
MOZ_TRY(PrincipalToPrincipalInfo(
document->EffectiveStoragePrincipal(),
&locationChangeData->contentStoragePrincipal(), false));
MOZ_TRY(PrincipalToPrincipalInfo(document->NodePrincipal(),
&locationChangeData->contentPrincipal(),
false));
nsIPrincipal* contentBlockingAllowListPrincipal =
locationChangeData->contentPrincipal() = document->NodePrincipal();
locationChangeData->contentStoragePrincipal() =
document->EffectiveStoragePrincipal();
locationChangeData->csp() = document->GetCsp();
locationChangeData->contentBlockingAllowListPrincipal() =
document->GetContentBlockingAllowListPrincipal();
if (contentBlockingAllowListPrincipal) {
PrincipalInfo principalInfo;
MOZ_TRY(PrincipalToPrincipalInfo(contentBlockingAllowListPrincipal,
&principalInfo, false));
locationChangeData->contentBlockingAllowListPrincipal() = principalInfo;
} else {
locationChangeData->contentBlockingAllowListPrincipal() = void_t();
}
if (const nsCOMPtr<nsIContentSecurityPolicy> csp = document->GetCsp()) {
locationChangeData->csp().emplace();
MOZ_TRY(CSPToCSPInfo(csp, &locationChangeData->csp().ref()));
}
locationChangeData->referrerInfo() = document->ReferrerInfo();
locationChangeData->isSyntheticDocument() = document->IsSyntheticDocument();

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

@ -2497,33 +2497,17 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnLocationChange(
aCanGoForward);
if (aWebProgressData && aWebProgressData->isTopLevel()) {
nsCOMPtr<nsIContentSecurityPolicy> csp;
if (aLocationChangeData->csp().isSome()) {
csp = CSPInfoToCSP(aLocationChangeData->csp().ref(), nullptr, nullptr);
}
nsCOMPtr<nsIPrincipal> contentPrincipal =
PrincipalInfoToPrincipal(aLocationChangeData->contentPrincipal());
nsCOMPtr<nsIPrincipal> contentStoragePrincipal = PrincipalInfoToPrincipal(
aLocationChangeData->contentStoragePrincipal());
nsCOMPtr<nsIPrincipal> contentBlockingAllowListPrincipal;
if (aLocationChangeData->contentBlockingAllowListPrincipal().type() ==
OptionalPrincipalInfo::TPrincipalInfo) {
contentBlockingAllowListPrincipal = PrincipalInfoToPrincipal(
aLocationChangeData->contentBlockingAllowListPrincipal()
.get_PrincipalInfo());
}
nsCOMPtr<nsIReferrerInfo> referrerInfo =
aLocationChangeData->referrerInfo();
Unused << browser->SetIsNavigating(aLocationChangeData->isNavigating());
Unused << browser->UpdateForLocationChange(
aLocation, aLocationChangeData->charset(),
aLocationChangeData->mayEnableCharacterEncodingMenu(),
aLocationChangeData->charsetAutodetected(),
aLocationChangeData->documentURI(), aLocationChangeData->title(),
contentPrincipal, contentStoragePrincipal,
contentBlockingAllowListPrincipal, csp, referrerInfo,
aLocationChangeData->contentPrincipal(),
aLocationChangeData->contentStoragePrincipal(),
aLocationChangeData->contentBlockingAllowListPrincipal(),
aLocationChangeData->csp(), aLocationChangeData->referrerInfo(),
aLocationChangeData->isSyntheticDocument(),
aWebProgressData->innerDOMWindowID(),
aLocationChangeData->requestContextID().isSome(),

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

@ -144,7 +144,6 @@ struct WebProgressStateChangeData
nsIURI documentURI;
};
struct WebProgressLocationChangeData
{
bool isNavigating;
@ -155,10 +154,10 @@ struct WebProgressLocationChangeData
nsString title;
nsString charset;
nsIURI documentURI;
PrincipalInfo contentPrincipal;
PrincipalInfo contentStoragePrincipal;
OptionalPrincipalInfo contentBlockingAllowListPrincipal;
CSPInfo? csp;
nsIPrincipal contentPrincipal;
nsIPrincipal contentStoragePrincipal;
nsIPrincipal contentBlockingAllowListPrincipal;
nsIContentSecurityPolicy csp;
nsIReferrerInfo referrerInfo;
uint64_t? requestContextID;
};