aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/BaseProtocolContentHandler.cpp104
-rw-r--r--embed/mozilla/BaseProtocolContentHandler.h43
-rw-r--r--embed/mozilla/BaseProtocolHandler.cpp106
-rw-r--r--embed/mozilla/BaseProtocolHandler.h39
-rw-r--r--embed/mozilla/ExternalProtocolHandlers.cpp167
-rw-r--r--embed/mozilla/ExternalProtocolHandlers.h52
-rw-r--r--embed/mozilla/Makefile.am4
-rw-r--r--embed/mozilla/MozRegisterComponents.cpp1
8 files changed, 210 insertions, 306 deletions
diff --git a/embed/mozilla/BaseProtocolContentHandler.cpp b/embed/mozilla/BaseProtocolContentHandler.cpp
deleted file mode 100644
index d381d0b17..000000000
--- a/embed/mozilla/BaseProtocolContentHandler.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2001 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "nsCOMPtr.h"
-#include "nsIURI.h"
-#include "nsIChannel.h"
-#include "nsIStorageStream.h"
-#include "nsIInputStream.h"
-#include "nsIOutputStream.h"
-#include "nsNetUtil.h"
-#include "nsIExternalProtocolService.h"
-#include "nsCExternalHandlerService.h"
-
-#include "BaseProtocolContentHandler.h"
-
-/* Implementation file */
-NS_IMPL_ISUPPORTS2 (GBaseProtocolContentHandler, nsIProtocolHandler, nsIContentHandler)
-
-GBaseProtocolContentHandler::GBaseProtocolContentHandler(const char *aScheme) :
- GBaseProtocolHandler(aScheme)
-{
- NS_INIT_ISUPPORTS();
- /* member initializers and constructor code */
- mMimeType = NS_LITERAL_CSTRING("application-x-gnome-") + mScheme;
-}
-
-GBaseProtocolContentHandler::~GBaseProtocolContentHandler()
-{
- /* destructor code */
-}
-
-/* nsIChannel newChannel (in nsIURI aURI); */
-NS_IMETHODIMP GBaseProtocolContentHandler::NewChannel(nsIURI *aURI,
- nsIChannel **_retval)
-{
- nsCOMPtr<nsIStorageStream> sStream;
- nsresult rv = NS_NewStorageStream(1, 16, getter_AddRefs(sStream));
- if (NS_FAILED(rv)) return rv;
-
- nsCOMPtr<nsIOutputStream> oStream;
- rv = sStream->GetOutputStream(0, getter_AddRefs(oStream));
-
- PRUint32 bytes;
- oStream->Write("Dummy stream\0", 13, &bytes);
-
- nsCOMPtr<nsIInputStream> iStream;
- rv = sStream->NewInputStream(0, getter_AddRefs(iStream));
- if (NS_FAILED(rv)) return rv;
-
- nsCOMPtr<nsIChannel> channel;
- rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI,
- iStream, mMimeType, NS_LITERAL_CSTRING(""));
- if (NS_FAILED(rv)) return rv;
-
- NS_IF_ADDREF (*_retval = channel);
- return rv;
-}
-
-NS_IMETHODIMP GBaseProtocolContentHandler::HandleContent (
- const char * aContentType,
- const char * aCommand,
- nsISupports * aWindowContext,
- nsIRequest *aRequest)
-{
- nsresult rv = NS_OK;
- if (!aRequest)
- return NS_ERROR_NULL_POINTER;
- // First of all, get the content type and make sure it is a
- // content type we know how to handle!
- if (mMimeType.Equals(aContentType))
- {
- nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
- if(!channel) return NS_ERROR_FAILURE;
-
- nsCOMPtr<nsIURI> uri;
- rv = channel->GetURI(getter_AddRefs(uri));
- if (NS_FAILED(rv)) return rv;
-
- aRequest->Cancel(NS_BINDING_ABORTED);
- if (uri)
- {
- nsCOMPtr<nsIExternalProtocolService> ps =
- do_GetService (NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &rv);
- if (NS_FAILED(rv) || !ps) return NS_ERROR_FAILURE;
- ps->LoadUrl (uri);
- }
- }
- return rv;
-}
diff --git a/embed/mozilla/BaseProtocolContentHandler.h b/embed/mozilla/BaseProtocolContentHandler.h
deleted file mode 100644
index b1f5c1e71..000000000
--- a/embed/mozilla/BaseProtocolContentHandler.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2001 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BaseProtocolContentHandler_h_
-#define _BaseProtocolContentHandler_h_
-
-#include "BaseProtocolHandler.h"
-#include "nsIContentHandler.h"
-
-#include "nsString.h"
-
-class GBaseProtocolContentHandler : public GBaseProtocolHandler,
- public nsIContentHandler
-{
- public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSICONTENTHANDLER
-
- NS_IMETHODIMP NewChannel(nsIURI *aURI, nsIChannel **_retval);
-
- GBaseProtocolContentHandler (const char *aScheme);
- virtual ~GBaseProtocolContentHandler();
- /* additional members */
- protected:
- nsCString mMimeType;
-};
-
-#endif //_BaseProtocolContentHandler_h_
diff --git a/embed/mozilla/BaseProtocolHandler.cpp b/embed/mozilla/BaseProtocolHandler.cpp
deleted file mode 100644
index 728465a15..000000000
--- a/embed/mozilla/BaseProtocolHandler.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2001 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "nsCOMPtr.h"
-#include "nsIComponentManager.h"
-#include "nsIURI.h"
-#include "nsNetCID.h"
-
-#include "BaseProtocolHandler.h"
-
-static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
-
-/* Implementation file */
-NS_IMPL_ISUPPORTS1 (GBaseProtocolHandler, nsIProtocolHandler)
-
-GBaseProtocolHandler::GBaseProtocolHandler(const char *aScheme)
-{
- NS_INIT_ISUPPORTS();
- /* member initializers and constructor code */
- mScheme.Assign(aScheme);
-}
-
-GBaseProtocolHandler::~GBaseProtocolHandler()
-{
- /* destructor code */
-}
-
-/* readonly attribute string scheme; */
-NS_IMETHODIMP GBaseProtocolHandler::GetScheme(nsACString &aScheme)
-{
- aScheme = mScheme;
- return NS_OK;
-}
-
-/* readonly attribute long defaultPort; */
-NS_IMETHODIMP GBaseProtocolHandler::GetDefaultPort(PRInt32 *aDefaultPort)
-{
- if (aDefaultPort)
- *aDefaultPort = -1;
- else
- return NS_ERROR_NULL_POINTER;
- return NS_OK;
-}
-
-/* readonly attribute short protocolFlags; */
-NS_IMETHODIMP GBaseProtocolHandler::GetProtocolFlags(PRUint32 *aProtocolFlags)
-{
- if (aProtocolFlags)
- *aProtocolFlags = nsIProtocolHandler::URI_STD;
- else
- return NS_ERROR_NULL_POINTER;
- return NS_OK;
-}
-
-/* nsIURI newURI (in string aSpec, in nsIURI aBaseURI); */
-NS_IMETHODIMP GBaseProtocolHandler::NewURI(const nsACString &aSpec,
- const char *aOriginCharset, nsIURI *aBaseURI,
- nsIURI **_retval)
-{
- nsresult rv = NS_OK;
- nsCOMPtr <nsIURI> newUri;
-
- rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
- NS_GET_IID(nsIURI),
- getter_AddRefs(newUri));
-
- if (NS_SUCCEEDED(rv))
- {
- newUri->SetSpec(aSpec);
- rv = newUri->QueryInterface(NS_GET_IID(nsIURI),
- (void **) _retval);
- }
- return rv;
-
-}
-
-/* nsIChannel newChannel (in nsIURI aURI); */
-NS_IMETHODIMP GBaseProtocolHandler::NewChannel(nsIURI *aURI,
- nsIChannel **_retval)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* boolean allowPort (in long port, in string scheme); */
-NS_IMETHODIMP GBaseProtocolHandler::AllowPort(PRInt32 port, const char *scheme,
- PRBool *_retval)
-{
- *_retval = PR_FALSE;
- return NS_OK;
-}
-
diff --git a/embed/mozilla/BaseProtocolHandler.h b/embed/mozilla/BaseProtocolHandler.h
deleted file mode 100644
index ab25a680d..000000000
--- a/embed/mozilla/BaseProtocolHandler.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2001 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef _BaseProtocolHandler_h_
-#define _BaseProtocolHandler_h_
-
-#include "nsIProtocolHandler.h"
-
-#include "nsString.h"
-
-class GBaseProtocolHandler : public nsIProtocolHandler
-{
- public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSIPROTOCOLHANDLER
-
- GBaseProtocolHandler (const char *aScheme);
- virtual ~GBaseProtocolHandler();
- /* additional members */
- protected:
- nsCString mScheme;
-};
-
-#endif //_BaseProtocolHandler_h_
diff --git a/embed/mozilla/ExternalProtocolHandlers.cpp b/embed/mozilla/ExternalProtocolHandlers.cpp
index ff6f2a941..10b4283c8 100644
--- a/embed/mozilla/ExternalProtocolHandlers.cpp
+++ b/embed/mozilla/ExternalProtocolHandlers.cpp
@@ -17,8 +17,175 @@
*/
#include "ExternalProtocolHandlers.h"
+#include "nsCOMPtr.h"
+#include "nsIComponentManager.h"
+#include "nsIURI.h"
+#include "nsCOMPtr.h"
+#include "nsIChannel.h"
+#include "nsIStorageStream.h"
+#include "nsIInputStream.h"
+#include "nsIOutputStream.h"
+#include "nsNetUtil.h"
+#include "nsIExternalProtocolService.h"
+#include "nsCExternalHandlerService.h"
NS_IMPL_ISUPPORTS2 (GIRCProtocolHandler, nsIProtocolHandler, nsIContentHandler)
NS_IMPL_ISUPPORTS2 (GFtpProtocolHandler, nsIProtocolHandler, nsIContentHandler)
NS_IMPL_ISUPPORTS2 (GMailtoProtocolHandler, nsIProtocolHandler, nsIContentHandler)
NS_IMPL_ISUPPORTS2 (GNewsProtocolHandler, nsIProtocolHandler, nsIContentHandler)
+
+static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
+
+/* Implementation file */
+NS_IMPL_ISUPPORTS1 (GBaseProtocolHandler, nsIProtocolHandler)
+
+GBaseProtocolHandler::GBaseProtocolHandler(const char *aScheme)
+{
+ NS_INIT_ISUPPORTS();
+ /* member initializers and constructor code */
+ mScheme.Assign(aScheme);
+}
+
+GBaseProtocolHandler::~GBaseProtocolHandler()
+{
+ /* destructor code */
+}
+
+/* readonly attribute string scheme; */
+NS_IMETHODIMP GBaseProtocolHandler::GetScheme(nsACString &aScheme)
+{
+ aScheme = mScheme;
+ return NS_OK;
+}
+
+/* readonly attribute long defaultPort; */
+NS_IMETHODIMP GBaseProtocolHandler::GetDefaultPort(PRInt32 *aDefaultPort)
+{
+ if (aDefaultPort)
+ *aDefaultPort = -1;
+ else
+ return NS_ERROR_NULL_POINTER;
+ return NS_OK;
+}
+
+/* readonly attribute short protocolFlags; */
+NS_IMETHODIMP GBaseProtocolHandler::GetProtocolFlags(PRUint32 *aProtocolFlags)
+{
+ if (aProtocolFlags)
+ *aProtocolFlags = nsIProtocolHandler::URI_STD;
+ else
+ return NS_ERROR_NULL_POINTER;
+ return NS_OK;
+}
+
+/* nsIURI newURI (in string aSpec, in nsIURI aBaseURI); */
+NS_IMETHODIMP GBaseProtocolHandler::NewURI(const nsACString &aSpec,
+ const char *aOriginCharset, nsIURI *aBaseURI,
+ nsIURI **_retval)
+{
+ nsresult rv = NS_OK;
+ nsCOMPtr <nsIURI> newUri;
+
+ rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
+ NS_GET_IID(nsIURI),
+ getter_AddRefs(newUri));
+
+ if (NS_SUCCEEDED(rv))
+ {
+ newUri->SetSpec(aSpec);
+ rv = newUri->QueryInterface(NS_GET_IID(nsIURI),
+ (void **) _retval);
+ }
+ return rv;
+
+}
+
+/* nsIChannel newChannel (in nsIURI aURI); */
+NS_IMETHODIMP GBaseProtocolHandler::NewChannel(nsIURI *aURI,
+ nsIChannel **_retval)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* boolean allowPort (in long port, in string scheme); */
+NS_IMETHODIMP GBaseProtocolHandler::AllowPort(PRInt32 port, const char *scheme,
+ PRBool *_retval)
+{
+ *_retval = PR_FALSE;
+ return NS_OK;
+}
+
+/* Implementation file */
+NS_IMPL_ISUPPORTS2 (GBaseProtocolContentHandler, nsIProtocolHandler, nsIContentHandler)
+
+GBaseProtocolContentHandler::GBaseProtocolContentHandler(const char *aScheme) :
+ GBaseProtocolHandler(aScheme)
+{
+ NS_INIT_ISUPPORTS();
+ /* member initializers and constructor code */
+ mMimeType = NS_LITERAL_CSTRING("application-x-gnome-") + mScheme;
+}
+
+GBaseProtocolContentHandler::~GBaseProtocolContentHandler()
+{
+ /* destructor code */
+}
+
+/* nsIChannel newChannel (in nsIURI aURI); */
+NS_IMETHODIMP GBaseProtocolContentHandler::NewChannel(nsIURI *aURI,
+ nsIChannel **_retval)
+{
+ nsCOMPtr<nsIStorageStream> sStream;
+ nsresult rv = NS_NewStorageStream(1, 16, getter_AddRefs(sStream));
+ if (NS_FAILED(rv)) return rv;
+
+ nsCOMPtr<nsIOutputStream> oStream;
+ rv = sStream->GetOutputStream(0, getter_AddRefs(oStream));
+
+ PRUint32 bytes;
+ oStream->Write("Dummy stream\0", 13, &bytes);
+
+ nsCOMPtr<nsIInputStream> iStream;
+ rv = sStream->NewInputStream(0, getter_AddRefs(iStream));
+ if (NS_FAILED(rv)) return rv;
+
+ nsCOMPtr<nsIChannel> channel;
+ rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI,
+ iStream, mMimeType, NS_LITERAL_CSTRING(""));
+ if (NS_FAILED(rv)) return rv;
+
+ NS_IF_ADDREF (*_retval = channel);
+ return rv;
+}
+
+NS_IMETHODIMP GBaseProtocolContentHandler::HandleContent (
+ const char * aContentType,
+ const char * aCommand,
+ nsISupports * aWindowContext,
+ nsIRequest *aRequest)
+{
+ nsresult rv = NS_OK;
+ if (!aRequest)
+ return NS_ERROR_NULL_POINTER;
+ // First of all, get the content type and make sure it is a
+ // content type we know how to handle!
+ if (mMimeType.Equals(aContentType))
+ {
+ nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
+ if(!channel) return NS_ERROR_FAILURE;
+
+ nsCOMPtr<nsIURI> uri;
+ rv = channel->GetURI(getter_AddRefs(uri));
+ if (NS_FAILED(rv)) return rv;
+
+ aRequest->Cancel(NS_BINDING_ABORTED);
+ if (uri)
+ {
+ nsCOMPtr<nsIExternalProtocolService> ps =
+ do_GetService (NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &rv);
+ if (NS_FAILED(rv) || !ps) return NS_ERROR_FAILURE;
+ ps->LoadUrl (uri);
+ }
+ }
+ return rv;
+}
diff --git a/embed/mozilla/ExternalProtocolHandlers.h b/embed/mozilla/ExternalProtocolHandlers.h
index e2a47ef13..7ff6e275b 100644
--- a/embed/mozilla/ExternalProtocolHandlers.h
+++ b/embed/mozilla/ExternalProtocolHandlers.h
@@ -16,13 +16,54 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+/* We are registering protocol handlers for news, mailto and irc
+ because mozilla load all modules on startup, so if you have these
+ components installed it will try to use them as protocol handlers.
+ Our implementation just forward to external protocol service.
+ Ftp is a special case, it can be handled by mozilla but we
+ want to use an external client when one is configured in GNOME
+ handlers.
+ IMPORTANT: there is no need to register handlers for other protocols
+ here. Once they are configured in GNOME, they will just work.
+*/
+
#ifndef EXTERNAL_PROTOCOL_HANDLERS
#define EXTERNAL_PROTOCOL_HANDLERS
#include "nsError.h"
-#include "BaseProtocolContentHandler.h"
+#include "nsIContentHandler.h"
#include "nsIProtocolHandler.h"
#include "nsCURILoader.h"
+#include "nsString.h"
+
+class GBaseProtocolHandler : public nsIProtocolHandler
+{
+ public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIPROTOCOLHANDLER
+
+ GBaseProtocolHandler (const char *aScheme);
+ virtual ~GBaseProtocolHandler();
+ /* additional members */
+ protected:
+ nsCString mScheme;
+};
+
+class GBaseProtocolContentHandler : public GBaseProtocolHandler,
+ public nsIContentHandler
+{
+ public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSICONTENTHANDLER
+
+ NS_IMETHODIMP NewChannel(nsIURI *aURI, nsIChannel **_retval);
+
+ GBaseProtocolContentHandler (const char *aScheme);
+ virtual ~GBaseProtocolContentHandler();
+ /* additional members */
+ protected:
+ nsCString mMimeType;
+};
#define G_IRC_PROTOCOL_CID \
{ /* aabe33d3-7455-4d8f-87e7-43e4541ace4e */ \
@@ -59,15 +100,6 @@ class GIRCProtocolHandler : public GBaseProtocolContentHandler
"application-x-gnome-ftp"
#define G_FTP_CONTENT_CLASSNAME "Epiphany's FTP Content Handler"
-#define NS_FTPPROTOCOLHANDLER_CID \
-{ \
- 0x25029490, \
- 0xf132, \
- 0x11d2, \
- {0x95, 0x88, 0x0, 0x80, 0x5f, 0x36, 0x9f, 0x95} \
-}
-#define NS_FTPPROTOCOLHANDLER_CLASSNAME "The FTP Protocol Handler"
-
class GFtpProtocolHandler : public GBaseProtocolContentHandler
{
public:
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index 2b58a2df5..b066f5efd 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -47,10 +47,6 @@ endif
noinst_LTLIBRARIES = libephymozillaembed.la
libephymozillaembed_la_SOURCES = \
- BaseProtocolHandler.cpp \
- BaseProtocolHandler.h \
- BaseProtocolContentHandler.cpp \
- BaseProtocolContentHandler.h \
ContentHandler.cpp \
ContentHandler.h \
EphyAboutRedirector.cpp \
diff --git a/embed/mozilla/MozRegisterComponents.cpp b/embed/mozilla/MozRegisterComponents.cpp
index 8133a2650..1b81702a6 100644
--- a/embed/mozilla/MozRegisterComponents.cpp
+++ b/embed/mozilla/MozRegisterComponents.cpp
@@ -39,6 +39,7 @@
#include <nsIComponentRegistrar.h>
#include <nsCOMPtr.h>
#include <nsILocalFile.h>
+#include <nsNetCID.h>
#include <glib.h>