1999-11-02 06:43:10 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
1999-10-25 08:53:13 +04:00
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-10-25 08:53:13 +04:00
|
|
|
|
2010-06-10 22:11:40 +04:00
|
|
|
#include "mozilla/ModuleUtils.h"
|
2005-02-27 21:33:27 +03:00
|
|
|
#include "nsDocShellCID.h"
|
|
|
|
|
2009-05-07 23:21:53 +04:00
|
|
|
#include "nsDocShell.h"
|
2000-11-09 00:00:37 +03:00
|
|
|
#include "nsDefaultURIFixup.h"
|
2005-02-27 21:33:27 +03:00
|
|
|
#include "nsWebNavigationInfo.h"
|
2000-07-19 03:13:07 +04:00
|
|
|
|
2006-09-16 02:17:26 +04:00
|
|
|
#include "nsAboutRedirector.h"
|
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
// uriloader
|
|
|
|
#include "nsURILoader.h"
|
|
|
|
#include "nsDocLoader.h"
|
|
|
|
#include "nsOSHelperAppService.h"
|
|
|
|
#include "nsExternalProtocolHandler.h"
|
|
|
|
#include "nsPrefetchService.h"
|
2007-07-25 09:35:39 +04:00
|
|
|
#include "nsOfflineCacheUpdate.h"
|
2007-08-14 20:47:41 +04:00
|
|
|
#include "nsLocalHandlerApp.h"
|
2008-07-27 17:40:14 +04:00
|
|
|
#ifdef MOZ_ENABLE_DBUS
|
2008-07-25 20:36:07 +04:00
|
|
|
#include "nsDBusHandlerApp.h"
|
2008-07-27 17:40:14 +04:00
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
|
2010-09-30 19:37:36 +04:00
|
|
|
#include "nsExternalSharingAppService.h"
|
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2010-11-24 02:40:46 +03:00
|
|
|
#include "nsExternalURLHandlerService.h"
|
|
|
|
#endif
|
2003-03-15 04:04:32 +03:00
|
|
|
|
|
|
|
// session history
|
|
|
|
#include "nsSHEntry.h"
|
2011-10-21 19:26:34 +04:00
|
|
|
#include "nsSHEntryShared.h"
|
2003-03-15 04:04:32 +03:00
|
|
|
#include "nsSHistory.h"
|
|
|
|
#include "nsSHTransaction.h"
|
|
|
|
|
2007-11-23 23:20:41 +03:00
|
|
|
// download history
|
|
|
|
#include "nsDownloadHistory.h"
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool gInitialized = false;
|
2005-09-23 22:16:40 +04:00
|
|
|
|
|
|
|
// The one time initialization for this module
|
2008-10-10 19:04:34 +04:00
|
|
|
static nsresult
|
2010-06-10 22:11:40 +04:00
|
|
|
Initialize()
|
2005-09-23 22:16:40 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(!gInitialized, "docshell module already initialized");
|
|
|
|
if (gInitialized) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
gInitialized = true;
|
2005-09-23 22:16:40 +04:00
|
|
|
|
|
|
|
nsresult rv = nsSHistory::Startup();
|
2007-09-21 13:19:59 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-21 19:26:34 +04:00
|
|
|
nsSHEntryShared::Startup();
|
|
|
|
return NS_OK;
|
2005-09-23 22:16:40 +04:00
|
|
|
}
|
|
|
|
|
2008-10-10 19:04:34 +04:00
|
|
|
static void
|
2010-06-10 22:11:40 +04:00
|
|
|
Shutdown()
|
2005-09-23 22:16:40 +04:00
|
|
|
{
|
2011-06-25 05:55:46 +04:00
|
|
|
nsSHistory::Shutdown();
|
2011-10-21 19:26:34 +04:00
|
|
|
nsSHEntryShared::Shutdown();
|
2011-10-17 18:59:28 +04:00
|
|
|
gInitialized = false;
|
2005-09-23 22:16:40 +04:00
|
|
|
}
|
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
// docshell
|
2009-05-07 23:21:53 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDocShell, Init)
|
2003-09-08 02:05:34 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup)
|
2005-02-27 21:33:27 +03:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebNavigationInfo, Init)
|
2000-07-19 03:13:07 +04:00
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
// uriloader
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader)
|
2004-12-08 20:32:06 +03:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDocLoader, Init)
|
2003-03-15 04:04:32 +03:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsOSHelperAppService, Init)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalProtocolHandler)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefetchService, Init)
|
2007-07-25 09:35:39 +04:00
|
|
|
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsOfflineCacheUpdateService,
|
|
|
|
nsOfflineCacheUpdateService::GetInstance)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsOfflineCacheUpdate)
|
2007-10-04 10:10:47 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(PlatformLocalHandlerApp_t)
|
2008-07-27 17:40:14 +04:00
|
|
|
#ifdef MOZ_ENABLE_DBUS
|
2008-07-25 20:36:07 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDBusHandlerApp)
|
2008-07-27 17:40:14 +04:00
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
|
2010-09-30 19:37:36 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalSharingAppService)
|
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2010-11-24 02:40:46 +03:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalURLHandlerService)
|
|
|
|
#endif
|
2003-03-15 04:04:32 +03:00
|
|
|
|
|
|
|
// session history
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHEntry)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHTransaction)
|
2005-09-23 22:16:40 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHistory)
|
2003-03-15 04:04:32 +03:00
|
|
|
|
2007-11-23 23:20:41 +03:00
|
|
|
// download history
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadHistory)
|
|
|
|
|
2010-06-10 22:11:40 +04:00
|
|
|
NS_DEFINE_NAMED_CID(NS_DOCSHELL_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_DEFAULTURIFIXUP_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_WEBNAVIGATION_INFO_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_ABOUT_REDIRECTOR_MODULE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_URI_LOADER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_DOCUMENTLOADER_SERVICE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_EXTERNALHELPERAPPSERVICE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_EXTERNALPROTOCOLHANDLER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_PREFETCHSERVICE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_OFFLINECACHEUPDATESERVICE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_OFFLINECACHEUPDATE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_LOCALHANDLERAPP_CID);
|
|
|
|
#ifdef MOZ_ENABLE_DBUS
|
|
|
|
NS_DEFINE_NAMED_CID(NS_DBUSHANDLERAPP_CID);
|
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
|
2010-09-30 19:37:36 +04:00
|
|
|
NS_DEFINE_NAMED_CID(NS_EXTERNALSHARINGAPPSERVICE_CID);
|
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2010-11-24 02:40:46 +03:00
|
|
|
NS_DEFINE_NAMED_CID(NS_EXTERNALURLHANDLERSERVICE_CID);
|
|
|
|
#endif
|
2010-06-10 22:11:40 +04:00
|
|
|
NS_DEFINE_NAMED_CID(NS_SHENTRY_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_SHTRANSACTION_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_SHISTORY_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_SHISTORY_INTERNAL_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_DOWNLOADHISTORY_CID);
|
|
|
|
|
|
|
|
|
|
|
|
const mozilla::Module::CIDEntry kDocShellCIDs[] = {
|
2013-04-03 04:24:42 +04:00
|
|
|
{ &kNS_DOCSHELL_CID, false, nullptr, nsDocShellConstructor },
|
|
|
|
{ &kNS_DEFAULTURIFIXUP_CID, false, nullptr, nsDefaultURIFixupConstructor },
|
|
|
|
{ &kNS_WEBNAVIGATION_INFO_CID, false, nullptr, nsWebNavigationInfoConstructor },
|
|
|
|
{ &kNS_ABOUT_REDIRECTOR_MODULE_CID, false, nullptr, nsAboutRedirector::Create },
|
|
|
|
{ &kNS_URI_LOADER_CID, false, nullptr, nsURILoaderConstructor },
|
|
|
|
{ &kNS_DOCUMENTLOADER_SERVICE_CID, false, nullptr, nsDocLoaderConstructor },
|
|
|
|
{ &kNS_EXTERNALHELPERAPPSERVICE_CID, false, nullptr, nsOSHelperAppServiceConstructor },
|
|
|
|
{ &kNS_EXTERNALPROTOCOLHANDLER_CID, false, nullptr, nsExternalProtocolHandlerConstructor },
|
|
|
|
{ &kNS_PREFETCHSERVICE_CID, false, nullptr, nsPrefetchServiceConstructor },
|
|
|
|
{ &kNS_OFFLINECACHEUPDATESERVICE_CID, false, nullptr, nsOfflineCacheUpdateServiceConstructor },
|
|
|
|
{ &kNS_OFFLINECACHEUPDATE_CID, false, nullptr, nsOfflineCacheUpdateConstructor },
|
|
|
|
{ &kNS_LOCALHANDLERAPP_CID, false, nullptr, PlatformLocalHandlerApp_tConstructor },
|
2010-06-10 22:11:40 +04:00
|
|
|
#ifdef MOZ_ENABLE_DBUS
|
2013-04-03 04:24:42 +04:00
|
|
|
{ &kNS_DBUSHANDLERAPP_CID, false, nullptr, nsDBusHandlerAppConstructor },
|
2010-09-30 19:37:36 +04:00
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
|
2013-04-03 04:24:42 +04:00
|
|
|
{ &kNS_EXTERNALSHARINGAPPSERVICE_CID, false, nullptr, nsExternalSharingAppServiceConstructor },
|
2010-11-24 02:40:46 +03:00
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2013-04-03 04:24:42 +04:00
|
|
|
{ &kNS_EXTERNALURLHANDLERSERVICE_CID, false, nullptr, nsExternalURLHandlerServiceConstructor },
|
2010-06-10 22:11:40 +04:00
|
|
|
#endif
|
2013-04-03 04:24:42 +04:00
|
|
|
{ &kNS_SHENTRY_CID, false, nullptr, nsSHEntryConstructor },
|
|
|
|
{ &kNS_SHTRANSACTION_CID, false, nullptr, nsSHTransactionConstructor },
|
|
|
|
{ &kNS_SHISTORY_CID, false, nullptr, nsSHistoryConstructor },
|
|
|
|
{ &kNS_SHISTORY_INTERNAL_CID, false, nullptr, nsSHistoryConstructor },
|
|
|
|
{ &kNS_DOWNLOADHISTORY_CID, false, nullptr, nsDownloadHistoryConstructor },
|
|
|
|
{ nullptr }
|
2010-06-10 22:11:40 +04:00
|
|
|
};
|
2003-03-15 04:04:32 +03:00
|
|
|
|
2010-06-10 22:11:40 +04:00
|
|
|
const mozilla::Module::ContractIDEntry kDocShellContracts[] = {
|
|
|
|
{ "@mozilla.org/docshell;1", &kNS_DOCSHELL_CID },
|
|
|
|
{ NS_URIFIXUP_CONTRACTID, &kNS_DEFAULTURIFIXUP_CID },
|
|
|
|
{ NS_WEBNAVIGATION_INFO_CONTRACTID, &kNS_WEBNAVIGATION_INFO_CID },
|
2010-10-15 14:28:54 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2010-06-10 22:11:40 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "about", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "config", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2008-01-24 19:11:09 +03:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2010-06-10 22:11:40 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashes", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2008-01-24 19:11:09 +03:00
|
|
|
#endif
|
2010-06-10 22:11:40 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "credits", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "plugins", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "mozilla", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "logo", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "buildconfig", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "license", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "neterror", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2012-02-17 10:10:39 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "compartments", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2010-06-10 22:11:40 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "memory", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "addons", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2011-08-13 00:50:47 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "newaddon", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2010-06-10 22:11:40 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "support", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2012-11-09 00:36:06 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "telemetry", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2013-08-08 04:15:28 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "networking", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2013-06-29 07:13:20 +04:00
|
|
|
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "srcdoc", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
|
2010-06-10 22:11:40 +04:00
|
|
|
{ NS_URI_LOADER_CONTRACTID, &kNS_URI_LOADER_CID },
|
|
|
|
{ NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &kNS_DOCUMENTLOADER_SERVICE_CID },
|
|
|
|
{ NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID },
|
|
|
|
{ NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID },
|
|
|
|
{ NS_MIMESERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID },
|
|
|
|
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default", &kNS_EXTERNALPROTOCOLHANDLER_CID },
|
|
|
|
{ NS_PREFETCHSERVICE_CONTRACTID, &kNS_PREFETCHSERVICE_CID },
|
|
|
|
{ NS_OFFLINECACHEUPDATESERVICE_CONTRACTID, &kNS_OFFLINECACHEUPDATESERVICE_CID },
|
|
|
|
{ NS_OFFLINECACHEUPDATE_CONTRACTID, &kNS_OFFLINECACHEUPDATE_CID },
|
|
|
|
{ NS_LOCALHANDLERAPP_CONTRACTID, &kNS_LOCALHANDLERAPP_CID },
|
2008-07-27 17:40:14 +04:00
|
|
|
#ifdef MOZ_ENABLE_DBUS
|
2010-06-10 22:11:40 +04:00
|
|
|
{ NS_DBUSHANDLERAPP_CONTRACTID, &kNS_DBUSHANDLERAPP_CID },
|
2010-09-30 19:37:36 +04:00
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
|
2010-09-30 19:37:36 +04:00
|
|
|
{ NS_EXTERNALSHARINGAPPSERVICE_CONTRACTID, &kNS_EXTERNALSHARINGAPPSERVICE_CID },
|
2010-11-24 02:40:46 +03:00
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2010-11-24 02:40:46 +03:00
|
|
|
{ NS_EXTERNALURLHANDLERSERVICE_CONTRACTID, &kNS_EXTERNALURLHANDLERSERVICE_CID },
|
2008-07-27 17:40:14 +04:00
|
|
|
#endif
|
2010-06-10 22:11:40 +04:00
|
|
|
{ NS_SHENTRY_CONTRACTID, &kNS_SHENTRY_CID },
|
|
|
|
{ NS_SHTRANSACTION_CONTRACTID, &kNS_SHTRANSACTION_CID },
|
|
|
|
{ NS_SHISTORY_CONTRACTID, &kNS_SHISTORY_CID },
|
|
|
|
{ NS_SHISTORY_INTERNAL_CONTRACTID, &kNS_SHISTORY_INTERNAL_CID },
|
|
|
|
{ NS_DOWNLOADHISTORY_CONTRACTID, &kNS_DOWNLOADHISTORY_CID },
|
2013-04-03 04:24:42 +04:00
|
|
|
{ nullptr }
|
2010-06-10 22:11:40 +04:00
|
|
|
};
|
2004-02-11 05:10:04 +03:00
|
|
|
|
2010-06-10 22:11:40 +04:00
|
|
|
static const mozilla::Module kDocShellModule = {
|
|
|
|
mozilla::Module::kVersion,
|
|
|
|
kDocShellCIDs,
|
|
|
|
kDocShellContracts,
|
2013-04-03 04:24:42 +04:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2010-06-10 22:11:40 +04:00
|
|
|
Initialize,
|
|
|
|
Shutdown
|
2000-01-25 11:18:46 +03:00
|
|
|
};
|
1999-10-25 08:53:13 +04:00
|
|
|
|
2010-06-10 22:11:40 +04:00
|
|
|
NSMODULE_DEFN(docshell_provider) = &kDocShellModule;
|