Make protocol handling dialog appear with protocols that are unknown to the OS if we have handlers (bug 392964), r=myk,biesi; sr=biesi; a=mconnor
authordmose@mozilla.org
Sun, 09 Sep 2007 16:58:31 -0700
changeset 5833 a2f9af74fef2ffc04d69ab946db6a714073fe35f
parent 5832 e8e8a4f9d1dbc7a73855167df30ccabb397d4c9a
child 5834 ffd4d2df43d3cf1f7f49096de5b0bb474c927bc8
push idunknown
push userunknown
push dateunknown
reviewersmyk, biesi, biesi, mconnor
bugs392964
milestone1.9a8pre
Make protocol handling dialog appear with protocols that are unknown to the OS if we have handlers (bug 392964), r=myk,biesi; sr=biesi; a=mconnor
uriloader/exthandler/nsExternalHelperAppService.cpp
uriloader/exthandler/nsIExternalProtocolService.idl
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -691,20 +691,23 @@ nsresult nsExternalHelperAppService::Get
 NS_IMETHODIMP nsExternalHelperAppService::ExternalProtocolHandlerExists(const char * aProtocolScheme,
                                                                         PRBool * aHandlerExists)
 {
   nsCOMPtr<nsIHandlerInfo> handlerInfo;
   nsresult rv = GetProtocolHandlerInfo(
       nsDependentCString(aProtocolScheme), getter_AddRefs(handlerInfo));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // See if we have a preferred handler app for this
-  nsCOMPtr<nsIHandlerApp> preferredApp;
-  handlerInfo->GetPreferredApplicationHandler(getter_AddRefs(preferredApp));
-  if (preferredApp) {
+  // See if we have any known possible handler apps for this
+  nsCOMPtr<nsIMutableArray> possibleHandlers;
+  handlerInfo->GetPossibleApplicationHandlers(getter_AddRefs(possibleHandlers));
+
+  PRUint32 length;
+  possibleHandlers->GetLength(&length);
+  if (length) {
     *aHandlerExists = PR_TRUE;
     return NS_OK;
   }
 
   // if not, fall back on an os-based handler
   return OSProtocolHandlerExists(aProtocolScheme, aHandlerExists);
 }
 
--- a/uriloader/exthandler/nsIExternalProtocolService.idl
+++ b/uriloader/exthandler/nsIExternalProtocolService.idl
@@ -54,19 +54,24 @@ interface nsIHandlerInfo;
  * 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(7968ffa9-bb51-4b2d-aad2-8ea46c15d27f)]
 interface nsIExternalProtocolService : nsISupports
 {
   /**
-   * Check whether a handler for a specific protocol exists.
+   * Check whether a handler for a specific protocol exists.  Specifically,
+   * this looks to see whether there are any known possible application handlers
+   * in either the nsIHandlerService datastore or registered with the OS.
+   *
    * @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.
    *