Bug 1354349 - Use channel.isDocument in ContentParent::TransmitPermissionsFor r=mystor

MozReview-Commit-ID: L9b6UeXJ8o5

--HG--
extra : rebase_source : a03d4f34bc53a92056168302c8ef41fb277db0ee
This commit is contained in:
Valentin Gosu 2017-04-18 14:17:58 +08:00
Родитель 8f33abcc56
Коммит a858271ee6
1 изменённых файлов: 3 добавлений и 20 удалений

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

@ -5035,27 +5035,10 @@ ContentParent::TransmitPermissionsFor(nsIChannel* aChannel)
{
MOZ_ASSERT(aChannel);
#ifdef MOZ_PERMISSIONS
// Check if this channel is going to be used to create a document. If it has
// LOAD_DOCUMENT_URI set it is trivially creating a document. If
// LOAD_HTML_OBJECT_DATA is set it may or may not be used to create a
// document, depending on its MIME type.
nsLoadFlags loadFlags;
nsresult rv = aChannel->GetLoadFlags(&loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
if (!(loadFlags & nsIChannel::LOAD_DOCUMENT_URI)) {
if (loadFlags & nsIRequest::LOAD_HTML_OBJECT_DATA) {
nsAutoCString mimeType;
aChannel->GetContentType(mimeType);
if (nsContentUtils::HtmlObjectContentTypeForMIMEType(mimeType, nullptr) !=
nsIObjectLoadingContent::TYPE_DOCUMENT) {
// The MIME type would not cause the creation of a document
return NS_OK;
}
} else {
// neither flag was set
return NS_OK;
}
nsresult rv;
if (!aChannel->IsDocument()) {
return NS_OK;
}
// Get the principal for the channel result, so that we can get the permission