bug 391150: expose an API for getting an nsIHandlerInfo object for a protocol; r=biesi, sr=dmose
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -20,16 +20,17 @@
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Scott MacGregor <mscott@netscape.com>
* Bill Law <law@netscape.com>
* Christian Biesinger <cbiesinger@web.de>
* Dan Mosedale <dmose@mozilla.org>
+ * Myk Melez <myk@mozilla.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
@@ -1321,22 +1322,22 @@ nsresult nsExternalHelperAppService::Exp
localFile->Remove(PR_FALSE);
}
mTemporaryFilesList.Clear();
return NS_OK;
}
-nsresult
+NS_IMETHODIMP
nsExternalHelperAppService::GetProtocolHandlerInfo(const nsACString &aScheme,
nsIHandlerInfo **aHandlerInfo)
{
- // XXX before we expose this to the UI, we need sort out our strategy re
- // the "warning" and "exposed" prefs
+ // XXX Now that we've exposed this to the UI (bug 391150), is there anything
+ // we need to do to make it compatible with the "warning" and "exposed" prefs?
// XXX enterprise customers should be able to turn this support off with a
// single master pref (maybe use one of the "exposed" prefs here?)
// nsIMIMEInfo is a superset of nsIHandlerInfo. Furthermore, nsMimeInfoImpl
// and subclasses have lots of good platform specific-knowledge of local
// applications which we might need later. For now, just use nsMIMEInfoImpl
// instead of implementating a separate nsIHandlerInfo object.
--- a/uriloader/exthandler/nsExternalHelperAppService.h
+++ b/uriloader/exthandler/nsExternalHelperAppService.h
@@ -18,16 +18,17 @@
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Scott MacGregor <mscott@netscape.com>
* Christian Biesinger <cbiesinger@web.de>
* Dan Mosedale <dmose@mozilla.org>
+ * Myk Melez <myk@mozilla.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
@@ -225,23 +226,16 @@ public:
nsIFile ** aFile);
/**
* Helper routine used to test whether a given mime type is in our
* mimeTypes.rdf data source
*/
NS_HIDDEN_(PRBool) MIMETypeIsInDataSource(const char * aContentType);
- /**
- * Return the URI template for any configured web handler. This will
- * probably be replaced by something on nsIWebContentConverterService soon.
- */
- NS_HIDDEN_(nsresult) GetProtocolHandlerInfo(const nsACString &aScheme,
- nsIHandlerInfo **aHandlerInfo);
-
virtual NS_HIDDEN_(nsresult) OSProtocolHandlerExists(const char *aScheme,
PRBool *aExists) = 0;
protected:
/**
* Pointer to the datasource that contains the user override information.
* @see InitDataSource
*/
--- a/uriloader/exthandler/nsIExternalProtocolService.idl
+++ b/uriloader/exthandler/nsIExternalProtocolService.idl
@@ -17,16 +17,17 @@
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Scott MacGregor <mscott@netscape.com>
+ * Myk Melez <myk@mozilla.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
@@ -37,49 +38,67 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIURI;
interface nsIFile;
interface nsIInterfaceRequestor;
+interface nsIHandlerInfo;
/**
* The external protocol service is used for finding and launching
* web handlers (a la registerProtocolHandler in the HTML5 draft) or
* platform-specific applications for handling particular protocols.
*
* You can ask the external protocol service if it has an external
* handler for a given protocol scheme. And you can ask it to load
* the url using the default handler.
*/
-[scriptable, uuid(01e9ce6e-1c81-4f1a-b128-2f2526ec40e3)]
+[scriptable, uuid(7968ffa9-bb51-4b2d-aad2-8ea46c15d27f)]
interface nsIExternalProtocolService : nsISupports
{
/**
* Check whether a handler for a specific protocol exists.
* @param aProtocolScheme The scheme from a url: http, ftp, mailto, etc.
* @return true if we have a handler and false otherwise.
+ * XXX shouldn't aProtocolScheme be an ACString like nsIURI::scheme?
*/
boolean externalProtocolHandlerExists(in string aProtocolScheme);
/**
* Check whether a handler for a specific protocol is "exposed" as a visible
* feature of the current application.
*
* An exposed protocol handler is one that can be used in all contexts. A
* non-exposed protocol handler is one that can only be used internally by the
* application. For example, a non-exposed protocol would not be loaded by the
* application in response to a link click or a X-remote openURL command.
* Instead, it would be deferred to the system's external protocol handler.
+ * XXX shouldn't aProtocolScheme be an ACString like nsIURI::scheme?
*/
boolean isExposedProtocol(in string aProtocolScheme);
/**
+ * Retrieve the handler for the given protocol. If neither the application
+ * nor the OS knows about a handler for the protocol, the object this method
+ * returns will represent a default handler for unknown content.
+ *
+ * @param aProtocolScheme the scheme from a URL: http, ftp, mailto, etc.
+ *
+ * Note: aProtocolScheme should not include a trailing colon, which is part
+ * of the URI syntax, not part of the scheme itself (i.e. pass "mailto" not
+ * "mailto:").
+ *
+ * @return the handler, if any; otherwise a default handler
+ */
+ nsIHandlerInfo getProtocolHandlerInfo(in ACString aProtocolScheme);
+
+ /**
* Used to load a url via an external protocol handler (if one exists)
*
* @param aURL The url to load
* @deprecated Use LoadURI instead (See Bug 389565 for removal)
*/
void loadUrl (in nsIURI aURL);
/**