Back to index

lightning-sunbird  0.9+nobinonly
nsModule.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "nsIGenericFactory.h"
00039 #include "nsICategoryManager.h"
00040 #include "rdf.h"
00041 #include "nsXPIDLString.h"
00042 #include "nsCharsetMenu.h"
00043 #include "nsDirectoryViewer.h"
00044 #include "nsFontPackageHandler.h"
00045 #include "nsWindowDataSource.h"
00046 #include "nsRDFCID.h"
00047 
00048 #if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER)
00049 #include "nsAutoComplete.h"
00050 #endif
00051 
00052 #if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER) && !defined(MOZ_MACBROWSER)
00053 #include "nsBookmarksService.h"
00054 #include "nsRelatedLinksHandlerImpl.h"
00055 #include "nsGlobalHistory.h"
00056 #include "nsDocShellCID.h"
00057 #include "nsDownloadManager.h"
00058 #include "nsDownloadProxy.h"
00059 #include "nsAppStartup.h"
00060 #include "nsCommandLineService.h"
00061 #include "nsUserInfo.h"
00062 
00063 #if defined(MOZ_LDAP_XPCOM)
00064 #include "nsLDAPAutoCompleteSession.h"
00065 #endif // defined(MOZ_LDAP_XPCOM)
00066 
00067 #endif // !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER) && !defined(MOZ_MACBROWSER)
00068 
00069 #if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER)
00070 #if defined(ALERTS_SERVICE)
00071 #include "nsAlertsService.h"
00072 #endif
00073 #if defined(XP_WIN)
00074 #include "nsWindowsHooks.h"
00075 #include "nsUrlWidget.h"
00076 #endif // Windows
00077 #endif
00078 
00079 #include "nsBrowserStatusFilter.h"
00080 #include "nsBrowserInstance.h"
00081 #include "nsCURILoader.h"
00082 #include "nsXPFEComponentsCID.h"
00083 
00084 // {9491C382-E3C4-11D2-BDBE-0050040A9B44}
00085 #define NS_GLOBALHISTORY_CID \
00086 { 0x9491c382, 0xe3c4, 0x11d2, { 0xbd, 0xbe, 0x0, 0x50, 0x4, 0xa, 0x9b, 0x44} }
00087 
00088 #define NS_GLOBALHISTORY_DATASOURCE_CONTRACTID \
00089     "@mozilla.org/rdf/datasource;1?name=history"
00090 
00091 // Factory constructors
00092 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHTTPIndex, Init)
00093 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDirectoryViewerFactory)
00094 
00095 #if !defined(MOZ_MACBROWSER)
00096 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontPackageHandler)
00097 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowDataSource, Init)
00098 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserStatusFilter)
00099 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserInstance)
00100 #endif
00101 
00102 #if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER)
00103 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAutoCompleteItem)
00104 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAutoCompleteResults)
00105 #endif
00106 
00107 #if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER) && !defined(MOZ_MACBROWSER)
00108 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(RelatedLinksHandlerImpl, Init)
00109 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsBookmarksService, Init)
00110 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGlobalHistory, Init)
00111 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDownloadManager, Init)
00112 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadProxy)
00113 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCmdLineService)
00114 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppStartup)
00115 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUserInfo)
00116 #if defined(MOZ_LDAP_XPCOM)
00117 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLDAPAutoCompleteSession)
00118 #endif // defined(MOZ_LDAP_XPCOM)
00119 #endif // !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER) && !defined(MOZ_MACBROWSER)
00120 
00121 #if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER)
00122 #if defined(ALERTS_SERVICE)
00123 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAlertsService)
00124 #endif
00125 #if defined(XP_WIN)
00126 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowsHooks)
00127 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUrlWidget, Init)
00128 #endif // Windows
00129 #endif
00130 
00131 #if (!defined(MOZ_XUL_APP)) && !defined(MOZ_MACBROWSER)
00132 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserContentHandler)
00133 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChromeStartupHandler)
00134 #endif
00135 
00136 
00137 static NS_METHOD
00138 RegisterProc(nsIComponentManager *aCompMgr,
00139              nsIFile *aPath,
00140              const char *registryLocation,
00141              const char *componentType,
00142              const nsModuleComponentInfo *info)
00143 {
00144     nsresult rv;
00145     nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
00146     if (NS_FAILED(rv)) return rv;
00147 
00148     // add the MIME types layotu can handle to the handlers category.
00149     // this allows users of layout's viewers (the docshell for example)
00150     // to query the types of viewers layout can create.
00151     return catman->AddCategoryEntry("Gecko-Content-Viewers", "application/http-index-format",
00152                                     "@mozilla.org/xpfe/http-index-format-factory-constructor",
00153                                     PR_TRUE, PR_TRUE, nsnull);
00154 }
00155 
00156 static NS_METHOD
00157 UnregisterProc(nsIComponentManager *aCompMgr,
00158                nsIFile *aPath,
00159                const char *registryLocation,
00160                const nsModuleComponentInfo *info)
00161 {
00162     nsresult rv;
00163     nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
00164     if (NS_FAILED(rv)) return rv;
00165 
00166     return catman->DeleteCategoryEntry("Gecko-Content-Viewers",
00167                                        "application/http-index-format", PR_TRUE);
00168 }
00169 
00170 static NS_METHOD
00171 RegisterWindowDS(nsIComponentManager *aCompMgr,
00172                  nsIFile *aPath,
00173                  const char *registryLocation,
00174                  const char *componentType,
00175                  const nsModuleComponentInfo *info)
00176 {
00177     nsresult rv;
00178     nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
00179     if (NS_FAILED(rv)) return rv;
00180 
00181     return catman->AddCategoryEntry("app-startup", "Window Data Source",
00182                                     "service," NS_RDF_DATASOURCE_CONTRACTID_PREFIX "window-mediator",
00183                                     PR_TRUE, PR_TRUE, nsnull);
00184 }
00185 
00186 static const nsModuleComponentInfo components[] = {
00187    { "Directory Viewer", NS_DIRECTORYVIEWERFACTORY_CID,
00188       "@mozilla.org/xpfe/http-index-format-factory-constructor",
00189       nsDirectoryViewerFactoryConstructor, RegisterProc, UnregisterProc  },
00190     { "Directory Viewer", NS_HTTPINDEX_SERVICE_CID, NS_HTTPINDEX_SERVICE_CONTRACTID,
00191       nsHTTPIndexConstructor },
00192     { "Directory Viewer", NS_HTTPINDEX_SERVICE_CID, NS_HTTPINDEX_DATASOURCE_CONTRACTID,
00193       nsHTTPIndexConstructor },
00194 
00195 #if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER)
00196     { "AutoComplete Search Results", NS_AUTOCOMPLETERESULTS_CID, NS_AUTOCOMPLETERESULTS_CONTRACTID,
00197       nsAutoCompleteResultsConstructor},
00198     { "AutoComplete Search Item", NS_AUTOCOMPLETEITEM_CID, NS_AUTOCOMPLETEITEM_CONTRACTID,
00199       nsAutoCompleteItemConstructor},
00200 #endif
00201 
00202 #if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER) && !defined(MOZ_MACBROWSER)
00203     { "Bookmarks", NS_BOOKMARKS_SERVICE_CID, NS_BOOKMARKS_SERVICE_CONTRACTID,
00204       nsBookmarksServiceConstructor },
00205     { "Bookmarks", NS_BOOKMARKS_SERVICE_CID,
00206       "@mozilla.org/embeddor.implemented/bookmark-charset-resolver;1",
00207       nsBookmarksServiceConstructor },
00208     { "Bookmarks", NS_BOOKMARKS_SERVICE_CID, NS_BOOKMARKS_DATASOURCE_CONTRACTID,
00209       nsBookmarksServiceConstructor },
00210     { "Download Manager", NS_DOWNLOADMANAGER_CID, NS_DOWNLOADMANAGER_CONTRACTID,
00211       nsDownloadManagerConstructor },
00212     { "Download", NS_DOWNLOAD_CID, NS_TRANSFER_CONTRACTID,
00213       nsDownloadProxyConstructor },
00214     { "Global History", NS_GLOBALHISTORY_CID, NS_GLOBALHISTORY2_CONTRACTID,
00215       nsGlobalHistoryConstructor },
00216     { "Global History", NS_GLOBALHISTORY_CID, NS_GLOBALHISTORY_DATASOURCE_CONTRACTID,
00217       nsGlobalHistoryConstructor },
00218     { "Global History", NS_GLOBALHISTORY_CID, NS_GLOBALHISTORY_AUTOCOMPLETE_CONTRACTID,
00219       nsGlobalHistoryConstructor },
00220     { "App Startup Service",
00221       NS_SEAMONKEY_APPSTARTUP_CID,
00222       NS_APPSTARTUP_CONTRACTID,
00223       nsAppStartupConstructor
00224     },
00225     { "CommandLine Service",
00226       NS_COMMANDLINESERVICE_CID,
00227       NS_COMMANDLINESERVICE_CONTRACTID,
00228       nsCmdLineServiceConstructor
00229     },
00230     { "User Info Service",
00231       NS_USERINFO_CID,
00232       NS_USERINFO_CONTRACTID,
00233       nsUserInfoConstructor
00234     },
00235 #if defined(MOZ_LDAP_XPCOM)
00236     { "LDAP Autocomplete Session", NS_LDAPAUTOCOMPLETESESSION_CID,
00237          "@mozilla.org/autocompleteSession;1?type=ldap",
00238          nsLDAPAutoCompleteSessionConstructor },
00239 #endif // defined(MOZ_LDAP_XPCOM)
00240     { "Related Links Handler", NS_RELATEDLINKSHANDLER_CID, NS_RELATEDLINKSHANDLER_CONTRACTID,
00241        RelatedLinksHandlerImplConstructor},
00242 #endif // !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER) && !defined(MOZ_MACBROWSER)
00243 
00244 #if !defined(MOZ_MACBROWSER)
00245     { "nsCharsetMenu", NS_CHARSETMENU_CID,
00246       NS_RDF_DATASOURCE_CONTRACTID_PREFIX NS_CHARSETMENU_PID,
00247       NS_NewCharsetMenu },
00248     { "nsFontPackageHandler", NS_FONTPACKAGEHANDLER_CID,
00249       "@mozilla.org/locale/default-font-package-handler;1",
00250       nsFontPackageHandlerConstructor },
00251     { "nsWindowDataSource",
00252       NS_WINDOWDATASOURCE_CID,
00253       NS_RDF_DATASOURCE_CONTRACTID_PREFIX "window-mediator",
00254       nsWindowDataSourceConstructor, RegisterWindowDS },
00255     { NS_BROWSERSTATUSFILTER_CLASSNAME,
00256       NS_BROWSERSTATUSFILTER_CID,
00257       NS_BROWSERSTATUSFILTER_CONTRACTID,
00258       nsBrowserStatusFilterConstructor
00259     },
00260     { "nsBrowserInstance",
00261       NS_BROWSERINSTANCE_CID,
00262       NS_BROWSERINSTANCE_CONTRACTID,
00263       nsBrowserInstanceConstructor
00264     },
00265 #endif
00266 
00267 #if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER)
00268 #if defined(ALERTS_SERVICE)
00269     { "nsAlertsService", NS_ALERTSSERVICE_CID,
00270       NS_ALERTSERVICE_CONTRACTID, nsAlertsServiceConstructor },
00271 #endif
00272 #if defined(XP_WIN)
00273     { NS_IURLWIDGET_CLASSNAME, NS_IURLWIDGET_CID,
00274       NS_IURLWIDGET_CONTRACTID, nsUrlWidgetConstructor },
00275     { NS_IWINDOWSHOOKS_CLASSNAME, NS_IWINDOWSHOOKS_CID,
00276       NS_IWINDOWSHOOKS_CONTRACTID, nsWindowsHooksConstructor },
00277 #endif // defined(XP_WIN)
00278 #endif
00279 
00280 #if (!defined(MOZ_XUL_APP)) && !defined(MOZ_MACBROWSER)
00281   { "Browser Content Handler",
00282     NS_BROWSERCONTENTHANDLER_CID,
00283     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/html",
00284     nsBrowserContentHandlerConstructor
00285   },
00286   { "Browser Content Handler",
00287     NS_BROWSERCONTENTHANDLER_CID,
00288     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/vnd.mozilla.xul+xml",
00289     nsBrowserContentHandlerConstructor
00290   },
00291 #ifdef MOZ_SVG
00292   { "Browser Content Handler",
00293     NS_BROWSERCONTENTHANDLER_CID,
00294     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/svg+xml",
00295     nsBrowserContentHandlerConstructor
00296   },
00297 #endif // MOZ_SVG
00298   { "Browser Content Handler",
00299     NS_BROWSERCONTENTHANDLER_CID,
00300     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/rdf",
00301     nsBrowserContentHandlerConstructor
00302   },
00303   { "Browser Content Handler",
00304     NS_BROWSERCONTENTHANDLER_CID,
00305     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/xml",
00306     nsBrowserContentHandlerConstructor
00307   },
00308   { "Browser Content Handler",
00309     NS_BROWSERCONTENTHANDLER_CID,
00310     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/xml",
00311     nsBrowserContentHandlerConstructor
00312   },
00313   { "Browser Content Handler",
00314     NS_BROWSERCONTENTHANDLER_CID,
00315     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/xhtml+xml",
00316     nsBrowserContentHandlerConstructor
00317   },
00318   { "Browser Content Handler",
00319     NS_BROWSERCONTENTHANDLER_CID,
00320     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/css",
00321     nsBrowserContentHandlerConstructor
00322   },
00323   { "Browser Content Handler",
00324     NS_BROWSERCONTENTHANDLER_CID,
00325     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/plain",
00326     nsBrowserContentHandlerConstructor
00327   },
00328   { "Browser Content Handler",
00329     NS_BROWSERCONTENTHANDLER_CID,
00330     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/gif",
00331     nsBrowserContentHandlerConstructor
00332   },
00333   { "Browser Content Handler",
00334     NS_BROWSERCONTENTHANDLER_CID,
00335     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/jpeg",
00336     nsBrowserContentHandlerConstructor
00337   },
00338   { "Browser Content Handler",
00339     NS_BROWSERCONTENTHANDLER_CID,
00340     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/jpg",
00341     nsBrowserContentHandlerConstructor
00342   },
00343   { "Browser Content Handler",
00344     NS_BROWSERCONTENTHANDLER_CID,
00345     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/png",
00346     nsBrowserContentHandlerConstructor
00347   },
00348   { "Browser Content Handler",
00349     NS_BROWSERCONTENTHANDLER_CID,
00350     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/bmp",
00351     nsBrowserContentHandlerConstructor
00352   },
00353   { "Browser Content Handler",
00354     NS_BROWSERCONTENTHANDLER_CID,
00355     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/x-icon",
00356     nsBrowserContentHandlerConstructor
00357   },
00358   { "Browser Content Handler",
00359     NS_BROWSERCONTENTHANDLER_CID,
00360     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/vnd.microsoft.icon",
00361     nsBrowserContentHandlerConstructor
00362   },
00363   { "Browser Content Handler",
00364     NS_BROWSERCONTENTHANDLER_CID,
00365     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"image/x-xbitmap",
00366     nsBrowserContentHandlerConstructor
00367   },
00368   { "Browser Content Handler",
00369     NS_BROWSERCONTENTHANDLER_CID,
00370     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/http-index-format",
00371     nsBrowserContentHandlerConstructor
00372   },
00373   { "Browser Startup Handler",
00374     NS_BROWSERCONTENTHANDLER_CID,
00375     NS_BROWSERSTARTUPHANDLER_CONTRACTID,
00376     nsBrowserContentHandlerConstructor,
00377     nsBrowserContentHandler::RegisterProc,
00378     nsBrowserContentHandler::UnregisterProc,
00379   },
00380   { "Chrome Startup Handler",
00381     NS_CHROMESTARTUPHANDLER_CID,
00382     NS_CHROMESTARTUPHANDLER_CONTRACTID,
00383     nsChromeStartupHandlerConstructor,
00384     nsChromeStartupHandler::RegisterProc,
00385     nsChromeStartupHandler::UnregisterProc
00386   },
00387 #endif //!defined(MOZ_XUL_APP) && !defined(MOZ_MACBROWSER)
00388 };
00389 
00390 NS_IMPL_NSGETMODULE(application, components)