Bug 469023 - network.protocol-handler.warn-external-default does not work with hildon platform. r=bugmail,doug
authorOleg Romashin <romaxa@gmail.com>
Wed, 18 Feb 2009 08:41:37 -0500
changeset 25124 6c47449be33d76fbb2cb6a766f3c75f6bc57fe0d
parent 25123 4c66a7e1fdf2d73af771afa7759abdaa8680d16b
child 25125 142c52f1c6506ecd9538512d49e2579a60e21e7f
push idunknown
push userunknown
push dateunknown
reviewersbugmail, doug
bugs469023
milestone1.9.2a1pre
Bug 469023 - network.protocol-handler.warn-external-default does not work with hildon platform. r=bugmail,doug
uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
uriloader/exthandler/unix/nsMIMEInfoUnix.h
uriloader/exthandler/unix/nsOSHelperAppService.cpp
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
@@ -114,16 +114,28 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
   if (!mDefaultApplication)
     return NS_ERROR_FILE_NOT_FOUND;
 
   return LaunchWithIProcess(mDefaultApplication, nativePath);
 }
 
 #ifdef MOZ_PLATFORM_HILDON
 
+/* static */ PRBool
+nsMIMEInfoUnix::HandlerExists(const char *aProtocolScheme)
+{
+  PRBool isEnabled = PR_FALSE;
+  HildonURIAction *action = hildon_uri_get_default_action(aProtocolScheme, nsnull);
+  if (action) {
+    isEnabled = PR_TRUE;
+    hildon_uri_action_unref(action);
+  }
+  return isEnabled;
+}
+
 NS_IMETHODIMP
 nsMIMEInfoUnix::GetPossibleApplicationHandlers(nsIMutableArray ** aPossibleAppHandlers)
 {
   if (!mPossibleApplications) {
     mPossibleApplications = do_CreateInstance(NS_ARRAY_CONTRACTID);
     
     if (!mPossibleApplications)
       return NS_ERROR_OUT_OF_MEMORY;
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.h
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.h
@@ -44,16 +44,17 @@
 
 class nsMIMEInfoUnix : public nsMIMEInfoImpl
 {
 public:
   nsMIMEInfoUnix(const char *aMIMEType = "") : nsMIMEInfoImpl(aMIMEType) {}
   nsMIMEInfoUnix(const nsACString& aMIMEType) : nsMIMEInfoImpl(aMIMEType) {}
   nsMIMEInfoUnix(const nsACString& aType, HandlerClass aClass) :
     nsMIMEInfoImpl(aType, aClass) {}
+  static PRBool HandlerExists(const char *aProtocolScheme);
 
 protected:
   NS_IMETHOD GetHasDefaultHandler(PRBool *_retval);
 
   virtual NS_HIDDEN_(nsresult) LoadUriInternal(nsIURI *aURI);
 
   virtual NS_HIDDEN_(nsresult) LaunchDefaultWithFile(nsIFile *aFile);
 #ifdef MOZ_PLATFORM_HILDON
--- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
@@ -1270,16 +1270,20 @@ nsresult nsOSHelperAppService::OSProtoco
     *aHandlerExists = (NS_SUCCEEDED(rv1) && exists && NS_SUCCEEDED(rv2) && isExecutable);
     LOG(("   handler exists: %s\n", *aHandlerExists ? "yes" : "no"));
   }
 
 #ifdef MOZ_WIDGET_GTK2
   // Check the GConf registry for a protocol handler
   if (!*aHandlerExists)
     *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
+#ifdef MOZ_PLATFORM_HILDON
+  if (!*aHandlerExists)
+    *aHandlerExists = nsMIMEInfoUnix::HandlerExists(aProtocolScheme);
+#endif
 #endif
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsAString& _retval)
 {
   nsCOMPtr<nsIFile> appFile;