Bug 1063197 - Callsites of NS_NewInputStreamChannel in /netwerk/ (r=mcmanus)
--- a/netwerk/protocol/about/nsAboutBlank.cpp
+++ b/netwerk/protocol/about/nsAboutBlank.cpp
@@ -2,30 +2,36 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsAboutBlank.h"
#include "nsStringStream.h"
#include "nsDOMString.h"
#include "nsNetUtil.h"
+#include "nsContentUtils.h"
NS_IMPL_ISUPPORTS(nsAboutBlank, nsIAboutModule)
NS_IMETHODIMP
nsAboutBlank::NewChannel(nsIURI *aURI, nsIChannel **result)
{
NS_ENSURE_ARG_POINTER(aURI);
nsCOMPtr<nsIInputStream> in;
nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), EmptyCString());
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
- rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI, in,
+ rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
+ aURI,
+ in,
+ nsContentUtils::GetSystemPrincipal(),
+ nsILoadInfo::SEC_NORMAL,
+ nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"));
if (NS_FAILED(rv)) return rv;
channel.forget(result);
return rv;
}
--- a/netwerk/protocol/about/nsAboutBloat.cpp
+++ b/netwerk/protocol/about/nsAboutBloat.cpp
@@ -4,16 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsTraceRefcnt.h"
// if NS_BUILD_REFCNT_LOGGING isn't defined, don't try to build
#ifdef NS_BUILD_REFCNT_LOGGING
#include "nsAboutBloat.h"
+#include "nsContentUtils.h"
#include "nsStringStream.h"
#include "nsDOMString.h"
#include "nsIURI.h"
#include "nsCOMPtr.h"
#include "nsNetUtil.h"
#include "nsDirectoryServiceDefs.h"
#include "nsIFile.h"
@@ -104,17 +105,22 @@ nsAboutBloat::NewChannel(nsIURI *aURI, n
::fclose(out);
if (NS_FAILED(rv)) return rv;
rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), file);
if (NS_FAILED(rv)) return rv;
}
nsIChannel* channel = nullptr;
- rv = NS_NewInputStreamChannel(&channel, aURI, inStr,
+ rv = NS_NewInputStreamChannel(&channel,
+ aURI,
+ inStr,
+ nsContentUtils::GetSystemPrincipal(),
+ nsILoadInfo::SEC_NORMAL,
+ nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/plain"),
NS_LITERAL_CSTRING("utf-8"));
if (NS_FAILED(rv)) return rv;
*result = channel;
return rv;
}
--- a/netwerk/protocol/about/nsAboutCache.cpp
+++ b/netwerk/protocol/about/nsAboutCache.cpp
@@ -4,16 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsAboutCache.h"
#include "nsIInputStream.h"
#include "nsIStorageStream.h"
#include "nsIURI.h"
#include "nsCOMPtr.h"
#include "nsNetUtil.h"
+#include "nsContentUtils.h"
#include "nsEscape.h"
#include "nsAboutProtocolUtils.h"
#include "nsPrintfCString.h"
#include "nsDOMString.h"
#include "nsICacheStorageService.h"
#include "nsICacheStorage.h"
#include "CacheFileUtils.h"
@@ -56,17 +57,22 @@ nsAboutCache::NewChannel(nsIURI *aURI, n
// ...and visit just the specified storage, entries will output too
mStorageList.AppendElement(storageName);
}
// The entries header is added on encounter of the first entry
mEntriesHeaderAdded = false;
nsCOMPtr<nsIChannel> channel;
- rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI, inputStream,
+ rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
+ aURI,
+ inputStream,
+ nsContentUtils::GetSystemPrincipal(),
+ nsILoadInfo::SEC_NORMAL,
+ nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"));
if (NS_FAILED(rv)) return rv;
mBuffer.AssignLiteral(
"<!DOCTYPE html>\n"
"<html>\n"
"<head>\n"
--- a/netwerk/protocol/about/nsAboutCacheEntry.cpp
+++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp
@@ -9,16 +9,17 @@
#include "CacheObserver.h"
#include "nsDOMString.h"
#include "nsNetUtil.h"
#include "prprf.h"
#include "nsEscape.h"
#include "nsIAsyncInputStream.h"
#include "nsIAsyncOutputStream.h"
#include "nsAboutProtocolUtils.h"
+#include "nsContentUtils.h"
#include "nsInputStreamPump.h"
#include "CacheFileUtils.h"
#include <algorithm>
using namespace mozilla::net;
#define HEXDUMP_MAX_ROWS 16
@@ -92,17 +93,22 @@ nsAboutCacheEntry::NewChannel(nsIURI *ur
{
NS_ENSURE_ARG_POINTER(uri);
nsresult rv;
nsCOMPtr<nsIInputStream> stream;
rv = GetContentStream(uri, getter_AddRefs(stream));
if (NS_FAILED(rv)) return rv;
- return NS_NewInputStreamChannel(result, uri, stream,
+ return NS_NewInputStreamChannel(result,
+ uri,
+ stream,
+ nsContentUtils::GetSystemPrincipal(),
+ nsILoadInfo::SEC_NORMAL,
+ nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"));
}
NS_IMETHODIMP
nsAboutCacheEntry::GetURIFlags(nsIURI *aURI, uint32_t *result)
{
*result = nsIAboutModule::HIDE_FROM_ABOUTABOUT;
--- a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp
+++ b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp
@@ -3,16 +3,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsViewSourceChannel.h"
#include "nsIIOService.h"
#include "nsMimeTypes.h"
#include "nsNetUtil.h"
+#include "nsContentUtils.h"
#include "nsIHttpHeaderVisitor.h"
NS_IMPL_ADDREF(nsViewSourceChannel)
NS_IMPL_RELEASE(nsViewSourceChannel)
/*
This QI uses NS_INTERFACE_MAP_ENTRY_CONDITIONAL to check for
non-nullness of mHttpChannel, mCachingChannel, and mUploadChannel.
*/
@@ -80,18 +81,23 @@ nsViewSourceChannel::InitSrcdoc(nsIURI*
nsCOMPtr<nsIURI> inStreamURI;
// Need to strip view-source: from the URI. Hardcoded to
// about:srcdoc as this is the only permissible URI for srcdoc
// loads
rv = NS_NewURI(getter_AddRefs(inStreamURI),
NS_LITERAL_STRING("about:srcdoc"));
NS_ENSURE_SUCCESS(rv, rv);
- rv = NS_NewInputStreamChannel(getter_AddRefs(mChannel), inStreamURI,
- aSrcdoc, NS_LITERAL_CSTRING("text/html"),
+ rv = NS_NewInputStreamChannel(getter_AddRefs(mChannel),
+ inStreamURI,
+ aSrcdoc,
+ NS_LITERAL_CSTRING("text/html"),
+ nsContentUtils::GetSystemPrincipal(),
+ nsILoadInfo::SEC_NORMAL,
+ nsIContentPolicy::TYPE_OTHER,
true);
NS_ENSURE_SUCCESS(rv, rv);
mOriginalURI = aURI;
mIsSrcdocChannel = true;
nsCOMPtr<nsIInputStreamChannel> isc = do_QueryInterface(mChannel);
MOZ_ASSERT(isc);
isc->SetBaseURI(aBaseURI);