Bug 1793463 - Part 6: Remove nsIProtocolHandler.{defaultPort,protocolFlags}, r=necko-reviewers,valentin

This removes all implementations of these types. Some implementations in JS
code were also removed in the previous part, when updating tests to use
`Services.io.registerProtocolHandler`.

Code which used to access these members should go through the IOService now
instead.

Differential Revision: https://phabricator.services.mozilla.com/D162805
This commit is contained in:
Nika Layzell 2022-11-30 18:13:43 +00:00
Родитель 9cc8ee8c01
Коммит 20db36cecb
23 изменённых файлов: 8 добавлений и 331 удалений

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

@ -40,12 +40,6 @@ nsChromeProtocolHandler::GetScheme(nsACString& result) {
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::GetDefaultPort(int32_t* result) {
*result = -1; // no port for chrome: URLs
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::AllowPort(int32_t port, const char* scheme,
bool* _retval) {
@ -54,12 +48,6 @@ nsChromeProtocolHandler::AllowPort(int32_t port, const char* scheme,
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::GetProtocolFlags(uint32_t* result) {
*result = URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE;
return NS_OK;
}
/* static */ nsresult nsChromeProtocolHandler::CreateNewURI(
const nsACString& aSpec, const char* aCharset, nsIURI* aBaseURI,
nsIURI** result) {

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

@ -824,19 +824,6 @@ void BlobURLProtocolHandler::Traverse(
NS_IMPL_ISUPPORTS(BlobURLProtocolHandler, nsIProtocolHandler,
nsISupportsWeakReference)
NS_IMETHODIMP
BlobURLProtocolHandler::GetDefaultPort(int32_t* result) {
*result = -1;
return NS_OK;
}
NS_IMETHODIMP
BlobURLProtocolHandler::GetProtocolFlags(uint32_t* result) {
*result = URI_NORELATIVE | URI_NOAUTH | URI_LOADABLE_BY_SUBSUMERS |
URI_NON_PERSISTABLE | URI_IS_LOCAL_RESOURCE;
return NS_OK;
}
/* static */ nsresult BlobURLProtocolHandler::CreateNewURI(
const nsACString& aSpec, const char* aCharset, nsIURI* aBaseURI,
nsIURI** aResult) {

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

@ -38,19 +38,6 @@ FontTableURIProtocolHandler::~FontTableURIProtocolHandler() = default;
NS_IMPL_ISUPPORTS(FontTableURIProtocolHandler, nsIProtocolHandler,
nsISupportsWeakReference)
NS_IMETHODIMP
FontTableURIProtocolHandler::GetDefaultPort(int32_t* result) {
*result = -1;
return NS_OK;
}
NS_IMETHODIMP
FontTableURIProtocolHandler::GetProtocolFlags(uint32_t* result) {
*result = URI_NORELATIVE | URI_NOAUTH | URI_LOADABLE_BY_SUBSUMERS |
URI_NON_PERSISTABLE | URI_IS_LOCAL_RESOURCE;
return NS_OK;
}
NS_IMETHODIMP
FontTableURIProtocolHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
nsIChannel** result) {

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

@ -1152,20 +1152,6 @@ nsJSProtocolHandler::GetScheme(nsACString& result) {
return NS_OK;
}
NS_IMETHODIMP
nsJSProtocolHandler::GetDefaultPort(int32_t* result) {
*result = -1; // no port for javascript: URLs
return NS_OK;
}
NS_IMETHODIMP
nsJSProtocolHandler::GetProtocolFlags(uint32_t* result) {
*result = URI_NORELATIVE | URI_NOAUTH | URI_INHERITS_SECURITY_CONTEXT |
URI_LOADABLE_BY_ANYONE | URI_NON_PERSISTABLE |
URI_OPENING_EXECUTES_SCRIPT;
return NS_OK;
}
/* static */ nsresult nsJSProtocolHandler::CreateNewURI(const nsACString& aSpec,
const char* aCharset,
nsIURI* aBaseURI,

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

@ -30,19 +30,6 @@ NS_IMETHODIMP nsIndexedDBProtocolHandler::GetScheme(nsACString& aScheme) {
return NS_OK;
}
NS_IMETHODIMP nsIndexedDBProtocolHandler::GetDefaultPort(
int32_t* aDefaultPort) {
*aDefaultPort = -1;
return NS_OK;
}
NS_IMETHODIMP nsIndexedDBProtocolHandler::GetProtocolFlags(
uint32_t* aProtocolFlags) {
*aProtocolFlags = URI_STD | URI_DANGEROUS_TO_LOAD | URI_DOES_NOT_RETURN_DATA |
URI_NON_PERSISTABLE;
return NS_OK;
}
NS_IMETHODIMP
nsIndexedDBProtocolHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
nsIChannel** _retval) {

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

@ -30,12 +30,6 @@ nsIconProtocolHandler::GetScheme(nsACString& result) {
return NS_OK;
}
NS_IMETHODIMP
nsIconProtocolHandler::GetDefaultPort(int32_t* result) {
*result = 0;
return NS_OK;
}
NS_IMETHODIMP
nsIconProtocolHandler::AllowPort(int32_t port, const char* scheme,
bool* _retval) {
@ -44,13 +38,6 @@ nsIconProtocolHandler::AllowPort(int32_t port, const char* scheme,
return NS_OK;
}
NS_IMETHODIMP
nsIconProtocolHandler::GetProtocolFlags(uint32_t* result) {
*result =
URI_NORELATIVE | URI_NOAUTH | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE;
return NS_OK;
}
NS_IMETHODIMP
nsIconProtocolHandler::NewChannel(nsIURI* url, nsILoadInfo* aLoadInfo,
nsIChannel** result) {

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

@ -67,23 +67,6 @@ nsJARProtocolHandler::GetScheme(nsACString& result) {
return NS_OK;
}
NS_IMETHODIMP
nsJARProtocolHandler::GetDefaultPort(int32_t* result) {
*result = -1; // no port for JAR: URLs
return NS_OK;
}
NS_IMETHODIMP
nsJARProtocolHandler::GetProtocolFlags(uint32_t* result) {
// URI_LOADABLE_BY_ANYONE, since it's our inner URI that will matter
// anyway.
*result = URI_NORELATIVE | URI_NOAUTH | URI_LOADABLE_BY_ANYONE;
/* Although jar uris have their own concept of relative urls
it is very different from the standard behaviour, so we
have to say norelative here! */
return NS_OK;
}
NS_IMETHODIMP
nsJARProtocolHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
nsIChannel** result) {

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

@ -55,44 +55,6 @@ interface nsIProtocolHandler : nsISupports
*/
readonly attribute ACString scheme;
/**
* The default port is the port that this protocol normally uses.
* If a port does not make sense for the protocol (e.g., "about:")
* then -1 will be returned.
*/
readonly attribute long defaultPort;
/**
* Returns the protocol specific flags (see flag definitions below).
*/
readonly attribute unsigned long protocolFlags;
%{C++
// Helper method to get the protocol flags in the right way.
nsresult DoGetProtocolFlags(nsIURI* aURI, uint32_t* aFlags)
{
nsCOMPtr<nsIProtocolHandlerWithDynamicFlags> dh = do_QueryInterface(this);
nsresult rv = dh ? dh->GetFlagsForURI(aURI, aFlags) : GetProtocolFlags(aFlags);
if (NS_SUCCEEDED(rv)) {
#ifdef DEBUG
if (dh) {
uint32_t staticFlags;
MOZ_ASSERT(NS_SUCCEEDED(GetProtocolFlags(&staticFlags)));
MOZ_ASSERT((staticFlags & ~nsIProtocolHandler::DYNAMIC_URI_FLAGS) ==
(*aFlags & ~nsIProtocolHandler::DYNAMIC_URI_FLAGS),
"only DYNAMIC_URI_FLAGS may be changed by a "
"nsIProtocolHandlerWithDynamicFlags implementation");
}
#endif
#if !IS_ORIGIN_IS_FULL_SPEC_DEFINED
MOZ_RELEASE_ASSERT(!(*aFlags & nsIProtocolHandler::ORIGIN_IS_FULL_SPEC),
"ORIGIN_IS_FULL_SPEC is unsupported but used");
#endif
}
return rv;
}
%}
/**
* Constructs a new channel from the given URI for this protocol handler and
* sets the loadInfo for the constructed channel.

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

@ -73,23 +73,11 @@ nsAboutProtocolHandler::GetScheme(nsACString& result) {
return NS_OK;
}
NS_IMETHODIMP
nsAboutProtocolHandler::GetDefaultPort(int32_t* result) {
*result = -1; // no port for about: URLs
return NS_OK;
}
NS_IMETHODIMP
nsAboutProtocolHandler::GetProtocolFlags(uint32_t* result) {
*result = URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD |
URI_SCHEME_NOT_SELF_LINKABLE;
return NS_OK;
}
NS_IMETHODIMP
nsAboutProtocolHandler::GetFlagsForURI(nsIURI* aURI, uint32_t* aFlags) {
// First use the default (which is "unsafe for content"):
GetProtocolFlags(aFlags);
*aFlags = URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD |
URI_SCHEME_NOT_SELF_LINKABLE;
// Now try to see if this URI overrides the default:
nsCOMPtr<nsIAboutModule> aboutMod;
@ -259,19 +247,6 @@ nsSafeAboutProtocolHandler::GetScheme(nsACString& result) {
return NS_OK;
}
NS_IMETHODIMP
nsSafeAboutProtocolHandler::GetDefaultPort(int32_t* result) {
*result = -1; // no port for moz-safe-about: URLs
return NS_OK;
}
NS_IMETHODIMP
nsSafeAboutProtocolHandler::GetProtocolFlags(uint32_t* result) {
*result = URI_NORELATIVE | URI_NOAUTH | URI_LOADABLE_BY_ANYONE |
URI_IS_POTENTIALLY_TRUSTWORTHY;
return NS_OK;
}
NS_IMETHODIMP
nsSafeAboutProtocolHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
nsIChannel** result) {

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

@ -34,21 +34,6 @@ nsDataHandler::GetScheme(nsACString& result) {
return NS_OK;
}
NS_IMETHODIMP
nsDataHandler::GetDefaultPort(int32_t* result) {
// no ports for data protocol
*result = -1;
return NS_OK;
}
NS_IMETHODIMP
nsDataHandler::GetProtocolFlags(uint32_t* result) {
*result = URI_NORELATIVE | URI_NOAUTH | URI_INHERITS_SECURITY_CONTEXT |
URI_LOADABLE_BY_ANYONE | URI_NON_PERSISTABLE |
URI_IS_LOCAL_RESOURCE | URI_SYNC_LOAD_IS_OK;
return NS_OK;
}
/* static */ nsresult nsDataHandler::CreateNewURI(const nsACString& aSpec,
const char* aCharset,
nsIURI* aBaseURI,

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

@ -164,19 +164,6 @@ nsFileProtocolHandler::GetScheme(nsACString& result) {
return NS_OK;
}
NS_IMETHODIMP
nsFileProtocolHandler::GetDefaultPort(int32_t* result) {
*result = -1; // no port for file: URLs
return NS_OK;
}
NS_IMETHODIMP
nsFileProtocolHandler::GetProtocolFlags(uint32_t* result) {
*result = URI_NOAUTH | URI_IS_LOCAL_FILE | URI_IS_LOCAL_RESOURCE |
URI_IS_POTENTIALLY_TRUSTWORTHY;
return NS_OK;
}
NS_IMETHODIMP
nsFileProtocolHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
nsIChannel** result) {

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

@ -906,19 +906,6 @@ nsGIOProtocolHandler::GetScheme(nsACString& aScheme) {
return NS_OK;
}
NS_IMETHODIMP
nsGIOProtocolHandler::GetDefaultPort(int32_t* aDefaultPort) {
*aDefaultPort = -1;
return NS_OK;
}
NS_IMETHODIMP
nsGIOProtocolHandler::GetProtocolFlags(uint32_t* aProtocolFlags) {
// Is URI_STD true of all GnomeVFS URI types?
*aProtocolFlags = URI_STD | URI_DANGEROUS_TO_LOAD;
return NS_OK;
}
static bool IsValidGIOScheme(const nsACString& aScheme) {
// Verify that GIO supports this URI scheme.
GVfs* gvfs = g_vfs_get_default();

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

@ -1894,18 +1894,6 @@ nsHttpHandler::GetScheme(nsACString& aScheme) {
return NS_OK;
}
NS_IMETHODIMP
nsHttpHandler::GetDefaultPort(int32_t* result) {
*result = NS_HTTP_DEFAULT_PORT;
return NS_OK;
}
NS_IMETHODIMP
nsHttpHandler::GetProtocolFlags(uint32_t* result) {
*result = NS_HTTP_PROTOCOL_FLAGS;
return NS_OK;
}
NS_IMETHODIMP
nsHttpHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
nsIChannel** result) {
@ -2416,18 +2404,6 @@ nsHttpsHandler::GetScheme(nsACString& aScheme) {
return NS_OK;
}
NS_IMETHODIMP
nsHttpsHandler::GetDefaultPort(int32_t* aPort) {
*aPort = NS_HTTPS_DEFAULT_PORT;
return NS_OK;
}
NS_IMETHODIMP
nsHttpsHandler::GetProtocolFlags(uint32_t* aProtocolFlags) {
*aProtocolFlags = NS_HTTP_PROTOCOL_FLAGS | URI_IS_POTENTIALLY_TRUSTWORTHY;
return NS_OK;
}
NS_IMETHODIMP
nsHttpsHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
nsIChannel** _retval) {

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

@ -395,9 +395,7 @@ ExtensionProtocolHandler::GetSingleton() {
}
ExtensionProtocolHandler::ExtensionProtocolHandler()
: SubstitutingProtocolHandler(
EXTENSION_SCHEME,
URI_STD | URI_IS_LOCAL_RESOURCE | URI_IS_POTENTIALLY_TRUSTWORTHY) {
: SubstitutingProtocolHandler(EXTENSION_SCHEME) {
// Note, extensions.webextensions.protocol.remote=false is for
// debugging purposes only. With process-level sandboxing, child
// processes (specifically content and extension processes), will
@ -414,8 +412,8 @@ static inline ExtensionPolicyService& EPS() {
nsresult ExtensionProtocolHandler::GetFlagsForURI(nsIURI* aURI,
uint32_t* aFlags) {
uint32_t flags;
GetProtocolFlags(&flags);
uint32_t flags =
URI_STD | URI_IS_LOCAL_RESOURCE | URI_IS_POTENTIALLY_TRUSTWORTHY;
URLInfo url(aURI);
if (auto* policy = EPS().GetByURL(url)) {

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

@ -70,10 +70,7 @@ PageThumbProtocolHandler::GetSingleton() {
// A moz-page-thumb URI is only loadable by chrome pages in the parent process,
// or privileged content running in the privileged about content process.
PageThumbProtocolHandler::PageThumbProtocolHandler()
: SubstitutingProtocolHandler(PAGE_THUMB_SCHEME,
URI_STD | URI_IS_UI_RESOURCE |
URI_IS_LOCAL_RESOURCE | URI_NORELATIVE |
URI_NOAUTH) {}
: SubstitutingProtocolHandler(PAGE_THUMB_SCHEME) {}
RefPtr<RemoteStreamPromise> PageThumbProtocolHandler::NewStream(
nsIURI* aChildURI, bool* aTerminateSender) {

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

@ -204,10 +204,8 @@ NS_IMPL_CI_INTERFACE_GETTER(SubstitutingJARURI, nsIURI, nsIJARURI, nsIURL,
nsIStandardURL, nsISerializable)
SubstitutingProtocolHandler::SubstitutingProtocolHandler(const char* aScheme,
uint32_t aFlags,
bool aEnforceFileOrJar)
: mScheme(aScheme),
mFlags(aFlags),
mSubstitutionsLock("SubstitutingProtocolHandler::mSubstitutions"),
mSubstitutions(16),
mEnforceFileOrJar(aEnforceFileOrJar) {
@ -282,16 +280,6 @@ nsresult SubstitutingProtocolHandler::GetScheme(nsACString& result) {
return NS_OK;
}
nsresult SubstitutingProtocolHandler::GetDefaultPort(int32_t* result) {
*result = -1;
return NS_OK;
}
nsresult SubstitutingProtocolHandler::GetProtocolFlags(uint32_t* result) {
*result = mFlags;
return NS_OK;
}
nsresult SubstitutingProtocolHandler::NewURI(const nsACString& aSpec,
const char* aCharset,
nsIURI* aBaseURI,

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

@ -28,8 +28,8 @@ namespace net {
// to properly invoke CollectSubstitutions at the right time.
class SubstitutingProtocolHandler {
public:
SubstitutingProtocolHandler(const char* aScheme, uint32_t aFlags,
bool aEnforceFileOrJar = true);
explicit SubstitutingProtocolHandler(const char* aScheme,
bool aEnforceFileOrJar = true);
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SubstitutingProtocolHandler);
NS_DECL_NON_VIRTUAL_NSIPROTOCOLHANDLER;
@ -100,7 +100,6 @@ class SubstitutingProtocolHandler {
void NotifyObservers(const nsACString& aRoot, nsIURI* aBaseURI);
nsCString mScheme;
uint32_t mFlags;
RWLock mSubstitutionsLock;
nsTHashMap<nsCStringHashKey, SubstitutionEntry> mSubstitutions

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

@ -28,8 +28,6 @@ class nsResProtocolHandler final
nsResProtocolHandler()
: mozilla::net::SubstitutingProtocolHandler(
"resource",
URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE |
URI_IS_POTENTIALLY_TRUSTWORTHY,
/* aEnforceFileOrJar = */ false) {}
NS_IMETHOD SetSubstitution(const nsACString& aRoot,

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

@ -31,18 +31,6 @@ nsViewSourceHandler::GetScheme(nsACString& result) {
return NS_OK;
}
NS_IMETHODIMP
nsViewSourceHandler::GetDefaultPort(int32_t* result) {
*result = -1;
return NS_OK;
}
NS_IMETHODIMP
nsViewSourceHandler::GetProtocolFlags(uint32_t* result) {
*result = DEFAULT_FLAGS;
return NS_OK;
}
NS_IMETHODIMP
nsViewSourceHandler::GetFlagsForURI(nsIURI* aURI, uint32_t* result) {
*result = DEFAULT_FLAGS;

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

@ -288,31 +288,6 @@ BaseWebSocketChannel::GetScheme(nsACString& aScheme) {
return NS_OK;
}
NS_IMETHODIMP
BaseWebSocketChannel::GetDefaultPort(int32_t* aDefaultPort) {
LOG(("BaseWebSocketChannel::GetDefaultPort() %p\n", this));
if (mEncrypted) {
*aDefaultPort = kDefaultWSSPort;
} else {
*aDefaultPort = kDefaultWSPort;
}
return NS_OK;
}
NS_IMETHODIMP
BaseWebSocketChannel::GetProtocolFlags(uint32_t* aProtocolFlags) {
LOG(("BaseWebSocketChannel::GetProtocolFlags() %p\n", this));
*aProtocolFlags = URI_NORELATIVE | URI_NON_PERSISTABLE | ALLOWS_PROXY |
ALLOWS_PROXY_HTTP | URI_DOES_NOT_RETURN_DATA |
URI_DANGEROUS_TO_LOAD;
if (mEncrypted) {
*aProtocolFlags |= URI_IS_POTENTIALLY_TRUSTWORTHY;
}
return NS_OK;
}
NS_IMETHODIMP
BaseWebSocketChannel::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
nsIChannel** outChannel) {

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

@ -181,18 +181,6 @@ NS_IMETHODIMP PageIconProtocolHandler::GetScheme(nsACString& aScheme) {
return NS_OK;
}
NS_IMETHODIMP PageIconProtocolHandler::GetDefaultPort(int32_t* aPort) {
*aPort = -1;
return NS_OK;
}
NS_IMETHODIMP PageIconProtocolHandler::GetProtocolFlags(uint32_t* aFlags) {
*aFlags = URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE |
URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP PageIconProtocolHandler::AllowPort(int32_t, const char*,
bool* aAllow) {
*aAllow = false;

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

@ -254,25 +254,6 @@ nsAnnoProtocolHandler::GetScheme(nsACString& aScheme) {
return NS_OK;
}
// nsAnnoProtocolHandler::GetDefaultPort
//
// There is no default port for annotation URLs
NS_IMETHODIMP
nsAnnoProtocolHandler::GetDefaultPort(int32_t* aDefaultPort) {
*aDefaultPort = -1;
return NS_OK;
}
// nsAnnoProtocolHandler::GetProtocolFlags
NS_IMETHODIMP
nsAnnoProtocolHandler::GetProtocolFlags(uint32_t* aProtocolFlags) {
*aProtocolFlags = (URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD |
URI_IS_LOCAL_RESOURCE);
return NS_OK;
}
// nsAnnoProtocolHandler::NewChannel
//

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

@ -489,11 +489,6 @@ NS_IMETHODIMP nsExternalProtocolHandler::GetScheme(nsACString& aScheme) {
return NS_OK;
}
NS_IMETHODIMP nsExternalProtocolHandler::GetDefaultPort(int32_t* aDefaultPort) {
*aDefaultPort = 0;
return NS_OK;
}
NS_IMETHODIMP
nsExternalProtocolHandler::AllowPort(int32_t port, const char* scheme,
bool* _retval) {
@ -518,13 +513,6 @@ bool nsExternalProtocolHandler::HaveExternalProtocolHandler(nsIURI* aURI) {
return haveHandler;
}
NS_IMETHODIMP nsExternalProtocolHandler::GetProtocolFlags(uint32_t* aUritype) {
// Make it norelative since it is a simple uri
*aUritype = URI_NORELATIVE | URI_NOAUTH | URI_LOADABLE_BY_ANYONE |
URI_NON_PERSISTABLE | URI_DOES_NOT_RETURN_DATA;
return NS_OK;
}
NS_IMETHODIMP
nsExternalProtocolHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
nsIChannel** aRetval) {