From eb04da966bfc60ed368fc6f774e7a1fd3b9c2841 Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Tue, 23 Jul 2002 23:30:04 +0000 Subject: [PATCH] more prep for bug 119923 - use chrome registry ContractID rather than CID, so that we can drop in a new embedding-only chrome registry r=bnesse, sr=dveditz, a=asa --- chrome/public/nsIChromeRegistry.idl | 7 ++---- chrome/src/nsChromeFactory.cpp | 2 +- chrome/src/nsChromeProtocolHandler.cpp | 3 +-- chrome/src/nsChromeRegistry.h | 6 ++++++ content/xbl/src/nsXBLDocumentInfo.cpp | 4 +--- content/xul/document/src/nsXULDocument.cpp | 6 +++--- editor/composer/src/nsEditorShell.cpp | 3 +-- profile/src/nsProfile.cpp | 10 +++++---- rdf/chrome/build/nsChromeFactory.cpp | 2 +- rdf/chrome/public/nsIChromeRegistry.idl | 7 ++---- rdf/chrome/src/nsChromeProtocolHandler.cpp | 3 +-- rdf/chrome/src/nsChromeRegistry.h | 6 ++++++ xpcom/proxy/public/nsProxiedService.h | 25 ++++++++++++++++------ xpfe/bootstrap/nsAppRunner.cpp | 12 +++++------ xpinstall/src/nsSoftwareUpdate.cpp | 5 ++--- 15 files changed, 57 insertions(+), 44 deletions(-) diff --git a/chrome/public/nsIChromeRegistry.idl b/chrome/public/nsIChromeRegistry.idl index 6faf3a90439..551314d00ea 100644 --- a/chrome/public/nsIChromeRegistry.idl +++ b/chrome/public/nsIChromeRegistry.idl @@ -157,9 +157,6 @@ interface nsIXULChromeRegistry : nsIChromeRegistry { %{ C++ -// for component registration -// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627} -#define NS_CHROMEREGISTRY_CID \ -{ 0xd8c7d8a2, 0xe84c, 0x11d2, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } - +#define NS_CHROMEREGISTRY_CONTRACTID \ + "@mozilla.org/chrome/chrome-registry;1" %} diff --git a/chrome/src/nsChromeFactory.cpp b/chrome/src/nsChromeFactory.cpp index 7273ea1bf8d..bb011283e4e 100644 --- a/chrome/src/nsChromeFactory.cpp +++ b/chrome/src/nsChromeFactory.cpp @@ -54,7 +54,7 @@ static const nsModuleComponentInfo components[] = { { "Chrome Registry", NS_CHROMEREGISTRY_CID, - "@mozilla.org/chrome/chrome-registry;1", + NS_CHROMEREGISTRY_CONTRACTID, nsChromeRegistryConstructor }, diff --git a/chrome/src/nsChromeProtocolHandler.cpp b/chrome/src/nsChromeProtocolHandler.cpp index fca807551cc..387f4f3d023 100644 --- a/chrome/src/nsChromeProtocolHandler.cpp +++ b/chrome/src/nsChromeProtocolHandler.cpp @@ -72,7 +72,6 @@ //---------------------------------------------------------------------- -static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); @@ -593,7 +592,7 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI, // Canonify the "chrome:" URL; e.g., so that we collapse // "chrome://navigator/content/navigator.xul" and "chrome://navigator/content" // and "chrome://navigator/content/navigator.xul". - nsCOMPtr reg(do_GetService(kChromeRegistryCID, &rv)); + nsCOMPtr reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; rv = reg->Canonify(aURI); diff --git a/chrome/src/nsChromeRegistry.h b/chrome/src/nsChromeRegistry.h index 78578171379..433d9b417e6 100644 --- a/chrome/src/nsChromeRegistry.h +++ b/chrome/src/nsChromeRegistry.h @@ -54,6 +54,12 @@ class nsIDocument; #include "nsWeakReference.h" #include "nsString.h" + +// for component registration +// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627} +#define NS_CHROMEREGISTRY_CID \ +{ 0xd8c7d8a2, 0xe84c, 0x11d2, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } + class nsChromeRegistry : public nsIXULChromeRegistry, public nsIObserver, public nsSupportsWeakReference diff --git a/content/xbl/src/nsXBLDocumentInfo.cpp b/content/xbl/src/nsXBLDocumentInfo.cpp index 13008b5e856..ea44c9e4809 100644 --- a/content/xbl/src/nsXBLDocumentInfo.cpp +++ b/content/xbl/src/nsXBLDocumentInfo.cpp @@ -355,8 +355,6 @@ static PRBool IsChromeOrResourceURI(nsIURI* aURI) /* Implementation file */ NS_IMPL_ISUPPORTS3(nsXBLDocumentInfo, nsIXBLDocumentInfo, nsIScriptGlobalObjectOwner, nsISupportsWeakReference) -static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); - nsXBLDocumentInfo::nsXBLDocumentInfo(const char* aDocURI, nsIDocument* aDocument) { NS_INIT_ISUPPORTS(); @@ -370,7 +368,7 @@ nsXBLDocumentInfo::nsXBLDocumentInfo(const char* aDocURI, nsIDocument* aDocument mDocument->GetDocumentURL(getter_AddRefs(uri)); if (IsChromeOrResourceURI(uri)) { // Cache whether or not this chrome XBL can execute scripts. - nsCOMPtr reg(do_GetService(kChromeRegistryCID)); + nsCOMPtr reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID)); if (reg) { PRBool allow = PR_TRUE; reg->AllowScriptsForSkin(uri, &allow); diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 78bbe6e656b..a4a89f2b176 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -168,7 +168,6 @@ // static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); -static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); static NS_DEFINE_CID(kEventListenerManagerCID, NS_EVENTLISTENERMANAGER_CID); static NS_DEFINE_CID(kHTMLCSSStyleSheetCID, NS_HTML_CSS_STYLESHEET_CID); static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); @@ -1752,7 +1751,8 @@ nsXULDocument::EndLoad() IsChromeURI(uri)) gXULCache->WritePrototype(mCurrentPrototype); - nsCOMPtr reg(do_GetService(kChromeRegistryCID, &rv)); + nsCOMPtr reg = + do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr sheets; @@ -5380,7 +5380,7 @@ nsresult nsXULDocument::AddChromeOverlays() { nsresult rv; - nsCOMPtr reg(do_GetService(kChromeRegistryCID, &rv)); + nsCOMPtr reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv)); if (NS_FAILED(rv)) return NS_ERROR_FAILURE; diff --git a/editor/composer/src/nsEditorShell.cpp b/editor/composer/src/nsEditorShell.cpp index dc6fe2cd78f..af8dd9f237f 100644 --- a/editor/composer/src/nsEditorShell.cpp +++ b/editor/composer/src/nsEditorShell.cpp @@ -132,7 +132,6 @@ static NS_DEFINE_CID(kHTMLEditorCID, NS_HTMLEDITOR_CID); static NS_DEFINE_CID(kCTextServicesDocumentCID, NS_TEXTSERVICESDOCUMENT_CID); static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); -static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); #define APP_DEBUG 0 @@ -3798,7 +3797,7 @@ nsEditorShell::InitSpellChecker() } nsCOMPtr packageRegistry = - do_GetService(kChromeRegistryCID, &result); + do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &result); if (NS_SUCCEEDED(result) && packageRegistry) result = packageRegistry->GetSelectedLocale(NS_LITERAL_STRING("navigator").get(), &dictName); diff --git a/profile/src/nsProfile.cpp b/profile/src/nsProfile.cpp index 1f9e21635d6..30e4fb1d1d6 100644 --- a/profile/src/nsProfile.cpp +++ b/profile/src/nsProfile.cpp @@ -79,6 +79,7 @@ #include "nsIObserverService.h" #include "nsISupportsPrimitives.h" #include "nsHashtable.h" +#include "nsIAtom.h" // Interfaces Needed #include "nsIDocShell.h" @@ -183,7 +184,6 @@ static NS_DEFINE_CID(kPrefMigrationCID, NS_PREFMIGRATION_CID); static NS_DEFINE_CID(kPrefConverterCID, NS_PREFCONVERTER_CID); static NS_DEFINE_IID(kCookieServiceCID, NS_COOKIESERVICE_CID); -static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); @@ -457,7 +457,8 @@ nsProfile::StartupWithArgs(nsICmdLineService *cmdLineArgs, PRBool canInteract) } gLocaleProfiles->Remove(&key); - nsCOMPtr chromeRegistry = do_GetService(kChromeRegistryCID, &rv); + nsCOMPtr chromeRegistry = + do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; // Install to the profile @@ -1621,7 +1622,8 @@ nsProfile::CreateNewProfileWithLocales(const PRUnichar* profileName, rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR, getter_AddRefs(profDefaultsDir)); if (NS_FAILED(rv)) return rv; - nsCOMPtr chromeRegistry = do_GetService(kChromeRegistryCID, &rv); + nsCOMPtr chromeRegistry = + do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { const PRUnichar* uiLocale = aUILocale; @@ -2123,7 +2125,7 @@ nsProfile::DefineLocaleDefaultsDir() if (NS_SUCCEEDED(rv)) { nsCOMPtr packageRegistry = - do_GetService(kChromeRegistryCID, &rv); + do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { nsXPIDLString localeName; diff --git a/rdf/chrome/build/nsChromeFactory.cpp b/rdf/chrome/build/nsChromeFactory.cpp index 7273ea1bf8d..bb011283e4e 100644 --- a/rdf/chrome/build/nsChromeFactory.cpp +++ b/rdf/chrome/build/nsChromeFactory.cpp @@ -54,7 +54,7 @@ static const nsModuleComponentInfo components[] = { { "Chrome Registry", NS_CHROMEREGISTRY_CID, - "@mozilla.org/chrome/chrome-registry;1", + NS_CHROMEREGISTRY_CONTRACTID, nsChromeRegistryConstructor }, diff --git a/rdf/chrome/public/nsIChromeRegistry.idl b/rdf/chrome/public/nsIChromeRegistry.idl index 6faf3a90439..551314d00ea 100644 --- a/rdf/chrome/public/nsIChromeRegistry.idl +++ b/rdf/chrome/public/nsIChromeRegistry.idl @@ -157,9 +157,6 @@ interface nsIXULChromeRegistry : nsIChromeRegistry { %{ C++ -// for component registration -// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627} -#define NS_CHROMEREGISTRY_CID \ -{ 0xd8c7d8a2, 0xe84c, 0x11d2, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } - +#define NS_CHROMEREGISTRY_CONTRACTID \ + "@mozilla.org/chrome/chrome-registry;1" %} diff --git a/rdf/chrome/src/nsChromeProtocolHandler.cpp b/rdf/chrome/src/nsChromeProtocolHandler.cpp index fca807551cc..387f4f3d023 100644 --- a/rdf/chrome/src/nsChromeProtocolHandler.cpp +++ b/rdf/chrome/src/nsChromeProtocolHandler.cpp @@ -72,7 +72,6 @@ //---------------------------------------------------------------------- -static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); @@ -593,7 +592,7 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI, // Canonify the "chrome:" URL; e.g., so that we collapse // "chrome://navigator/content/navigator.xul" and "chrome://navigator/content" // and "chrome://navigator/content/navigator.xul". - nsCOMPtr reg(do_GetService(kChromeRegistryCID, &rv)); + nsCOMPtr reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; rv = reg->Canonify(aURI); diff --git a/rdf/chrome/src/nsChromeRegistry.h b/rdf/chrome/src/nsChromeRegistry.h index 78578171379..433d9b417e6 100644 --- a/rdf/chrome/src/nsChromeRegistry.h +++ b/rdf/chrome/src/nsChromeRegistry.h @@ -54,6 +54,12 @@ class nsIDocument; #include "nsWeakReference.h" #include "nsString.h" + +// for component registration +// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627} +#define NS_CHROMEREGISTRY_CID \ +{ 0xd8c7d8a2, 0xe84c, 0x11d2, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } + class nsChromeRegistry : public nsIXULChromeRegistry, public nsIObserver, public nsSupportsWeakReference diff --git a/xpcom/proxy/public/nsProxiedService.h b/xpcom/proxy/public/nsProxiedService.h index 055938d2970..d8d95cd56a1 100644 --- a/xpcom/proxy/public/nsProxiedService.h +++ b/xpcom/proxy/public/nsProxiedService.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: NPL 1.1/GPL 2.0/LGPL 2.1 * @@ -99,13 +99,27 @@ class nsProxiedService nsProxiedService(const nsCID &aClass, const nsIID &aIID, nsIEventQueue* pIProxyQueue, PRBool always, nsresult*rv) { - static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID); - - *rv = nsServiceManager::GetService(aClass, aIID, getter_AddRefs(mService)); if (NS_FAILED(*rv)) return; + InitProxy(aIID, pIProxyQueue, always, rv); + } + + nsProxiedService(const char* aContractID, const nsIID &aIID, + nsIEventQueue* pIProxyQueue, PRBool always, nsresult*rv) + { + *rv = nsServiceManager::GetService(aContractID, + aIID, + getter_AddRefs(mService)); + if (NS_FAILED(*rv)) return; + InitProxy(aIID, pIProxyQueue, always, rv); + } + + void InitProxy(const nsIID &aIID, nsIEventQueue* pIProxyQueue, + PRBool always, nsresult*rv) + { + static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID); nsCOMPtr pIProxyObjectManager = do_GetService(kProxyObjectManagerCID, rv); @@ -119,8 +133,7 @@ class nsProxiedService proxyType, getter_AddRefs(mProxiedService)); } - - + ~nsProxiedService() { } diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 5f175efc5d7..8d3bb95c957 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -73,7 +73,6 @@ #include "nsIXULWindow.h" #include "nsIChromeRegistry.h" #include "nsIContentHandler.h" -#include "nsIBrowserInstance.h" #include "nsIEventQueueService.h" #include "nsDirectoryServiceDefs.h" #include "nsIHttpProtocolHandler.h" @@ -116,7 +115,6 @@ static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID); -static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); #define UILOCALE_CMD_LINE_ARG "-UILocale" #define CONTENTLOCALE_CMD_LINE_ARG "-contentLocale" @@ -931,7 +929,7 @@ static nsresult ConvertToUnicode(nsString& aCharset, const char* inString, nsASt static nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width) { nsresult rv; - nsCOMPtr handler(do_GetService(NS_BROWSERSTARTUPHANDLER_CONTRACTID, &rv)); + nsCOMPtr handler(do_GetService("@mozilla.org/commandlinehandler/general-startup;1?type=browser", &rv)); if (NS_FAILED(rv)) return rv; nsXPIDLCString chromeUrlForTask; @@ -1116,14 +1114,14 @@ static nsresult InstallGlobalLocale(nsICmdLineService *cmdLineArgs) if (cmdUI) { nsAutoString UILocaleName; UILocaleName.AssignWithConversion(cmdUI); - nsCOMPtr chromeRegistry = do_GetService(kChromeRegistryCID, &rv); + nsCOMPtr chromeRegistry = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); if (chromeRegistry) rv = chromeRegistry->SelectLocale(UILocaleName.get(), PR_FALSE); } } // match OS when no cmdline override if (!cmdUI && matchOS) { - nsCOMPtr chromeRegistry = do_GetService(kChromeRegistryCID, &rv); + nsCOMPtr chromeRegistry = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); if (chromeRegistry) { chromeRegistry->SetRuntimeProvider(PR_TRUE); rv = chromeRegistry->SelectLocale(uiLang.get(), PR_FALSE); @@ -1136,14 +1134,14 @@ static nsresult InstallGlobalLocale(nsICmdLineService *cmdLineArgs) if (cmdContent) { nsAutoString ContentLocaleName; ContentLocaleName.AssignWithConversion(cmdContent); - nsCOMPtr chromeRegistry = do_GetService(kChromeRegistryCID, &rv); + nsCOMPtr chromeRegistry = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); if(chromeRegistry) rv = chromeRegistry->SelectLocale(ContentLocaleName.get(), PR_FALSE); } } // match OS when no cmdline override if (!cmdContent && matchOS) { - nsCOMPtr chromeRegistry = do_GetService(kChromeRegistryCID, &rv); + nsCOMPtr chromeRegistry = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); if (chromeRegistry) { chromeRegistry->SetRuntimeProvider(PR_TRUE); rv = chromeRegistry->SelectLocale(country.get(), PR_FALSE); diff --git a/xpinstall/src/nsSoftwareUpdate.cpp b/xpinstall/src/nsSoftwareUpdate.cpp index f85e9d2374c..7779fc055a2 100644 --- a/xpinstall/src/nsSoftwareUpdate.cpp +++ b/xpinstall/src/nsSoftwareUpdate.cpp @@ -86,7 +86,6 @@ static NS_DEFINE_CID(kInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID); static NS_DEFINE_CID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID); -static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); static NS_DEFINE_CID(knsRegistryCID, NS_REGISTRY_CID); static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID); @@ -315,7 +314,7 @@ nsSoftwareUpdate::InstallJar( nsIFile* aLocalFile, nsIXULChromeRegistry* chromeRegistry = nsnull; NS_WITH_ALWAYS_PROXIED_SERVICE( nsIXULChromeRegistry, tmpReg, - kChromeRegistryCID, + NS_CHROMEREGISTRY_CONTRACTID, NS_UI_THREAD_EVENTQ, &rv); if (NS_SUCCEEDED(rv)) chromeRegistry = tmpReg; @@ -347,7 +346,7 @@ nsSoftwareUpdate::InstallChrome( PRUint32 aType, nsresult rv; NS_WITH_ALWAYS_PROXIED_SERVICE( nsIXULChromeRegistry, chromeRegistry, - kChromeRegistryCID, + NS_CHROMEREGISTRY_CONTRACTID, NS_UI_THREAD_EVENTQ, &rv); if (NS_FAILED(rv)) return rv;