b=109777 Make sure certificate downloading works immediately

r=javi sr=mscott
This commit is contained in:
kaie%netscape.com 2001-11-30 00:07:13 +00:00
Родитель 1c8672d4f4
Коммит 03e1cbc357
4 изменённых файлов: 93 добавлений и 1 удалений

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

@ -1417,6 +1417,9 @@ PSMContentDownloader::OnStopRequest(nsIRequest* request,
PRUint32
getPSMContentType(const char * aContentType)
{
// Don't forget to update RegisterPSMContentListeners in nsNSSModule.cpp
// for every supported content type.
if (!nsCRT::strcasecmp(aContentType, "application/x-x509-ca-cert"))
return PSMContentDownloader::X509_CA_CERT;
else if (!nsCRT::strcasecmp(aContentType, "application/x-x509-server-cert"))
@ -1540,4 +1543,3 @@ PSMContentListener::SetParentContentListener(nsIURIContentListener * aContentLis
mParentContentListener = aContentListener;
return NS_OK;
}

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

@ -44,6 +44,8 @@
#include "nsCMSSecureMessage.h"
#include "nsCMS.h"
#include "nsCertPicker.h"
#include "nsCURILoader.h"
#include "nsICategoryManager.h"
// We must ensure that the nsNSSComponent has been loaded before
// creating any other components.
@ -154,6 +156,56 @@ NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(PR_FALSE, nsCMSMessage)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(PR_FALSE, nsHash)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(PR_FALSE, nsCertPicker)
static NS_METHOD RegisterPSMContentListeners(
nsIComponentManager *aCompMgr,
nsIFile *aPath, const char *registryLocation,
const char *componentType, const nsModuleComponentInfo *info)
{
nsresult rv;
nsCOMPtr<nsICategoryManager> catman =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsXPIDLCString previous;
catman->AddCategoryEntry(
NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY,
"application/x-x509-ca-cert",
info->mContractID, PR_TRUE, PR_TRUE, getter_Copies(previous));
catman->AddCategoryEntry(
NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY,
"application/x-x509-server-cert",
info->mContractID, PR_TRUE, PR_TRUE, getter_Copies(previous));
catman->AddCategoryEntry(
NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY,
"application/x-x509-user-cert",
info->mContractID, PR_TRUE, PR_TRUE, getter_Copies(previous));
catman->AddCategoryEntry(
NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY,
"application/x-x509-email-cert",
info->mContractID, PR_TRUE, PR_TRUE, getter_Copies(previous));
catman->AddCategoryEntry(
NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY,
"application/x-pkcs7-crl",
info->mContractID, PR_TRUE, PR_TRUE, getter_Copies(previous));
catman->AddCategoryEntry(
NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY,
"application/x-x509-crl",
info->mContractID, PR_TRUE, PR_TRUE, getter_Copies(previous));
catman->AddCategoryEntry(
NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY,
"application/pkix-crl",
info->mContractID, PR_TRUE, PR_TRUE, getter_Copies(previous));
return NS_OK;
}
static nsModuleComponentInfo components[] =
{
{
@ -287,6 +339,14 @@ static nsModuleComponentInfo components[] =
NS_CERT_PICKER_CID,
NS_CERT_PICKER_CONTRACTID,
nsCertPickerConstructor
},
{
"PSM Content Listeners",
NS_PSMCONTENTLISTEN_CID,
"@mozilla.org/uriloader/psm-external-content-listener;1",
PSMContentListenerConstructor,
RegisterPSMContentListeners
}
};

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

@ -54,4 +54,6 @@ nsIURILoader
#define NS_CONTENT_HANDLER_CONTRACTID "@mozilla.org/uriloader/content-handler;1"
#define NS_CONTENT_HANDLER_CONTRACTID_PREFIX NS_CONTENT_HANDLER_CONTRACTID "?type="
#define NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY "external-uricontentlisteners"
%}

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

@ -65,6 +65,7 @@
#include "nsIDOMWindowInternal.h"
#include "nsDOMError.h"
#include "nsICategoryManager.h"
#include "nsCExternalHandlerService.h" // contains contractids for the helper app service
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
@ -759,6 +760,33 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType,
return rv;
}
// Try to find a content listener, that had not yet the chance to register,
// as it is contained in a not-yet-loaded module, but which has registered a contract ID.
nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
if (catman)
{
// see if someone has registered a content listener for aContentType with the category manager...
nsXPIDLCString contractidString;
rv = catman->GetCategoryEntry(NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY,
aContentType, getter_Copies(contractidString));
if (NS_SUCCEEDED(rv) && contractidString.get())
{
nsCOMPtr<nsIURIContentListener> listener;
listener = do_CreateInstance(contractidString.get(), &rv);
if (NS_SUCCEEDED(rv)) // we did indeed have a content listener for this type!! yippee...
{
foundContentHandler = ShouldHandleContent(listener, aContentType, aIsContentPreferred, aContentTypeToUse);
if (foundContentHandler && listener)
{
*aContentListenerToUse = listener;
NS_IF_ADDREF(*aContentListenerToUse);
return rv;
}
} // if we were able to create a uri content listener...
} // if we got a valid contract ID
} // if we can get the category manager....
// no registered content listeners to handle this type!!! so go to the register
// and get a registered nsIContentHandler for our content type. Hand it off
// to them...