зеркало из https://github.com/mozilla/pjs.git
Added chrome protocol handler for necko.
This commit is contained in:
Родитель
82e55d7a09
Коммит
f51b095d63
|
@ -22,10 +22,16 @@
|
|||
#include "nsIChromeRegistry.h"
|
||||
#include "nscore.h"
|
||||
#include "rdf.h"
|
||||
#ifdef NECKO
|
||||
#include "nsChromeProtocolHandler.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||
#ifdef NECKO
|
||||
static NS_DEFINE_CID(kChromeProtocolHandlerCID, NS_CHROMEPROTOCOLHANDLER_CID);
|
||||
#endif
|
||||
|
||||
static NS_IMETHODIMP
|
||||
NS_ConstructChromeRegistry(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
|
@ -53,25 +59,23 @@ NSGetFactory(nsISupports* aServMgr,
|
|||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aFactory != nsnull, "bad factory pointer");
|
||||
NS_ASSERTION(aClass.Equals(kChromeRegistryCID), "incorrectly registered");
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIGenericFactory* factory;
|
||||
rv = compMgr->CreateInstance(kGenericFactoryCID, nsnull, nsIGenericFactory::GetIID(),
|
||||
(void**)&factory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = factory->SetConstructor(NS_ConstructChromeRegistry);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete factory;
|
||||
return rv;
|
||||
nsIGenericFactory* fact;
|
||||
if (aClass.Equals(kChromeRegistryCID)) {
|
||||
rv = NS_NewGenericFactory(&fact, NS_ConstructChromeRegistry);
|
||||
}
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
#ifdef NECKO
|
||||
else if (aClass.Equals(kChromeProtocolHandlerCID)) {
|
||||
rv = NS_NewGenericFactory(&fact, nsChromeProtocolHandler::Create);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*aFactory = fact;
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
|
@ -88,7 +92,14 @@ NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
|||
NS_RDF_DATASOURCE_PROGID_PREFIX "chrome",
|
||||
aPath,
|
||||
PR_TRUE, PR_TRUE);
|
||||
#ifdef NECKO
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kChromeProtocolHandlerCID,
|
||||
"Chrome Protocol Handler",
|
||||
NS_NETWORK_PROTOCOL_PROGID_PREFIX "chrome",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -101,7 +112,11 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kChromeRegistryCID, aPath);
|
||||
#ifdef NECKO
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kChromeProtocolHandlerCID, aPath);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,9 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
nsIURL* url = nsnull;
|
||||
rv = aChromeURL->QueryInterface(nsIURL::GetIID(), (void**)&url);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
(void)url->GetQuery(&file);
|
||||
rv = url->GetQuery(&file);
|
||||
if (NS_FAILED(rv))
|
||||
file = nsCRT::strdup("");
|
||||
NS_RELEASE(url);
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -26,6 +26,8 @@ CPP_OBJS=\
|
|||
.\$(OBJDIR)\nsChromeFactory.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS = $(LINCS) -I..\src # for implementation headers
|
||||
|
||||
# XXX linking in raptor is a heinous crime that will go away once we
|
||||
# have a more DOM-based mechanism for constructing elements and
|
||||
# hooking in to their changes.
|
||||
|
|
|
@ -22,10 +22,16 @@
|
|||
#include "nsIChromeRegistry.h"
|
||||
#include "nscore.h"
|
||||
#include "rdf.h"
|
||||
#ifdef NECKO
|
||||
#include "nsChromeProtocolHandler.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||
#ifdef NECKO
|
||||
static NS_DEFINE_CID(kChromeProtocolHandlerCID, NS_CHROMEPROTOCOLHANDLER_CID);
|
||||
#endif
|
||||
|
||||
static NS_IMETHODIMP
|
||||
NS_ConstructChromeRegistry(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
|
@ -53,25 +59,23 @@ NSGetFactory(nsISupports* aServMgr,
|
|||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aFactory != nsnull, "bad factory pointer");
|
||||
NS_ASSERTION(aClass.Equals(kChromeRegistryCID), "incorrectly registered");
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIGenericFactory* factory;
|
||||
rv = compMgr->CreateInstance(kGenericFactoryCID, nsnull, nsIGenericFactory::GetIID(),
|
||||
(void**)&factory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = factory->SetConstructor(NS_ConstructChromeRegistry);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete factory;
|
||||
return rv;
|
||||
nsIGenericFactory* fact;
|
||||
if (aClass.Equals(kChromeRegistryCID)) {
|
||||
rv = NS_NewGenericFactory(&fact, NS_ConstructChromeRegistry);
|
||||
}
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
#ifdef NECKO
|
||||
else if (aClass.Equals(kChromeProtocolHandlerCID)) {
|
||||
rv = NS_NewGenericFactory(&fact, nsChromeProtocolHandler::Create);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*aFactory = fact;
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
|
@ -88,7 +92,14 @@ NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
|||
NS_RDF_DATASOURCE_PROGID_PREFIX "chrome",
|
||||
aPath,
|
||||
PR_TRUE, PR_TRUE);
|
||||
#ifdef NECKO
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kChromeProtocolHandlerCID,
|
||||
"Chrome Protocol Handler",
|
||||
NS_NETWORK_PROTOCOL_PROGID_PREFIX "chrome",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -101,7 +112,11 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kChromeRegistryCID, aPath);
|
||||
#ifdef NECKO
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kChromeProtocolHandlerCID, aPath);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ LIBRARY_NAME = chrome_s
|
|||
|
||||
CPPSRCS = \
|
||||
nsChromeRegistry.cpp \
|
||||
nsChromeProtocolHandler.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
|
|
@ -21,6 +21,7 @@ LIBRARY_NAME=chrome_s
|
|||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsChromeRegistry.obj \
|
||||
.\$(OBJDIR)\nsChromeProtocolHandler.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -263,7 +263,9 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
nsIURL* url = nsnull;
|
||||
rv = aChromeURL->QueryInterface(nsIURL::GetIID(), (void**)&url);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
(void)url->GetQuery(&file);
|
||||
rv = url->GetQuery(&file);
|
||||
if (NS_FAILED(rv))
|
||||
file = nsCRT::strdup("");
|
||||
NS_RELEASE(url);
|
||||
}
|
||||
#else
|
||||
|
|
Загрузка…
Ссылка в новой задаче