Back to index

lightning-sunbird  0.9+nobinonly
nsDocShellModule.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Travis Bogard <travis@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #include "nsIModule.h"
00041 #include "nsIGenericFactory.h"
00042 
00043 #include "nsDocShellCID.h"
00044 
00045 #include "nsWebShell.h"
00046 #include "nsDefaultURIFixup.h"
00047 #include "nsWebNavigationInfo.h"
00048 
00049 // uriloader
00050 #include "nsURILoader.h"
00051 #include "nsDocLoader.h"
00052 #include "nsOSHelperAppService.h"
00053 #include "nsExternalProtocolHandler.h"
00054 #include "nsPrefetchService.h"
00055 
00056 // session history
00057 #include "nsSHEntry.h"
00058 #include "nsSHistory.h"
00059 #include "nsSHTransaction.h"
00060 
00061 // global history
00062 #include "nsGlobalHistoryAdapter.h"
00063 #include "nsGlobalHistory2Adapter.h"
00064 
00065 static PRBool gInitialized = PR_FALSE;
00066 
00067 // The one time initialization for this module
00068 // static
00069 PR_STATIC_CALLBACK(nsresult)
00070 Initialize(nsIModule* aSelf)
00071 {
00072   NS_PRECONDITION(!gInitialized, "docshell module already initialized");
00073   if (gInitialized) {
00074     return NS_OK;
00075   }
00076   gInitialized = PR_TRUE;
00077 
00078   nsresult rv = nsSHistory::Startup();
00079   return rv;
00080 }
00081 
00082 PR_STATIC_CALLBACK(void)
00083 Shutdown(nsIModule* aSelf)
00084 {
00085   gInitialized = PR_FALSE;
00086 }
00087 
00088 // docshell
00089 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebShell, Init)
00090 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup)
00091 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebNavigationInfo, Init)
00092 
00093 // uriloader
00094 NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader)
00095 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDocLoader, Init)
00096 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsOSHelperAppService, Init)
00097 NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalProtocolHandler)
00098 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlockedExternalProtocolHandler)
00099 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefetchService, Init)
00100 
00101 #if defined(XP_MAC) || defined(XP_MACOSX)
00102 #include "nsInternetConfigService.h"
00103 NS_GENERIC_FACTORY_CONSTRUCTOR(nsInternetConfigService)
00104 #endif
00105 
00106 // session history
00107 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHEntry)
00108 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHTransaction)
00109 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHistory)
00110 
00111 // Currently no-one is instantiating docshell's directly because
00112 // nsWebShell is still our main "shell" class. nsWebShell is a subclass
00113 // of nsDocShell. Once migration is complete, docshells will be the main
00114 // "shell" class and this module will need to register the docshell as
00115 // a component
00116 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsDocShell)
00117 
00118 static const nsModuleComponentInfo gDocShellModuleInfo[] = {
00119   // docshell
00120     { "WebShell", 
00121       NS_WEB_SHELL_CID,
00122       "@mozilla.org/webshell;1",
00123       nsWebShellConstructor
00124     },
00125     { "Default keyword fixup", 
00126       NS_DEFAULTURIFIXUP_CID,
00127       NS_URIFIXUP_CONTRACTID,
00128       nsDefaultURIFixupConstructor
00129     },
00130     { "Webnavigation info service",
00131       NS_WEBNAVIGATION_INFO_CID,
00132       NS_WEBNAVIGATION_INFO_CONTRACTID,
00133       nsWebNavigationInfoConstructor
00134     },
00135 
00136     // uriloader
00137   { "Netscape URI Loader Service", NS_URI_LOADER_CID, NS_URI_LOADER_CONTRACTID, nsURILoaderConstructor, },
00138   { "Netscape Doc Loader Service", NS_DOCUMENTLOADER_SERVICE_CID, NS_DOCUMENTLOADER_SERVICE_CONTRACTID, 
00139      nsDocLoaderConstructor, },
00140   { "Netscape External Helper App Service", NS_EXTERNALHELPERAPPSERVICE_CID, NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, 
00141      nsOSHelperAppServiceConstructor, },
00142   { "Netscape External Helper App Service", NS_EXTERNALHELPERAPPSERVICE_CID, NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, 
00143      nsOSHelperAppServiceConstructor, },
00144   { "Netscape Mime Mapping Service", NS_EXTERNALHELPERAPPSERVICE_CID, NS_MIMESERVICE_CONTRACTID, 
00145      nsOSHelperAppServiceConstructor, },
00146   { "Netscape Default Protocol Handler", NS_EXTERNALPROTOCOLHANDLER_CID, NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default", 
00147      nsExternalProtocolHandlerConstructor, },
00148   { "Netscape Default Blocked Protocol Handler", NS_BLOCKEDEXTERNALPROTOCOLHANDLER_CID, NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default-blocked", 
00149      nsBlockedExternalProtocolHandlerConstructor, },
00150   {  NS_PREFETCHSERVICE_CLASSNAME, NS_PREFETCHSERVICE_CID, NS_PREFETCHSERVICE_CONTRACTID,
00151      nsPrefetchServiceConstructor, },
00152 #if defined(XP_MAC) || defined(XP_MACOSX)
00153   { "Internet Config Service", NS_INTERNETCONFIGSERVICE_CID, NS_INTERNETCONFIGSERVICE_CONTRACTID,
00154     nsInternetConfigServiceConstructor, },
00155 #endif
00156     
00157     // session history
00158    { "nsSHEntry", NS_SHENTRY_CID,
00159       NS_SHENTRY_CONTRACTID, nsSHEntryConstructor },
00160    { "nsSHEntry", NS_HISTORYENTRY_CID,
00161       NS_HISTORYENTRY_CONTRACTID, nsSHEntryConstructor },
00162    { "nsSHTransaction", NS_SHTRANSACTION_CID,
00163       NS_SHTRANSACTION_CONTRACTID, nsSHTransactionConstructor },
00164    { "nsSHistory", NS_SHISTORY_CID,
00165       NS_SHISTORY_CONTRACTID, nsSHistoryConstructor },
00166    { "nsSHistory", NS_SHISTORY_INTERNAL_CID,
00167       NS_SHISTORY_INTERNAL_CONTRACTID, nsSHistoryConstructor },
00168 
00169     // global history adapters
00170     { "nsGlobalHistoryAdapter", NS_GLOBALHISTORYADAPTER_CID,
00171       nsnull, nsGlobalHistoryAdapter::Create,
00172       nsGlobalHistoryAdapter::RegisterSelf },
00173     { "nsGlobalHistory2Adapter", NS_GLOBALHISTORY2ADAPTER_CID,
00174       nsnull, nsGlobalHistory2Adapter::Create,
00175       nsGlobalHistory2Adapter::RegisterSelf }
00176 };
00177 
00178 // "docshell provider" to illustrate that this thing really *should*
00179 // be dispensing docshells rather than webshells.
00180 NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(docshell_provider, gDocShellModuleInfo,
00181                                    Initialize, Shutdown)