Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / docshell / build / nsDocShellModule.cpp
blob7503fcf42ec5ff8986164fe2476745372445c962
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is the Mozilla browser.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications, Inc.
20 * Portions created by the Initial Developer are Copyright (C) 1999
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Travis Bogard <travis@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #include "nsIModule.h"
41 #include "nsIGenericFactory.h"
43 #include "nsDocShellCID.h"
45 #include "nsWebShell.h"
46 #include "nsDefaultURIFixup.h"
47 #include "nsWebNavigationInfo.h"
49 #include "nsAboutRedirector.h"
51 // uriloader
52 #include "nsURILoader.h"
53 #include "nsDocLoader.h"
54 #include "nsOSHelperAppService.h"
55 #include "nsExternalProtocolHandler.h"
56 #include "nsPrefetchService.h"
57 #include "nsOfflineCacheUpdate.h"
58 #include "nsLocalHandlerApp.h"
59 #ifdef MOZ_ENABLE_DBUS
60 #include "nsDBusHandlerApp.h"
61 #endif
63 // session history
64 #include "nsSHEntry.h"
65 #include "nsSHistory.h"
66 #include "nsSHTransaction.h"
68 // global history
69 #include "nsGlobalHistoryAdapter.h"
70 #include "nsGlobalHistory2Adapter.h"
72 // download history
73 #include "nsDownloadHistory.h"
75 static PRBool gInitialized = PR_FALSE;
77 // The one time initialization for this module
78 // static
79 static nsresult
80 Initialize(nsIModule* aSelf)
82 NS_PRECONDITION(!gInitialized, "docshell module already initialized");
83 if (gInitialized) {
84 return NS_OK;
86 gInitialized = PR_TRUE;
88 nsresult rv = nsSHistory::Startup();
89 NS_ENSURE_SUCCESS(rv, rv);
91 rv = nsSHEntry::Startup();
92 return rv;
95 static void
96 Shutdown(nsIModule* aSelf)
98 nsSHEntry::Shutdown();
99 gInitialized = PR_FALSE;
102 // docshell
103 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebShell, Init)
104 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup)
105 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebNavigationInfo, Init)
106 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClassifierCallback)
108 // uriloader
109 NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader)
110 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDocLoader, Init)
111 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsOSHelperAppService, Init)
112 NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalProtocolHandler)
113 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefetchService, Init)
114 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsOfflineCacheUpdateService,
115 nsOfflineCacheUpdateService::GetInstance)
116 NS_GENERIC_FACTORY_CONSTRUCTOR(nsOfflineCacheUpdate)
117 NS_GENERIC_FACTORY_CONSTRUCTOR(PlatformLocalHandlerApp_t)
118 #ifdef MOZ_ENABLE_DBUS
119 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDBusHandlerApp)
120 #endif
122 #if defined(XP_MAC) || defined(XP_MACOSX)
123 #include "nsInternetConfigService.h"
124 NS_GENERIC_FACTORY_CONSTRUCTOR(nsInternetConfigService)
125 #endif
127 // session history
128 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHEntry)
129 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHTransaction)
130 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHistory)
132 // download history
133 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadHistory)
135 // Currently no-one is instantiating docshell's directly because
136 // nsWebShell is still our main "shell" class. nsWebShell is a subclass
137 // of nsDocShell. Once migration is complete, docshells will be the main
138 // "shell" class and this module will need to register the docshell as
139 // a component
140 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsDocShell)
142 static const nsModuleComponentInfo gDocShellModuleInfo[] = {
143 // docshell
144 { "WebShell",
145 NS_WEB_SHELL_CID,
146 "@mozilla.org/webshell;1",
147 nsWebShellConstructor
149 { "Default keyword fixup",
150 NS_DEFAULTURIFIXUP_CID,
151 NS_URIFIXUP_CONTRACTID,
152 nsDefaultURIFixupConstructor
154 { "Webnavigation info service",
155 NS_WEBNAVIGATION_INFO_CID,
156 NS_WEBNAVIGATION_INFO_CONTRACTID,
157 nsWebNavigationInfoConstructor
160 "Channel classifier",
161 NS_CHANNELCLASSIFIER_CID,
162 NS_CHANNELCLASSIFIER_CONTRACTID,
163 nsClassifierCallbackConstructor
166 // about redirector
167 { "about:config",
168 NS_ABOUT_REDIRECTOR_MODULE_CID,
169 NS_ABOUT_MODULE_CONTRACTID_PREFIX "config",
170 nsAboutRedirector::Create
172 #ifdef MOZ_CRASHREPORTER
173 { "about:crashes",
174 NS_ABOUT_REDIRECTOR_MODULE_CID,
175 NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashes",
176 nsAboutRedirector::Create
178 #endif
179 { "about:credits",
180 NS_ABOUT_REDIRECTOR_MODULE_CID,
181 NS_ABOUT_MODULE_CONTRACTID_PREFIX "credits",
182 nsAboutRedirector::Create
184 { "about:plugins",
185 NS_ABOUT_REDIRECTOR_MODULE_CID,
186 NS_ABOUT_MODULE_CONTRACTID_PREFIX "plugins",
187 nsAboutRedirector::Create
189 { "about:mozilla",
190 NS_ABOUT_REDIRECTOR_MODULE_CID,
191 NS_ABOUT_MODULE_CONTRACTID_PREFIX "mozilla",
192 nsAboutRedirector::Create
194 { "about:logo",
195 NS_ABOUT_REDIRECTOR_MODULE_CID,
196 NS_ABOUT_MODULE_CONTRACTID_PREFIX "logo",
197 nsAboutRedirector::Create
199 { "about:buildconfig",
200 NS_ABOUT_REDIRECTOR_MODULE_CID,
201 NS_ABOUT_MODULE_CONTRACTID_PREFIX "buildconfig",
202 nsAboutRedirector::Create
204 { "about:license",
205 NS_ABOUT_REDIRECTOR_MODULE_CID,
206 NS_ABOUT_MODULE_CONTRACTID_PREFIX "license",
207 nsAboutRedirector::Create
209 { "about:licence",
210 NS_ABOUT_REDIRECTOR_MODULE_CID,
211 NS_ABOUT_MODULE_CONTRACTID_PREFIX "licence",
212 nsAboutRedirector::Create
214 { "about:neterror",
215 NS_ABOUT_REDIRECTOR_MODULE_CID,
216 NS_ABOUT_MODULE_CONTRACTID_PREFIX "neterror",
217 nsAboutRedirector::Create
220 // uriloader
221 { "Netscape URI Loader Service", NS_URI_LOADER_CID, NS_URI_LOADER_CONTRACTID, nsURILoaderConstructor, },
222 { "Netscape Doc Loader Service", NS_DOCUMENTLOADER_SERVICE_CID, NS_DOCUMENTLOADER_SERVICE_CONTRACTID,
223 nsDocLoaderConstructor, },
224 { "Netscape External Helper App Service", NS_EXTERNALHELPERAPPSERVICE_CID, NS_EXTERNALHELPERAPPSERVICE_CONTRACTID,
225 nsOSHelperAppServiceConstructor, },
226 { "Netscape External Helper App Service", NS_EXTERNALHELPERAPPSERVICE_CID, NS_EXTERNALPROTOCOLSERVICE_CONTRACTID,
227 nsOSHelperAppServiceConstructor, },
228 { "Netscape Mime Mapping Service", NS_EXTERNALHELPERAPPSERVICE_CID, NS_MIMESERVICE_CONTRACTID,
229 nsOSHelperAppServiceConstructor, },
230 { "Netscape Default Protocol Handler", NS_EXTERNALPROTOCOLHANDLER_CID, NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default",
231 nsExternalProtocolHandlerConstructor, },
232 { NS_PREFETCHSERVICE_CLASSNAME, NS_PREFETCHSERVICE_CID, NS_PREFETCHSERVICE_CONTRACTID,
233 nsPrefetchServiceConstructor, },
234 { NS_OFFLINECACHEUPDATESERVICE_CLASSNAME, NS_OFFLINECACHEUPDATESERVICE_CID, NS_OFFLINECACHEUPDATESERVICE_CONTRACTID,
235 nsOfflineCacheUpdateServiceConstructor, },
236 { NS_OFFLINECACHEUPDATE_CLASSNAME, NS_OFFLINECACHEUPDATE_CID, NS_OFFLINECACHEUPDATE_CONTRACTID,
237 nsOfflineCacheUpdateConstructor, },
238 { "Local Application Handler App", NS_LOCALHANDLERAPP_CID,
239 NS_LOCALHANDLERAPP_CONTRACTID, PlatformLocalHandlerApp_tConstructor, },
240 #ifdef MOZ_ENABLE_DBUS
241 { "DBus Handler App", NS_DBUSHANDLERAPP_CID,
242 NS_DBUSHANDLERAPP_CONTRACTID, nsDBusHandlerAppConstructor},
243 #endif
244 #if defined(XP_MAC) || defined(XP_MACOSX)
245 { "Internet Config Service", NS_INTERNETCONFIGSERVICE_CID, NS_INTERNETCONFIGSERVICE_CONTRACTID,
246 nsInternetConfigServiceConstructor, },
247 #endif
249 // session history
250 { "nsSHEntry", NS_SHENTRY_CID,
251 NS_SHENTRY_CONTRACTID, nsSHEntryConstructor },
252 { "nsSHEntry", NS_HISTORYENTRY_CID,
253 NS_HISTORYENTRY_CONTRACTID, nsSHEntryConstructor },
254 { "nsSHTransaction", NS_SHTRANSACTION_CID,
255 NS_SHTRANSACTION_CONTRACTID, nsSHTransactionConstructor },
256 { "nsSHistory", NS_SHISTORY_CID,
257 NS_SHISTORY_CONTRACTID, nsSHistoryConstructor },
258 { "nsSHistory", NS_SHISTORY_INTERNAL_CID,
259 NS_SHISTORY_INTERNAL_CONTRACTID, nsSHistoryConstructor },
261 // global history adapters
262 { "nsGlobalHistoryAdapter", NS_GLOBALHISTORYADAPTER_CID,
263 nsnull, nsGlobalHistoryAdapter::Create,
264 nsGlobalHistoryAdapter::RegisterSelf },
265 { "nsGlobalHistory2Adapter", NS_GLOBALHISTORY2ADAPTER_CID,
266 nsnull, nsGlobalHistory2Adapter::Create,
267 nsGlobalHistory2Adapter::RegisterSelf },
269 // download history
270 { "nsDownloadHistory", NS_DOWNLOADHISTORY_CID,
271 nsnull, nsDownloadHistoryConstructor,
272 nsDownloadHistory::RegisterSelf }
275 // "docshell provider" to illustrate that this thing really *should*
276 // be dispensing docshells rather than webshells.
277 NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(docshell_provider, gDocShellModuleInfo,
278 Initialize, Shutdown)