Bug 1195173 - Convert ExtensionProtocolHandler to use channel->Open2() (r=maglione)

This commit is contained in:
Christoph Kerschbaumer 2016-02-02 20:35:15 -08:00
parent 5a89bae2c9
commit 4372ffbfa4

View File

@ -104,8 +104,9 @@ ExtensionProtocolHandler::SubstituteChannel(nsIURI* aURI,
const char* kToType = "text/css"; const char* kToType = "text/css";
nsCOMPtr<nsIInputStream> inputStream; nsCOMPtr<nsIInputStream> inputStream;
if (aLoadInfo && aLoadInfo->GetSecurityMode()) { if (aLoadInfo &&
// Certain security checks require an async channel. aLoadInfo->GetSecurityMode() == nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS) {
// If the channel needs to enforce CORS, we need to open the channel async.
nsCOMPtr<nsIOutputStream> outputStream; nsCOMPtr<nsIOutputStream> outputStream;
rv = NS_NewPipe(getter_AddRefs(inputStream), getter_AddRefs(outputStream), rv = NS_NewPipe(getter_AddRefs(inputStream), getter_AddRefs(outputStream),
@ -128,11 +129,14 @@ ExtensionProtocolHandler::SubstituteChannel(nsIURI* aURI,
rv = (*result)->AsyncOpen2(converter); rv = (*result)->AsyncOpen2(converter);
} else { } else {
// Stylesheet loads for extension content scripts require a sync channel, // Stylesheet loads for extension content scripts require a sync channel.
// but fortunately do not invoke security checks.
nsCOMPtr<nsIInputStream> sourceStream; nsCOMPtr<nsIInputStream> sourceStream;
rv = (*result)->Open(getter_AddRefs(sourceStream)); if (aLoadInfo && aLoadInfo->GetEnforceSecurity()) {
rv = (*result)->Open2(getter_AddRefs(sourceStream));
} else {
rv = (*result)->Open(getter_AddRefs(sourceStream));
}
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = convService->Convert(sourceStream, kFromType, kToType, rv = convService->Convert(sourceStream, kFromType, kToType,