Blocked protocols should still allow URI creation; they should just fail
channel creation. Bug 244220, r+sr=darin git-svn-id: svn://10.0.0.236/trunk@156677 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -67,6 +67,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDocLoaderImpl, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsOSHelperAppService, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalProtocolHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlockedExternalProtocolHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefetchService, Init)
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
@@ -112,6 +113,8 @@ static const nsModuleComponentInfo gDocShellModuleInfo[] = {
|
||||
nsOSHelperAppServiceConstructor, },
|
||||
{ "Netscape Default Protocol Handler", NS_EXTERNALPROTOCOLHANDLER_CID, NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default",
|
||||
nsExternalProtocolHandlerConstructor, },
|
||||
{ "Netscape Default Blocked Protocol Handler", NS_BLOCKEDEXTERNALPROTOCOLHANDLER_CID, NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default-blocked",
|
||||
nsBlockedExternalProtocolHandlerConstructor, },
|
||||
{ NS_PREFETCHSERVICE_CLASSNAME, NS_PREFETCHSERVICE_CID, NS_PREFETCHSERVICE_CONTRACTID,
|
||||
nsPrefetchServiceConstructor, },
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
|
||||
@@ -333,45 +333,51 @@ nsIOService::GetProtocolHandler(const char* scheme, nsIProtocolHandler* *result)
|
||||
ToLowerCase(contractID);
|
||||
|
||||
rv = CallGetService(contractID.get(), result);
|
||||
|
||||
// If the pref for this protocol was explicitly set to false,
|
||||
// stop here and do not invoke the default handler.
|
||||
if (NS_FAILED(rv) && listedProtocol)
|
||||
return NS_ERROR_UNKNOWN_PROTOCOL;
|
||||
}
|
||||
|
||||
if (externalProtocol || NS_FAILED(rv)) {
|
||||
|
||||
// If the pref for this protocol was explicitly set to false, we want to
|
||||
// use our special "blocked protocol" handler. That will ensure we don't
|
||||
// open any channels for this protocol.
|
||||
if (listedProtocol) {
|
||||
rv = CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default-blocked",
|
||||
result);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_UNKNOWN_PROTOCOL;
|
||||
}
|
||||
else {
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// check to see whether GnomeVFS can handle this URI scheme. if it can
|
||||
// create a nsIURI for the "scheme:", then we assume it has support for
|
||||
// the requested protocol. otherwise, we failover to using the default
|
||||
// protocol handler.
|
||||
|
||||
// check to see if GnomeVFS can handle this URI scheme. if it can create
|
||||
// a nsIURI for the "scheme:", then we assume it has support for the
|
||||
// requested protocol. otherwise, we failover to using the default
|
||||
// protocol handler.
|
||||
// XXX should this be generalized into something that searches a
|
||||
// category? (see bug 234714)
|
||||
|
||||
// XXX should this be generalized into something that searches a category?
|
||||
// (see bug 234714)
|
||||
|
||||
rv = CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"moz-gnomevfs",
|
||||
result);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"moz-gnomevfs",
|
||||
result);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCAutoString spec(scheme);
|
||||
spec.Append(':');
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = (*result)->NewURI(spec, nsnull, nsnull, getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
NS_RELEASE(*result);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
// okay we don't have a protocol handler to handle this url type, so use the default protocol handler.
|
||||
// this will cause urls to get dispatched out to the OS ('cause we can't do anything with them) when
|
||||
// we try to read from a channel created by the default protocol handler.
|
||||
// Okay we don't have a protocol handler to handle this url type, so use
|
||||
// the default protocol handler. This will cause urls to get dispatched
|
||||
// out to the OS ('cause we can't do anything with them) when we try to
|
||||
// read from a channel created by the default protocol handler.
|
||||
|
||||
rv = CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default",
|
||||
result);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_UNKNOWN_PROTOCOL;
|
||||
rv = CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default",
|
||||
result);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_UNKNOWN_PROTOCOL;
|
||||
}
|
||||
}
|
||||
|
||||
CacheProtocolHandler(scheme, *result);
|
||||
|
||||
@@ -63,6 +63,9 @@ nsIExternalHelperAppService
|
||||
#define NS_EXTERNALPROTOCOLHANDLER_CID \
|
||||
{ 0xbd6390c8, 0xfbea, 0x11d4, {0x98, 0xf6, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } }
|
||||
|
||||
/* 9fa83ce7-d0ab-4ed3-938e-afafee435670 */
|
||||
#define NS_BLOCKEDEXTERNALPROTOCOLHANDLER_CID \
|
||||
{ 0x9fa83ce7, 0xd0ab, 0x4ed3, {0x93, 0x8e, 0xaf, 0xaf, 0xee, 0x43, 0x56, 0x70 } }
|
||||
|
||||
%}
|
||||
|
||||
|
||||
@@ -393,3 +393,16 @@ NS_IMETHODIMP nsExternalProtocolHandler::ExternalAppExistsForScheme(const nsACSt
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsBlockedExternalProtocolHandler::nsBlockedExternalProtocolHandler()
|
||||
{
|
||||
m_schemeName = "default-blocked";
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBlockedExternalProtocolHandler::NewChannel(nsIURI *aURI,
|
||||
nsIChannel **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_UNKNOWN_PROTOCOL;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,12 @@ protected:
|
||||
nsCOMPtr<nsIExternalProtocolService> m_extProtService;
|
||||
};
|
||||
|
||||
class nsBlockedExternalProtocolHandler: public nsExternalProtocolHandler
|
||||
{
|
||||
public:
|
||||
nsBlockedExternalProtocolHandler();
|
||||
NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel **_retval);
|
||||
};
|
||||
|
||||
#endif // nsExternalProtocolHandler_h___
|
||||
|
||||
|
||||
Reference in New Issue
Block a user