| 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|---|
| 2 | * |
|---|
| 3 | * ***** BEGIN LICENSE BLOCK ***** |
|---|
| 4 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
|---|
| 5 | * |
|---|
| 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/ |
|---|
| 10 | * |
|---|
| 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. |
|---|
| 15 | * |
|---|
| 16 | * The Original Code is the Mozilla browser. |
|---|
| 17 | * |
|---|
| 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. |
|---|
| 22 | * |
|---|
| 23 | * Contributor(s): |
|---|
| 24 | * Travis Bogard <travis@netscape.com> |
|---|
| 25 | * |
|---|
| 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. |
|---|
| 37 | * |
|---|
| 38 | * ***** END LICENSE BLOCK ***** */ |
|---|
| 39 | |
|---|
| 40 | #include "nsIModule.h" |
|---|
| 41 | #include "nsIGenericFactory.h" |
|---|
| 42 | |
|---|
| 43 | #include "nsDocShellCID.h" |
|---|
| 44 | |
|---|
| 45 | #include "nsWebShell.h" |
|---|
| 46 | #include "nsDefaultURIFixup.h" |
|---|
| 47 | #include "nsWebNavigationInfo.h" |
|---|
| 48 | |
|---|
| 49 | #include "nsAboutRedirector.h" |
|---|
| 50 | |
|---|
| 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 | |
|---|
| 60 | // session history |
|---|
| 61 | #include "nsSHEntry.h" |
|---|
| 62 | #include "nsSHistory.h" |
|---|
| 63 | #include "nsSHTransaction.h" |
|---|
| 64 | |
|---|
| 65 | // global history |
|---|
| 66 | #include "nsGlobalHistoryAdapter.h" |
|---|
| 67 | #include "nsGlobalHistory2Adapter.h" |
|---|
| 68 | |
|---|
| 69 | // download history |
|---|
| 70 | #include "nsDownloadHistory.h" |
|---|
| 71 | |
|---|
| 72 | static PRBool gInitialized = PR_FALSE; |
|---|
| 73 | |
|---|
| 74 | // The one time initialization for this module |
|---|
| 75 | // static |
|---|
| 76 | PR_STATIC_CALLBACK(nsresult) |
|---|
| 77 | Initialize(nsIModule* aSelf) |
|---|
| 78 | { |
|---|
| 79 | NS_PRECONDITION(!gInitialized, "docshell module already initialized"); |
|---|
| 80 | if (gInitialized) { |
|---|
| 81 | return NS_OK; |
|---|
| 82 | } |
|---|
| 83 | gInitialized = PR_TRUE; |
|---|
| 84 | |
|---|
| 85 | nsresult rv = nsSHistory::Startup(); |
|---|
| 86 | NS_ENSURE_SUCCESS(rv, rv); |
|---|
| 87 | |
|---|
| 88 | rv = nsSHEntry::Startup(); |
|---|
| 89 | return rv; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | PR_STATIC_CALLBACK(void) |
|---|
| 93 | Shutdown(nsIModule* aSelf) |
|---|
| 94 | { |
|---|
| 95 | nsSHEntry::Shutdown(); |
|---|
| 96 | gInitialized = PR_FALSE; |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | // docshell |
|---|
| 100 | NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebShell, Init) |
|---|
| 101 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup) |
|---|
| 102 | NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebNavigationInfo, Init) |
|---|
| 103 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsClassifierCallback) |
|---|
| 104 | |
|---|
| 105 | // uriloader |
|---|
| 106 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader) |
|---|
| 107 | NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDocLoader, Init) |
|---|
| 108 | NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsOSHelperAppService, Init) |
|---|
| 109 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalProtocolHandler) |
|---|
| 110 | NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefetchService, Init) |
|---|
| 111 | NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsOfflineCacheUpdateService, |
|---|
| 112 | nsOfflineCacheUpdateService::GetInstance) |
|---|
| 113 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsOfflineCacheUpdate) |
|---|
| 114 | NS_GENERIC_FACTORY_CONSTRUCTOR(PlatformLocalHandlerApp_t) |
|---|
| 115 | |
|---|
| 116 | #if defined(XP_MAC) || defined(XP_MACOSX) |
|---|
| 117 | #include "nsInternetConfigService.h" |
|---|
| 118 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsInternetConfigService) |
|---|
| 119 | #endif |
|---|
| 120 | |
|---|
| 121 | // session history |
|---|
| 122 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHEntry) |
|---|
| 123 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHTransaction) |
|---|
| 124 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHistory) |
|---|
| 125 | |
|---|
| 126 | // download history |
|---|
| 127 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadHistory) |
|---|
| 128 | |
|---|
| 129 | // Currently no-one is instantiating docshell's directly because |
|---|
| 130 | // nsWebShell is still our main "shell" class. nsWebShell is a subclass |
|---|
| 131 | // of nsDocShell. Once migration is complete, docshells will be the main |
|---|
| 132 | // "shell" class and this module will need to register the docshell as |
|---|
| 133 | // a component |
|---|
| 134 | //NS_GENERIC_FACTORY_CONSTRUCTOR(nsDocShell) |
|---|
| 135 | |
|---|
| 136 | static const nsModuleComponentInfo gDocShellModuleInfo[] = { |
|---|
| 137 | // docshell |
|---|
| 138 | { "WebShell", |
|---|
| 139 | NS_WEB_SHELL_CID, |
|---|
| 140 | "@mozilla.org/webshell;1", |
|---|
| 141 | nsWebShellConstructor |
|---|
| 142 | }, |
|---|
| 143 | { "Default keyword fixup", |
|---|
| 144 | NS_DEFAULTURIFIXUP_CID, |
|---|
| 145 | NS_URIFIXUP_CONTRACTID, |
|---|
| 146 | nsDefaultURIFixupConstructor |
|---|
| 147 | }, |
|---|
| 148 | { "Webnavigation info service", |
|---|
| 149 | NS_WEBNAVIGATION_INFO_CID, |
|---|
| 150 | NS_WEBNAVIGATION_INFO_CONTRACTID, |
|---|
| 151 | nsWebNavigationInfoConstructor |
|---|
| 152 | }, |
|---|
| 153 | { |
|---|
| 154 | "Channel classifier", |
|---|
| 155 | NS_CHANNELCLASSIFIER_CID, |
|---|
| 156 | NS_CHANNELCLASSIFIER_CONTRACTID, |
|---|
| 157 | nsClassifierCallbackConstructor |
|---|
| 158 | }, |
|---|
| 159 | |
|---|
| 160 | // about redirector |
|---|
| 161 | { "about:config", |
|---|
| 162 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 163 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "config", |
|---|
| 164 | nsAboutRedirector::Create |
|---|
| 165 | }, |
|---|
| 166 | #ifdef MOZ_CRASHREPORTER |
|---|
| 167 | { "about:crashes", |
|---|
| 168 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 169 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashes", |
|---|
| 170 | nsAboutRedirector::Create |
|---|
| 171 | }, |
|---|
| 172 | #endif |
|---|
| 173 | { "about:credits", |
|---|
| 174 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 175 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "credits", |
|---|
| 176 | nsAboutRedirector::Create |
|---|
| 177 | }, |
|---|
| 178 | { "about:plugins", |
|---|
| 179 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 180 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "plugins", |
|---|
| 181 | nsAboutRedirector::Create |
|---|
| 182 | }, |
|---|
| 183 | { "about:mozilla", |
|---|
| 184 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 185 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "mozilla", |
|---|
| 186 | nsAboutRedirector::Create |
|---|
| 187 | }, |
|---|
| 188 | { "about:logo", |
|---|
| 189 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 190 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "logo", |
|---|
| 191 | nsAboutRedirector::Create |
|---|
| 192 | }, |
|---|
| 193 | { "about:buildconfig", |
|---|
| 194 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 195 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "buildconfig", |
|---|
| 196 | nsAboutRedirector::Create |
|---|
| 197 | }, |
|---|
| 198 | { "about:license", |
|---|
| 199 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 200 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "license", |
|---|
| 201 | nsAboutRedirector::Create |
|---|
| 202 | }, |
|---|
| 203 | { "about:licence", |
|---|
| 204 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 205 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "licence", |
|---|
| 206 | nsAboutRedirector::Create |
|---|
| 207 | }, |
|---|
| 208 | { "about:about", |
|---|
| 209 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 210 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "about", |
|---|
| 211 | nsAboutRedirector::Create |
|---|
| 212 | }, |
|---|
| 213 | { "about:neterror", |
|---|
| 214 | NS_ABOUT_REDIRECTOR_MODULE_CID, |
|---|
| 215 | NS_ABOUT_MODULE_CONTRACTID_PREFIX "neterror", |
|---|
| 216 | nsAboutRedirector::Create |
|---|
| 217 | }, |
|---|
| 218 | |
|---|
| 219 | // uriloader |
|---|
| 220 | { "Netscape URI Loader Service", NS_URI_LOADER_CID, NS_URI_LOADER_CONTRACTID, nsURILoaderConstructor, }, |
|---|
| 221 | { "Netscape Doc Loader Service", NS_DOCUMENTLOADER_SERVICE_CID, NS_DOCUMENTLOADER_SERVICE_CONTRACTID, |
|---|
| 222 | nsDocLoaderConstructor, }, |
|---|
| 223 | { "Netscape External Helper App Service", NS_EXTERNALHELPERAPPSERVICE_CID, NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, |
|---|
| 224 | nsOSHelperAppServiceConstructor, }, |
|---|
| 225 | { "Netscape External Helper App Service", NS_EXTERNALHELPERAPPSERVICE_CID, NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, |
|---|
| 226 | nsOSHelperAppServiceConstructor, }, |
|---|
| 227 | { "Netscape Mime Mapping Service", NS_EXTERNALHELPERAPPSERVICE_CID, NS_MIMESERVICE_CONTRACTID, |
|---|
| 228 | nsOSHelperAppServiceConstructor, }, |
|---|
| 229 | { "Netscape Default Protocol Handler", NS_EXTERNALPROTOCOLHANDLER_CID, NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default", |
|---|
| 230 | nsExternalProtocolHandlerConstructor, }, |
|---|
| 231 | { NS_PREFETCHSERVICE_CLASSNAME, NS_PREFETCHSERVICE_CID, NS_PREFETCHSERVICE_CONTRACTID, |
|---|
| 232 | nsPrefetchServiceConstructor, }, |
|---|
| 233 | { NS_OFFLINECACHEUPDATESERVICE_CLASSNAME, NS_OFFLINECACHEUPDATESERVICE_CID, NS_OFFLINECACHEUPDATESERVICE_CONTRACTID, |
|---|
| 234 | nsOfflineCacheUpdateServiceConstructor, }, |
|---|
| 235 | { NS_OFFLINECACHEUPDATE_CLASSNAME, NS_OFFLINECACHEUPDATE_CID, NS_OFFLINECACHEUPDATE_CONTRACTID, |
|---|
| 236 | nsOfflineCacheUpdateConstructor, }, |
|---|
| 237 | { "Local Application Handler App", NS_LOCALHANDLERAPP_CID, |
|---|
| 238 | NS_LOCALHANDLERAPP_CONTRACTID, PlatformLocalHandlerApp_tConstructor, }, |
|---|
| 239 | |
|---|
| 240 | #if defined(XP_MAC) || defined(XP_MACOSX) |
|---|
| 241 | { "Internet Config Service", NS_INTERNETCONFIGSERVICE_CID, NS_INTERNETCONFIGSERVICE_CONTRACTID, |
|---|
| 242 | nsInternetConfigServiceConstructor, }, |
|---|
| 243 | #endif |
|---|
| 244 | |
|---|
| 245 | // session history |
|---|
| 246 | { "nsSHEntry", NS_SHENTRY_CID, |
|---|
| 247 | NS_SHENTRY_CONTRACTID, nsSHEntryConstructor }, |
|---|
| 248 | { "nsSHEntry", NS_HISTORYENTRY_CID, |
|---|
| 249 | NS_HISTORYENTRY_CONTRACTID, nsSHEntryConstructor }, |
|---|
| 250 | { "nsSHTransaction", NS_SHTRANSACTION_CID, |
|---|
| 251 | NS_SHTRANSACTION_CONTRACTID, nsSHTransactionConstructor }, |
|---|
| 252 | { "nsSHistory", NS_SHISTORY_CID, |
|---|
| 253 | NS_SHISTORY_CONTRACTID, nsSHistoryConstructor }, |
|---|
| 254 | { "nsSHistory", NS_SHISTORY_INTERNAL_CID, |
|---|
| 255 | NS_SHISTORY_INTERNAL_CONTRACTID, nsSHistoryConstructor }, |
|---|
| 256 | |
|---|
| 257 | // global history adapters |
|---|
| 258 | { "nsGlobalHistoryAdapter", NS_GLOBALHISTORYADAPTER_CID, |
|---|
| 259 | nsnull, nsGlobalHistoryAdapter::Create, |
|---|
| 260 | nsGlobalHistoryAdapter::RegisterSelf }, |
|---|
| 261 | { "nsGlobalHistory2Adapter", NS_GLOBALHISTORY2ADAPTER_CID, |
|---|
| 262 | nsnull, nsGlobalHistory2Adapter::Create, |
|---|
| 263 | nsGlobalHistory2Adapter::RegisterSelf }, |
|---|
| 264 | |
|---|
| 265 | // download history |
|---|
| 266 | { "nsDownloadHistory", NS_DOWNLOADHISTORY_CID, |
|---|
| 267 | nsnull, nsDownloadHistoryConstructor, |
|---|
| 268 | nsDownloadHistory::RegisterSelf } |
|---|
| 269 | }; |
|---|
| 270 | |
|---|
| 271 | // "docshell provider" to illustrate that this thing really *should* |
|---|
| 272 | // be dispensing docshells rather than webshells. |
|---|
| 273 | NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(docshell_provider, gDocShellModuleInfo, |
|---|
| 274 | Initialize, Shutdown) |
|---|