Bug 634942 - HelperApp launch is broken with GIO. r=karlt, a=beltzner
authorWolfgang Rosenauer <wr@rosenauer.org>
Tue, 01 Mar 2011 08:19:23 +0100
changeset 63198 372eca6704c2555906a06ae68e10b22005f00cea
parent 63197 a7b9ace8b3a36f3738d3ec89cb02aa619724f429
child 63199 ec8a059bea58fd550dad8d34c265293bf2d3d706
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, beltzner
bugs634942
milestone2.0b13pre
first release with
nightly linux32
372eca6704c2 / 4.0b13pre / 20110301030403 / files
nightly linux64
372eca6704c2 / 4.0b13pre / 20110301030403 / files
nightly mac
372eca6704c2 / 4.0b13pre / 20110301030403 / files
nightly win32
372eca6704c2 / 4.0b13pre / 20110301030403 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 634942 - HelperApp launch is broken with GIO. r=karlt, a=beltzner
uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
@@ -52,16 +52,18 @@
 #include <contentaction/contentaction.h>
 #include "nsContentHandlerApp.h"
 #endif
 #endif
 
 #include "nsMIMEInfoUnix.h"
 #include "nsGNOMERegistry.h"
 #include "nsIGIOService.h"
+#include "nsNetCID.h"
+#include "nsIIOService.h"
 #include "nsIGnomeVFSService.h"
 #include "nsAutoPtr.h"
 #ifdef MOZ_ENABLE_DBUS
 #include "nsDBusHandlerApp.h"
 #endif
 
 nsresult
 nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
@@ -152,38 +154,50 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
   if (action.isValid()) {
     action.trigger();
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
 #endif
 
   nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
+  nsCAutoString uriSpec;
+  if (giovfs) {
+    // nsGIOMimeApp->Launch wants a URI string instead of local file
+    nsresult rv;
+    nsCOMPtr<nsIIOService> ioservice = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
+    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIURI> uri;
+    rv = ioservice->NewFileURI(aFile, getter_AddRefs(uri));
+    NS_ENSURE_SUCCESS(rv, rv);
+    uri->GetSpec(uriSpec);
+  }
+
   nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
   if (giovfs) {
     nsCOMPtr<nsIGIOMimeApp> app;
     if (NS_SUCCEEDED(giovfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
-      return app->Launch(nativePath);
+      return app->Launch(uriSpec);
   } else if (gnomevfs) {
     /* Fallback to GnomeVFS */
     nsCOMPtr<nsIGnomeVFSMimeApp> app;
     if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
       return app->Launch(nativePath);
   }
 
   // If we haven't got an app we try to get a valid one by searching for the
   // extension mapped type
   nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath);
   if (mimeInfo) {
     nsCAutoString type;
     mimeInfo->GetType(type);
     if (giovfs) {
       nsCOMPtr<nsIGIOMimeApp> app;
       if (NS_SUCCEEDED(giovfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
-        return app->Launch(nativePath);
+        return app->Launch(uriSpec);
     } else if (gnomevfs) {
       nsCOMPtr<nsIGnomeVFSMimeApp> app;
       if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
         return app->Launch(nativePath);
     }
   }
 
   if (!mDefaultApplication)