diff options
author | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-12 08:37:43 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-12 08:37:43 +0800 |
commit | 824dfce72819337e7dad44f9b9c999caadd0e9a2 (patch) | |
tree | 5080b21ccbdf078fcd95eb2842e55ffd265aead6 /embed/mozilla | |
parent | 3a57d18b63e6cde5a2a3bed06834020794c0ebd9 (diff) | |
download | gsoc2013-epiphany-824dfce72819337e7dad44f9b9c999caadd0e9a2.tar gsoc2013-epiphany-824dfce72819337e7dad44f9b9c999caadd0e9a2.tar.gz gsoc2013-epiphany-824dfce72819337e7dad44f9b9c999caadd0e9a2.tar.bz2 gsoc2013-epiphany-824dfce72819337e7dad44f9b9c999caadd0e9a2.tar.lz gsoc2013-epiphany-824dfce72819337e7dad44f9b9c999caadd0e9a2.tar.xz gsoc2013-epiphany-824dfce72819337e7dad44f9b9c999caadd0e9a2.tar.zst gsoc2013-epiphany-824dfce72819337e7dad44f9b9c999caadd0e9a2.zip |
*** empty log message ***
Diffstat (limited to 'embed/mozilla')
-rw-r--r-- | embed/mozilla/ContentHandler.cpp | 26 | ||||
-rw-r--r-- | embed/mozilla/EphyAboutRedirector.cpp | 21 | ||||
-rw-r--r-- | embed/mozilla/EphyWrapper.cpp | 20 | ||||
-rw-r--r-- | embed/mozilla/ExternalProtocolService.cpp | 23 | ||||
-rw-r--r-- | embed/mozilla/FilePicker.cpp | 24 | ||||
-rw-r--r-- | embed/mozilla/FtpProtocolHandler.cpp | 37 | ||||
-rw-r--r-- | embed/mozilla/FtpProtocolHandler.h | 13 | ||||
-rw-r--r-- | embed/mozilla/GlobalHistory.cpp | 49 | ||||
-rw-r--r-- | embed/mozilla/GlobalHistory.h | 26 | ||||
-rw-r--r-- | embed/mozilla/IRCProtocolHandler.cpp | 37 | ||||
-rw-r--r-- | embed/mozilla/IRCProtocolHandler.h | 13 | ||||
-rw-r--r-- | embed/mozilla/MailtoProtocolHandler.cpp | 43 | ||||
-rw-r--r-- | embed/mozilla/MailtoProtocolHandler.h | 13 | ||||
-rw-r--r-- | embed/mozilla/MozRegisterComponents.cpp | 360 | ||||
-rw-r--r-- | embed/mozilla/PrintingPromptService.cpp | 39 | ||||
-rw-r--r-- | embed/mozilla/PrintingPromptService.h | 13 | ||||
-rw-r--r-- | embed/mozilla/ProgressListener.cpp | 24 | ||||
-rw-r--r-- | embed/mozilla/StartHereProtocolHandler.cpp | 37 | ||||
-rw-r--r-- | embed/mozilla/StartHereProtocolHandler.h | 17 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 2 |
20 files changed, 311 insertions, 526 deletions
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp index 2acf96a3a..c39bbc923 100644 --- a/embed/mozilla/ContentHandler.cpp +++ b/embed/mozilla/ContentHandler.cpp @@ -177,11 +177,9 @@ extern "C" { #include "nsCRT.h" #include "nsCOMPtr.h" -#include "nsIFactory.h" #include "nsISupportsArray.h" #include "nsIServiceManager.h" #include "nsWeakReference.h" -#include "nsXPComFactory.h" #include "nsString.h" #include "nsIURI.h" @@ -535,30 +533,6 @@ NS_METHOD GContentHandler::MIMEAskAction (void) return NS_OK; } -//------------------------------------------------------------------------------ - -NS_DEF_FACTORY (GContentHandler, GContentHandler); - -/** - * NS_NewContentHandlerFactory: - */ -nsresult NS_NewContentHandlerFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsGContentHandlerFactory *result = new nsGContentHandlerFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} - //////////////////////////////////////////////////////////////////////////////// // begin MIMEAskActionDialog methods. //////////////////////////////////////////////////////////////////////////////// diff --git a/embed/mozilla/EphyAboutRedirector.cpp b/embed/mozilla/EphyAboutRedirector.cpp index 2a011060b..6cae8369d 100644 --- a/embed/mozilla/EphyAboutRedirector.cpp +++ b/embed/mozilla/EphyAboutRedirector.cpp @@ -102,24 +102,3 @@ EphyAboutRedirector::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) return rv; } -NS_DEF_FACTORY (EphyAboutRedirector, EphyAboutRedirector); - -/** - * NS_NewEphyAboutRedirectorFactory: - */ -nsresult NS_NewEphyAboutRedirectorFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsEphyAboutRedirectorFactory *result = new nsEphyAboutRedirectorFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embed/mozilla/EphyWrapper.cpp b/embed/mozilla/EphyWrapper.cpp index fcde13437..b5ae3a24a 100644 --- a/embed/mozilla/EphyWrapper.cpp +++ b/embed/mozilla/EphyWrapper.cpp @@ -100,26 +100,14 @@ nsresult EphyWrapper::Init (GtkMozEmbed *mozembed) nsCOMPtr<nsIDocShellHistory> dsHistory = do_QueryInterface (DocShell); if (!dsHistory) return NS_ERROR_FAILURE; - static NS_DEFINE_CID(kGlobalHistoryCID, GALEON_GLOBALHISTORY_CID); - - nsCOMPtr<nsIFactory> GHFactory; - result = NS_NewGlobalHistoryFactory(getter_AddRefs(GHFactory)); - if (NS_FAILED(result)) return NS_ERROR_FAILURE; - - result = nsComponentManager::RegisterFactory(kGlobalHistoryCID, - "Global history", - NS_GLOBALHISTORY_CONTRACTID, - GHFactory, - PR_TRUE); - - nsCOMPtr<nsIGlobalHistory> inst = - do_GetService(NS_GLOBALHISTORY_CONTRACTID, &result); - mEventListener = new EphyEventListener(); mEventListener->Init (EPHY_EMBED (mozembed)); GetListener(); AttachListeners(); - + + nsCOMPtr<nsIGlobalHistory> inst = + do_GetService(NS_GLOBALHISTORY_CONTRACTID, &result); + return dsHistory->SetGlobalHistory(inst); } diff --git a/embed/mozilla/ExternalProtocolService.cpp b/embed/mozilla/ExternalProtocolService.cpp index 5d71b2b85..9d9a7368c 100644 --- a/embed/mozilla/ExternalProtocolService.cpp +++ b/embed/mozilla/ExternalProtocolService.cpp @@ -28,7 +28,6 @@ #include <nsIDOMWindow.h> #include <nsIWindowWatcher.h> #include <nsIServiceManager.h> -#include <nsXPComFactory.h> #include "ephy-prefs.h" #include "eel-gconf-extensions.h" @@ -152,25 +151,3 @@ NS_IMETHODIMP GExternalProtocolService::LoadUrl(nsIURI *aURL) return NS_OK; } - -NS_DEF_FACTORY (GExternalProtocolService, GExternalProtocolService); - -/** - * NS_NewExternalProtocolServiceFactory: - */ -nsresult NS_NewExternalProtocolServiceFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsGExternalProtocolServiceFactory *result = new nsGExternalProtocolServiceFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embed/mozilla/FilePicker.cpp b/embed/mozilla/FilePicker.cpp index e488a8a6f..277a5a3a3 100644 --- a/embed/mozilla/FilePicker.cpp +++ b/embed/mozilla/FilePicker.cpp @@ -53,10 +53,8 @@ #include "nsCRT.h" #include "nsCOMPtr.h" -#include "nsIFactory.h" #include "nsISupportsArray.h" #include "nsIServiceManager.h" -#include "nsXPComFactory.h" #include "nsString.h" #include "nsXPIDLString.h" @@ -493,26 +491,4 @@ NS_METHOD GFilePicker::HandleFilePickerResult(PRInt16 *retval) return NS_OK; } -//------------------------------------------------------------------------------ -NS_DEF_FACTORY (GFilePicker, GFilePicker); - -/** - * NS_NewFilePickerFactory: - */ -nsresult NS_NewFilePickerFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsGFilePickerFactory *result = new nsGFilePickerFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embed/mozilla/FtpProtocolHandler.cpp b/embed/mozilla/FtpProtocolHandler.cpp index a9b299095..267bf695b 100644 --- a/embed/mozilla/FtpProtocolHandler.cpp +++ b/embed/mozilla/FtpProtocolHandler.cpp @@ -16,43 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "nsIFactory.h" -#include "nsXPComFactory.h" - -#include "BaseProtocolContentHandler.h" - -class GFtpProtocolHandler : public GBaseProtocolContentHandler -{ - public: - NS_DECL_ISUPPORTS - GFtpProtocolHandler() : GBaseProtocolContentHandler("ftp") - {NS_INIT_ISUPPORTS();}; - virtual ~GFtpProtocolHandler() {}; - /* additional members */ -}; +#include "FtpProtocolHandler.h" /* Implementation file */ NS_IMPL_ISUPPORTS2 (GFtpProtocolHandler, nsIProtocolHandler, nsIContentHandler) -NS_DEF_FACTORY (GFtpProtocolHandler, GFtpProtocolHandler); - -/** - * NS_NewFtpHandlerFactory: - */ -nsresult NS_NewFtpHandlerFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsGFtpProtocolHandlerFactory *result = - new nsGFtpProtocolHandlerFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embed/mozilla/FtpProtocolHandler.h b/embed/mozilla/FtpProtocolHandler.h index d031cd17b..d9b7c6c1b 100644 --- a/embed/mozilla/FtpProtocolHandler.h +++ b/embed/mozilla/FtpProtocolHandler.h @@ -22,6 +22,7 @@ #include "nsError.h" #include "nsIProtocolHandler.h" #include "nsCURILoader.h" +#include "BaseProtocolContentHandler.h" #define G_FTP_PROTOCOL_CID \ { /* 5a48bdf4-a422-4eb4-b073-0fc3bee8e670 */ \ @@ -45,8 +46,14 @@ } #define NS_FTPPROTOCOLHANDLER_CLASSNAME "The FTP Protocol Handler" -class nsIFactory; - -extern nsresult NS_NewFtpHandlerFactory(nsIFactory** aFactory); +class GFtpProtocolHandler : public GBaseProtocolContentHandler +{ + public: + NS_DECL_ISUPPORTS + GFtpProtocolHandler() : GBaseProtocolContentHandler("ftp") + {NS_INIT_ISUPPORTS();}; + virtual ~GFtpProtocolHandler() {}; + /* additional members */ +}; #endif // __FtpProtocolHandler_h__ diff --git a/embed/mozilla/GlobalHistory.cpp b/embed/mozilla/GlobalHistory.cpp index a6d95970a..09c2c994a 100644 --- a/embed/mozilla/GlobalHistory.cpp +++ b/embed/mozilla/GlobalHistory.cpp @@ -17,43 +17,16 @@ */ #include "ephy-embed-shell.h" - +#include "GlobalHistory.h" #include "nsCOMPtr.h" #include "nsISupportsArray.h" #include "nsIFactory.h" #include "nsIServiceManager.h" -#include "nsXPComFactory.h" #include "nsString.h" #include "nsReadableUtils.h" -#include "nsIGlobalHistory.h" -#include "nsIBrowserHistory.h" #include "nsIRequestObserver.h" -/** - * class GlobalHistory: - * - */ -class MozGlobalHistory: public nsIGlobalHistory, - public nsIBrowserHistory -{ - public: - MozGlobalHistory (); - virtual ~MozGlobalHistory(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIGLOBALHISTORY - NS_DECL_NSIBROWSERHISTORY - - private: - EphyHistory *mGlobalHistory; -}; - -NS_IMPL_ADDREF(MozGlobalHistory) -NS_IMPL_RELEASE(MozGlobalHistory) -NS_INTERFACE_MAP_BEGIN(MozGlobalHistory) - NS_INTERFACE_MAP_ENTRY(nsIGlobalHistory) - NS_INTERFACE_MAP_ENTRY(nsIBrowserHistory) -NS_INTERFACE_MAP_END +NS_IMPL_ISUPPORTS2(MozGlobalHistory, nsIGlobalHistory, nsIBrowserHistory) MozGlobalHistory::MozGlobalHistory () { @@ -149,21 +122,3 @@ NS_IMETHODIMP MozGlobalHistory::MarkPageAsTyped(const char *url) return NS_ERROR_NOT_IMPLEMENTED; } -NS_DEF_FACTORY (MozGlobalHistory, MozGlobalHistory); - -nsresult NS_NewGlobalHistoryFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsMozGlobalHistoryFactory *result = new nsMozGlobalHistoryFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embed/mozilla/GlobalHistory.h b/embed/mozilla/GlobalHistory.h index 5b2e615a1..f1d810f6a 100644 --- a/embed/mozilla/GlobalHistory.h +++ b/embed/mozilla/GlobalHistory.h @@ -20,12 +20,32 @@ #define __GlobalHistory_h #include "nsError.h" +#include "nsIGlobalHistory.h" +#include "nsIBrowserHistory.h" -#define GALEON_GLOBALHISTORY_CID \ +#define EPHY_GLOBALHISTORY_CLASSNAME \ + "Epiphany's Global History Implementation" + +#define EPHY_GLOBALHISTORY_CID \ { 0xbe0c42c1, 0x39d4, 0x4271, { 0xb7, 0x9e, 0xf7, 0xaa, 0x49, 0xeb, 0x6a, 0x15}} -class nsIFactory; +/** + * class GlobalHistory: + * + */ +class MozGlobalHistory: public nsIGlobalHistory, + public nsIBrowserHistory +{ + public: + MozGlobalHistory (); + virtual ~MozGlobalHistory(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIGLOBALHISTORY + NS_DECL_NSIBROWSERHISTORY -extern nsresult NS_NewGlobalHistoryFactory(nsIFactory** aFactory); + private: + EphyHistory *mGlobalHistory; +}; #endif diff --git a/embed/mozilla/IRCProtocolHandler.cpp b/embed/mozilla/IRCProtocolHandler.cpp index b1c4d7f68..106ec98c1 100644 --- a/embed/mozilla/IRCProtocolHandler.cpp +++ b/embed/mozilla/IRCProtocolHandler.cpp @@ -16,43 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "nsIFactory.h" -#include "nsXPComFactory.h" - -#include "BaseProtocolContentHandler.h" - -class GIRCProtocolHandler : public GBaseProtocolContentHandler -{ - public: - NS_DECL_ISUPPORTS - GIRCProtocolHandler() : GBaseProtocolContentHandler("irc") - {NS_INIT_ISUPPORTS();}; - virtual ~GIRCProtocolHandler() {}; - /* additional members */ -}; +#include "IRCProtocolHandler.h" /* Implementation file */ NS_IMPL_ISUPPORTS2 (GIRCProtocolHandler, nsIProtocolHandler, nsIContentHandler) -NS_DEF_FACTORY (GIRCProtocolHandler, GIRCProtocolHandler); - -/** - * NS_NewIRCHandlerFactory: - */ -nsresult NS_NewIRCHandlerFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsGIRCProtocolHandlerFactory *result = - new nsGIRCProtocolHandlerFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embed/mozilla/IRCProtocolHandler.h b/embed/mozilla/IRCProtocolHandler.h index f50ae3f12..abe971380 100644 --- a/embed/mozilla/IRCProtocolHandler.h +++ b/embed/mozilla/IRCProtocolHandler.h @@ -20,6 +20,7 @@ #define __IRCProtocolHandler_h__ #include "nsError.h" +#include "BaseProtocolContentHandler.h" #include "nsIProtocolHandler.h" #include "nsCURILoader.h" @@ -36,8 +37,14 @@ "application-x-gnome-irc" #define G_IRC_CONTENT_CLASSNAME "Epiphany's irc Content Handler" -class nsIFactory; - -extern nsresult NS_NewIRCHandlerFactory(nsIFactory** aFactory); +class GIRCProtocolHandler : public GBaseProtocolContentHandler +{ + public: + NS_DECL_ISUPPORTS + GIRCProtocolHandler() : GBaseProtocolContentHandler("irc") + {NS_INIT_ISUPPORTS();}; + virtual ~GIRCProtocolHandler() {}; + /* additional members */ +}; #endif // __IRCProtocolHandler_h__ diff --git a/embed/mozilla/MailtoProtocolHandler.cpp b/embed/mozilla/MailtoProtocolHandler.cpp index 946f14aff..42ab590ac 100644 --- a/embed/mozilla/MailtoProtocolHandler.cpp +++ b/embed/mozilla/MailtoProtocolHandler.cpp @@ -16,49 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "nsIFactory.h" -#include "nsXPComFactory.h" -#include "nsString.h" -#include "nsIURI.h" -#include "nsNetUtil.h" -#include "nsIExternalProtocolService.h" -#include "nsCExternalHandlerService.h" -#include "nsCRT.h" - -#include "BaseProtocolContentHandler.h" - -class GMailtoProtocolHandler : public GBaseProtocolContentHandler -{ - public: - NS_DECL_ISUPPORTS - GMailtoProtocolHandler() : GBaseProtocolContentHandler("mailto") - {NS_INIT_ISUPPORTS();}; - virtual ~GMailtoProtocolHandler() {}; - private: -}; +#include "MailtoProtocolHandler.h" /* Implementation file */ NS_IMPL_ISUPPORTS2 (GMailtoProtocolHandler, nsIProtocolHandler, nsIContentHandler) -NS_DEF_FACTORY (GMailtoProtocolHandler, GMailtoProtocolHandler); - -/** - * NS_NewMailtoHandlerFactory: - */ -nsresult NS_NewMailtoHandlerFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsGMailtoProtocolHandlerFactory *result = - new nsGMailtoProtocolHandlerFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embed/mozilla/MailtoProtocolHandler.h b/embed/mozilla/MailtoProtocolHandler.h index 643fd7db7..2d269c588 100644 --- a/embed/mozilla/MailtoProtocolHandler.h +++ b/embed/mozilla/MailtoProtocolHandler.h @@ -22,6 +22,7 @@ #include "nsError.h" #include "nsIProtocolHandler.h" #include "nsCURILoader.h" +#include "BaseProtocolContentHandler.h" #define G_MAILTO_PROTOCOL_CID \ { /* aabe33d3-7455-4d8f-87e7-43e4541ace4d */ \ @@ -36,8 +37,14 @@ "application-x-gnome-mailto" #define G_MAILTO_CONTENT_CLASSNAME "Epiphany's mailto Content Handler" -class nsIFactory; - -extern nsresult NS_NewMailtoHandlerFactory(nsIFactory** aFactory); +class GMailtoProtocolHandler : public GBaseProtocolContentHandler +{ + public: + NS_DECL_ISUPPORTS + GMailtoProtocolHandler() : GBaseProtocolContentHandler("mailto") + {NS_INIT_ISUPPORTS();}; + virtual ~GMailtoProtocolHandler() {}; + private: +}; #endif // __MailtoProtocolHandler_h__ diff --git a/embed/mozilla/MozRegisterComponents.cpp b/embed/mozilla/MozRegisterComponents.cpp index bb3db8930..e35a88d3a 100644 --- a/embed/mozilla/MozRegisterComponents.cpp +++ b/embed/mozilla/MozRegisterComponents.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001 Philip Langdale + * Copyright (C) 2001,2002,2003 Philip Langdale * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,39 +20,159 @@ #include <config.h> #endif -#include "EphyAboutRedirector.h" -#include "StartHereProtocolHandler.h" #include "ContentHandler.h" -#include "ExternalProtocolService.h" #include "FilePicker.h" #include "FtpProtocolHandler.h" +#include "StartHereProtocolHandler.h" +#include "GlobalHistory.h" #include "IRCProtocolHandler.h" #include "MailtoProtocolHandler.h" #include "PrintingPromptService.h" #include "ProgressListener.h" +#include "ExternalProtocolService.h" +#include "EphyAboutRedirector.h" -#include <nsIFactory.h> -#include <nsIComponentManager.h> +#include <nsIGenericFactory.h> +#include <nsIComponentRegistrar.h> #include <nsCOMPtr.h> +#include <nsILocalFile.h> #include <glib.h> -static NS_DEFINE_CID(kContentHandlerCID, G_CONTENTHANDLER_CID); -static NS_DEFINE_CID(kProtocolServiceCID, G_EXTERNALPROTOCOLSERVICE_CID); -static NS_DEFINE_CID(kFilePickerCID, G_FILEPICKER_CID); -static NS_DEFINE_CID(kStartHereProcotolHandlerCID, G_START_HERE_PROTOCOLHANDLER_CID); -static NS_DEFINE_CID(kEphyAboutRedirectorCID, EPHY_ABOUT_REDIRECTOR_CID); -static NS_DEFINE_CID(knsFtpProtocolHandlerCID, NS_FTPPROTOCOLHANDLER_CID); -static NS_DEFINE_CID(kFtpHandlerCID, G_FTP_PROTOCOL_CID); -static NS_DEFINE_CID(kIRCHandlerCID, G_IRC_PROTOCOL_CID); -static NS_DEFINE_CID(kMailtoHandlerCID, G_MAILTO_PROTOCOL_CID); -static NS_DEFINE_CID(kPrintingPromptServiceCID, G_PRINTINGPROMPTSERVICE_CID); -static NS_DEFINE_CID(kProgressDialogCID, G_PROGRESSDIALOG_CID); +NS_GENERIC_FACTORY_CONSTRUCTOR(EphyAboutRedirector) +NS_GENERIC_FACTORY_CONSTRUCTOR(GStartHereProtocolHandler) +NS_GENERIC_FACTORY_CONSTRUCTOR(GProgressListener) +NS_GENERIC_FACTORY_CONSTRUCTOR(GFilePicker) +NS_GENERIC_FACTORY_CONSTRUCTOR(GContentHandler) +NS_GENERIC_FACTORY_CONSTRUCTOR(MozGlobalHistory) +NS_GENERIC_FACTORY_CONSTRUCTOR(GPrintingPromptService) +NS_GENERIC_FACTORY_CONSTRUCTOR(GIRCProtocolHandler) +NS_GENERIC_FACTORY_CONSTRUCTOR(GFtpProtocolHandler) + +static const nsModuleComponentInfo sAppComps[] = { + { + G_PROGRESSDIALOG_CLASSNAME, + G_PROGRESSDIALOG_CID, + G_PROGRESSDIALOG_CONTRACTID, + GProgressListenerConstructor + }, + { + G_PROGRESSDIALOG_CLASSNAME, + G_PROGRESSDIALOG_CID, + NS_DOWNLOAD_CONTRACTID, + GProgressListenerConstructor + }, + { + G_FILEPICKER_CLASSNAME, + G_FILEPICKER_CID, + G_FILEPICKER_CONTRACTID, + GFilePickerConstructor + }, + { + NS_IHELPERAPPLAUNCHERDLG_CLASSNAME, + G_CONTENTHANDLER_CID, + NS_IHELPERAPPLAUNCHERDLG_CONTRACTID, + GContentHandlerConstructor + }, + { + EPHY_GLOBALHISTORY_CLASSNAME, + EPHY_GLOBALHISTORY_CID, + NS_GLOBALHISTORY_CONTRACTID, + MozGlobalHistoryConstructor + }, + { + G_PRINTINGPROMPTSERVICE_CLASSNAME, + G_PRINTINGPROMPTSERVICE_CID, + G_PRINTINGPROMPTSERVICE_CONTRACTID, + GPrintingPromptServiceConstructor + }, + { + G_IRC_PROTOCOL_CLASSNAME, + G_IRC_PROTOCOL_CID, + G_IRC_PROTOCOL_CONTRACTID, + GIRCProtocolHandlerConstructor + }, + { + G_IRC_CONTENT_CLASSNAME, + G_IRC_PROTOCOL_CID, + G_IRC_CONTENT_CONTRACTID, + GIRCProtocolHandlerConstructor + }, + { + G_FTP_CONTENT_CLASSNAME, + G_FTP_PROTOCOL_CID, + G_FTP_CONTENT_CONTRACTID, + GFtpProtocolHandlerConstructor + }, + { + G_START_HERE_PROTOCOLHANDLER_CLASSNAME, + G_START_HERE_PROTOCOLHANDLER_CID, + G_START_HERE_PROTOCOLHANDLER_CONTRACTID, + GStartHereProtocolHandlerConstructor + }, + { + EPHY_ABOUT_REDIRECTOR_CLASSNAME, + EPHY_ABOUT_REDIRECTOR_CID, + EPHY_ABOUT_REDIRECTOR_EPIPHANY_CONTRACTID, + EphyAboutRedirectorConstructor + }, + { + EPHY_ABOUT_REDIRECTOR_CLASSNAME, + EPHY_ABOUT_REDIRECTOR_CID, + EPHY_ABOUT_REDIRECTOR_OPTIONS_CONTRACTID, + EphyAboutRedirectorConstructor + }, + { + EPHY_ABOUT_REDIRECTOR_CLASSNAME, + EPHY_ABOUT_REDIRECTOR_CID, + EPHY_ABOUT_REDIRECTOR_CONSPIRACY_CONTRACTID, + EphyAboutRedirectorConstructor + }, + { + EPHY_ABOUT_REDIRECTOR_CLASSNAME, + EPHY_ABOUT_REDIRECTOR_CID, + EPHY_ABOUT_REDIRECTOR_MARCO_CONTRACTID, + EphyAboutRedirectorConstructor + } +}; + +static const int sNumAppComps = sizeof(sAppComps) / sizeof(nsModuleComponentInfo); + +static const nsModuleComponentInfo sFtpComps = { + G_FTP_PROTOCOL_CLASSNAME, + G_FTP_PROTOCOL_CID, + G_FTP_PROTOCOL_CONTRACTID, + GFtpProtocolHandlerConstructor +}; + +NS_GENERIC_FACTORY_CONSTRUCTOR(GMailtoProtocolHandler) + +static const nsModuleComponentInfo sMailtoComps[] = { + { + G_MAILTO_PROTOCOL_CLASSNAME, + G_MAILTO_PROTOCOL_CID, + G_MAILTO_PROTOCOL_CONTRACTID, + GMailtoProtocolHandlerConstructor + }, + { + G_MAILTO_CONTENT_CLASSNAME, + G_MAILTO_PROTOCOL_CID, + G_MAILTO_CONTENT_CONTRACTID, + GMailtoProtocolHandlerConstructor + } +}; + +static const int sNumMailtoComps = sizeof(sMailtoComps) / sizeof(nsModuleComponentInfo); + +static const nsModuleComponentInfo sModuleComps[] = { + { + G_EXTERNALPROTOCOLSERVICE_CLASSNAME, + G_EXTERNALPROTOCOLSERVICE_CID, + NS_EXTERNALPROTOCOLSERVICE_CONTRACTID + } +}; -//RegisterFactory is local -NS_METHOD RegisterFactory (nsresult (aFactoryFunc)(nsIFactory** aFactory), - const nsCID & aClass, const char *aClassName, - const char *aContractID, PRBool aReplace); +static NS_DEFINE_CID(knsFtpProtocolHandlerCID, NS_FTPPROTOCOLHANDLER_CID); //Annoying globals to track the mozilla ftp handler so it can be restored. static PRBool ftpRegistered = PR_FALSE; @@ -66,121 +186,63 @@ mozilla_register_components (void) gboolean ret = TRUE; nsresult rv; - rv = RegisterFactory (NS_NewProgressListenerFactory, kProgressDialogCID, - G_PROGRESSDIALOG_CLASSNAME, - NS_DOWNLOAD_CONTRACTID, PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewContentHandlerFactory, kContentHandlerCID, - NS_IHELPERAPPLAUNCHERDLG_CLASSNAME, - NS_IHELPERAPPLAUNCHERDLG_CONTRACTID, PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewExternalProtocolServiceFactory, - kProtocolServiceCID, - G_EXTERNALPROTOCOLSERVICE_CLASSNAME, - NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, - PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewFilePickerFactory, kFilePickerCID, - G_FILEPICKER_CLASSNAME, G_FILEPICKER_CONTRACTID, - PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewStartHereHandlerFactory, - kStartHereProcotolHandlerCID, - G_START_HERE_PROTOCOLHANDLER_CLASSNAME, - G_START_HERE_PROTOCOLHANDLER_CONTRACTID, - PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewEphyAboutRedirectorFactory, - kEphyAboutRedirectorCID, - EPHY_ABOUT_REDIRECTOR_CLASSNAME, - EPHY_ABOUT_REDIRECTOR_OPTIONS_CONTRACTID, - PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewEphyAboutRedirectorFactory, - kEphyAboutRedirectorCID, - EPHY_ABOUT_REDIRECTOR_CLASSNAME, - EPHY_ABOUT_REDIRECTOR_EPIPHANY_CONTRACTID, - PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewEphyAboutRedirectorFactory, - kEphyAboutRedirectorCID, - EPHY_ABOUT_REDIRECTOR_CLASSNAME, - EPHY_ABOUT_REDIRECTOR_MARCO_CONTRACTID, - PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewEphyAboutRedirectorFactory, - kEphyAboutRedirectorCID, - EPHY_ABOUT_REDIRECTOR_CLASSNAME, - EPHY_ABOUT_REDIRECTOR_CONSPIRACY_CONTRACTID, - PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - - rv = RegisterFactory (NS_NewFtpHandlerFactory, kFtpHandlerCID, - G_FTP_CONTENT_CLASSNAME, G_FTP_CONTENT_CONTRACTID, - PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewIRCHandlerFactory, kIRCHandlerCID, - G_IRC_PROTOCOL_CLASSNAME, - G_IRC_PROTOCOL_CONTRACTID, PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewIRCHandlerFactory, kIRCHandlerCID, - G_IRC_CONTENT_CLASSNAME, - G_IRC_CONTENT_CONTRACTID, PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; - - rv = RegisterFactory (NS_NewPrintingPromptServiceFactory, - kPrintingPromptServiceCID, - G_PRINTINGPROMPTSERVICE_CLASSNAME, - G_PRINTINGPROMPTSERVICE_CONTRACTID, PR_TRUE); - if (NS_FAILED(rv)) ret = FALSE; + nsCOMPtr<nsIComponentRegistrar> cr; + rv = NS_GetComponentRegistrar(getter_AddRefs(cr)); + NS_ENSURE_SUCCESS(rv, rv); + + for (int i = 0; i < sNumAppComps; i++) + { + nsCOMPtr<nsIGenericFactory> componentFactory; + rv = NS_NewGenericFactory(getter_AddRefs(componentFactory), + &(sAppComps[i])); + if (NS_FAILED(rv)) + { + ret = FALSE; + continue; // don't abort registering other components + } + + rv = cr->RegisterFactory(sAppComps[i].mCID, + sAppComps[i].mDescription, + sAppComps[i].mContractID, + componentFactory); + if (NS_FAILED(rv)) + ret = FALSE; + } return ret; } -NS_METHOD RegisterFactory (nsresult (aFactoryFunc)(nsIFactory** aFactory), - const nsCID & aClass, const char *aClassName, - const char *aContractID, PRBool aReplace) -{ - nsresult rv = NS_OK; - - nsCOMPtr<nsIFactory> factory; - rv = aFactoryFunc(getter_AddRefs(factory)); - if (NS_FAILED(rv)) return rv; - rv = nsComponentManager::RegisterFactory(aClass, aClassName, - aContractID, - factory, aReplace); - return rv; -} - /** * mozilla_register_FtpProtocolHandler: Register Ftp Protocol Handler */ -extern "C" gboolean -mozilla_register_FtpProtocolHandler (void) +extern "C" gboolean mozilla_register_FtpProtocolHandler (void) { if (ftpRegistered == PR_TRUE) return TRUE; nsresult rv = NS_OK; - - rv = nsComponentManager::FindFactory (knsFtpProtocolHandlerCID, - getter_AddRefs(nsFtpFactory)); + + nsCOMPtr<nsIComponentManager> cm; + rv = NS_GetComponentManager(getter_AddRefs(cm)); + if (NS_FAILED(rv) || !cm) return FALSE; + + rv = cm->GetClassObject(knsFtpProtocolHandlerCID, + NS_GET_IID(nsIFactory), + getter_AddRefs(nsFtpFactory)); if (NS_FAILED(rv)) return FALSE; - rv = RegisterFactory (NS_NewFtpHandlerFactory, kFtpHandlerCID, - G_FTP_PROTOCOL_CLASSNAME, - G_FTP_PROTOCOL_CONTRACTID, PR_TRUE); + nsCOMPtr<nsIGenericFactory> ftpFactory; + rv = NS_NewGenericFactory(getter_AddRefs(ftpFactory), + &sFtpComps); + if (NS_FAILED(rv) || !ftpFactory) return FALSE; + nsCOMPtr<nsIComponentRegistrar> cr; + rv = NS_GetComponentRegistrar(getter_AddRefs(cr)); + if (NS_FAILED(rv) || !cr) return FALSE; + + rv = cr->RegisterFactory(sFtpComps.mCID, + sFtpComps.mDescription, + sFtpComps.mContractID, + ftpFactory); if (NS_FAILED(rv)) return FALSE; ftpRegistered = PR_TRUE; @@ -190,17 +252,20 @@ mozilla_register_FtpProtocolHandler (void) /** * mozilla_unregister_FtpProtocolHandler: Unregister Ftp Protocol Handler */ -extern "C" gboolean -mozilla_unregister_FtpProtocolHandler (void) +extern "C" gboolean mozilla_unregister_FtpProtocolHandler (void) { if (ftpRegistered == PR_FALSE) return FALSE; nsresult rv = NS_OK; - - rv = nsComponentManager::RegisterFactory(knsFtpProtocolHandlerCID, - NS_FTPPROTOCOLHANDLER_CLASSNAME, - G_FTP_PROTOCOL_CONTRACTID, - nsFtpFactory, PR_TRUE); + + nsCOMPtr<nsIComponentRegistrar> cr; + rv = NS_GetComponentRegistrar(getter_AddRefs(cr)); + if (NS_FAILED(rv) || !cr) return FALSE; + + rv = cr->RegisterFactory(knsFtpProtocolHandlerCID, + NS_FTPPROTOCOLHANDLER_CLASSNAME, + G_FTP_PROTOCOL_CONTRACTID, + nsFtpFactory); ftpRegistered = PR_FALSE; return NS_SUCCEEDED (rv) ? TRUE : FALSE; @@ -212,15 +277,30 @@ mozilla_unregister_FtpProtocolHandler (void) extern "C" gboolean mozilla_register_MailtoProtocolHandler (void) { - nsresult rv = NS_OK; - - rv = RegisterFactory (NS_NewMailtoHandlerFactory, kMailtoHandlerCID, - G_MAILTO_PROTOCOL_CLASSNAME, - G_MAILTO_PROTOCOL_CONTRACTID, PR_TRUE); - if (NS_FAILED(rv)) return FALSE; - - rv = RegisterFactory (NS_NewMailtoHandlerFactory, kMailtoHandlerCID, - G_MAILTO_CONTENT_CLASSNAME, - G_MAILTO_CONTENT_CONTRACTID, PR_TRUE); - return NS_SUCCEEDED (rv) ? TRUE : FALSE; + gboolean retVal = TRUE; + nsresult rv; + + nsCOMPtr<nsIComponentRegistrar> cr; + rv = NS_GetComponentRegistrar(getter_AddRefs(cr)); + if (NS_FAILED(rv) || !cr) return FALSE; + + for (int i = 0; i < sNumMailtoComps; i++) + { + nsCOMPtr<nsIGenericFactory> componentFactory; + rv = NS_NewGenericFactory(getter_AddRefs(componentFactory), + &(sMailtoComps[i])); + if (NS_FAILED(rv)) + { + retVal = FALSE; + continue; // don't abort registering other components + } + + rv = cr->RegisterFactory(sMailtoComps[i].mCID, + sMailtoComps[i].mDescription, + sMailtoComps[i].mContractID, + componentFactory); + if (NS_FAILED(rv)) + retVal = FALSE; + } + return retVal; } diff --git a/embed/mozilla/PrintingPromptService.cpp b/embed/mozilla/PrintingPromptService.cpp index 183da034c..a66cb5379 100644 --- a/embed/mozilla/PrintingPromptService.cpp +++ b/embed/mozilla/PrintingPromptService.cpp @@ -25,27 +25,12 @@ #include "print-dialog.h" #include "ephy-embed.h" #include "MozillaPrivate.h" +#include "PrintingPromptService.h" #include <nsIPrintSettings.h> #include <nsCOMPtr.h> -#include <nsIFactory.h> #include <nsString.h> #include <nsIServiceManager.h> -#include <nsXPComFactory.h> - -#include <nsIPrintingPromptService.h> - -/* Header file */ -class GPrintingPromptService : public nsIPrintingPromptService -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIPRINTINGPROMPTSERVICE - - GPrintingPromptService(); - virtual ~GPrintingPromptService(); - /* additional members */ -}; /* Implementation file */ NS_IMPL_ISUPPORTS1(GPrintingPromptService, nsIPrintingPromptService) @@ -102,25 +87,3 @@ NS_IMETHODIMP GPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent { return NS_ERROR_NOT_IMPLEMENTED; } - -NS_DEF_FACTORY (GPrintingPromptService, GPrintingPromptService); - -/** - * NS_NewPromptServiceFactory: - */ -nsresult NS_NewPrintingPromptServiceFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsGPrintingPromptServiceFactory *result = new nsGPrintingPromptServiceFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embed/mozilla/PrintingPromptService.h b/embed/mozilla/PrintingPromptService.h index e4b2239c1..2b878a70a 100644 --- a/embed/mozilla/PrintingPromptService.h +++ b/embed/mozilla/PrintingPromptService.h @@ -20,6 +20,7 @@ #define __PrintingPromptService_h #include "nsError.h" +#include "nsIPrintingPromptService.h" #define G_PRINTINGPROMPTSERVICE_CID \ { /* 5998a2d3-88ea-4c52-b4bb-4e7abd0d35e0 */ \ @@ -31,8 +32,16 @@ #define G_PRINTINGPROMPTSERVICE_CLASSNAME "Epiphany's Printing Prompt Service" #define G_PRINTINGPROMPTSERVICE_CONTRACTID "@mozilla.org/embedcomp/printingprompt-service;1" -class nsIFactory; -extern nsresult NS_NewPrintingPromptServiceFactory(nsIFactory** aFactory); +class GPrintingPromptService : public nsIPrintingPromptService +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPRINTINGPROMPTSERVICE + + GPrintingPromptService(); + virtual ~GPrintingPromptService(); + /* additional members */ +}; #endif diff --git a/embed/mozilla/ProgressListener.cpp b/embed/mozilla/ProgressListener.cpp index f0d719669..43a0acd06 100644 --- a/embed/mozilla/ProgressListener.cpp +++ b/embed/mozilla/ProgressListener.cpp @@ -33,8 +33,6 @@ #include "nsXPIDLString.h" #include "nsIChannel.h" #include "nsIFTPChannel.h" -#include "nsIFactory.h" -#include "nsXPComFactory.h" #include "nsIMIMEInfo.h" #include "nsCOMPtr.h" @@ -689,28 +687,6 @@ nsresult GProgressListener::Abort (void) return NS_OK; } -NS_DEF_FACTORY (GProgressListener, GProgressListener); - -/** - * NS_NewProgressListenerFactory: - */ -nsresult NS_NewProgressListenerFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsGProgressListenerFactory *result = new nsGProgressListenerFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} - static void download_remove_cb (DownloaderView *dv, GProgressListener *Progress) { diff --git a/embed/mozilla/StartHereProtocolHandler.cpp b/embed/mozilla/StartHereProtocolHandler.cpp index 2f7270490..987415435 100644 --- a/embed/mozilla/StartHereProtocolHandler.cpp +++ b/embed/mozilla/StartHereProtocolHandler.cpp @@ -22,30 +22,16 @@ #include <string.h> -#include "nsCOMPtr.h" -#include "nsIFactory.h" +#include "StartHereProtocolHandler.h" #include "nsIIOService.h" #include "nsIServiceManager.h" #include "nsIURI.h" #include "nsNetCID.h" #include "nsNetUtil.h" -#include "nsXPComFactory.h" #include "nsIStorageStream.h" static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); -class GStartHereProtocolHandler : public nsIProtocolHandler -{ - public: - NS_DECL_ISUPPORTS - NS_DECL_NSIPROTOCOLHANDLER - - GStartHereProtocolHandler (void); - virtual ~GStartHereProtocolHandler(); - - nsCOMPtr<nsIChannel> mChannel; -}; - /* Implementation file */ NS_IMPL_ISUPPORTS1 (GStartHereProtocolHandler, nsIProtocolHandler) @@ -199,24 +185,3 @@ NS_IMETHODIMP GStartHereProtocolHandler::AllowPort(PRInt32 port, const char *sch return NS_OK; } -NS_DEF_FACTORY (GStartHereProtocolHandler, GStartHereProtocolHandler); - -/** - * NS_NewStartHereProtocolHandlerFactory: - */ -nsresult NS_NewStartHereHandlerFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - nsGStartHereProtocolHandlerFactory *result = new nsGStartHereProtocolHandlerFactory; - if (result == NULL) - { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embed/mozilla/StartHereProtocolHandler.h b/embed/mozilla/StartHereProtocolHandler.h index fc3125423..ea18ee39d 100644 --- a/embed/mozilla/StartHereProtocolHandler.h +++ b/embed/mozilla/StartHereProtocolHandler.h @@ -20,6 +20,9 @@ #define StartHereProtocolHandler_h__ #include "nsError.h" +#include "nsIProtocolHandler.h" +#include "nsCOMPtr.h" +#include "nsIChannel.h" #define G_START_HERE_PROTOCOLHANDLER_CID \ { /* a3a7b6e5-7a92-431d-87e6-3bef8e7ada51*/ \ @@ -31,8 +34,16 @@ #define G_START_HERE_PROTOCOLHANDLER_CONTRACTID NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "start-here" #define G_START_HERE_PROTOCOLHANDLER_CLASSNAME "Epiphany's start here protocol handler" -class nsIFactory; +class GStartHereProtocolHandler : public nsIProtocolHandler +{ + public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPROTOCOLHANDLER -extern nsresult NS_NewStartHereHandlerFactory(nsIFactory** aFactory); + GStartHereProtocolHandler (void); + virtual ~GStartHereProtocolHandler(); -#endif // MyportalProtocolHandler_h__ + nsCOMPtr<nsIChannel> mChannel; +}; + +#endif // StarthereProtocolHandler_h__ diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index 467fcbfa1..78304cd15 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -979,6 +979,8 @@ impl_shistory_get_nth (EphyEmbed *embed, *aTitle = g_strdup (NS_ConvertUCS2toUTF8(title).get()); + nsMemory::Free (title); + return G_OK; } |