Bug 562897 - Add required implementation to open files on Maemo 6. r=dougt
authorWolfgang Rosenauer <mozilla@rosenauer.org>
Fri, 30 Jul 2010 12:46:20 -0700
changeset 48430 5064715c0415661cef6556f149f395a7fced6cd9
parent 48429 71d27f203ef5a506ce1cfb792e2f79ddd30db286
child 48431 0e00a31fb25c135c872e619681e1ccfceb815915
push idunknown
push userunknown
push dateunknown
reviewersdougt
bugs562897
milestone2.0b3pre
Bug 562897 - Add required implementation to open files on Maemo 6. r=dougt
configure.in
uriloader/exthandler/Makefile.in
uriloader/exthandler/nsContentHandlerApp.cpp
uriloader/exthandler/nsContentHandlerApp.h
uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
uriloader/exthandler/unix/nsMIMEInfoUnix.h
uriloader/exthandler/unix/nsOSHelperAppService.cpp
xpcom/io/Makefile.in
xpcom/io/nsLocalFileUnix.cpp
--- a/configure.in
+++ b/configure.in
@@ -6884,16 +6884,24 @@ if test $MOZ_PLATFORM_MAEMO; then
       PKG_CHECK_MODULES(LIBHILDONFM,hildon-fm-2, _LIB_FOUND=1, _LIB_FOUND=)
       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONFM_LIBS"
       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONFM_CFLAGS"
       if test -z "$_LIB_FOUND"; then
          AC_MSG_ERROR([Hildon FM-2 is required when building for Maemo])
       fi
 
    fi
+   if test $MOZ_PLATFORM_MAEMO = 6; then
+      PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
+      MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTACTION_LIBS"
+      MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTACTION_CFLAGS"
+      if test -z "$_LIB_FOUND"; then
+         AC_MSG_ERROR([libcontentaction is required when build for Maemo])
+      fi
+   fi
 
    if test "$MOZ_PLATFORM_MAEMO" -gt 5; then
      MOZ_THUMB2=1
    fi
 
    PKG_CHECK_MODULES(LIBLOCATION,liblocation, _LIB_FOUND=1, _LIB_FOUND=)
    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBLOCATION_LIBS"
    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBLOCATION_CFLAGS"
--- a/uriloader/exthandler/Makefile.in
+++ b/uriloader/exthandler/Makefile.in
@@ -139,27 +139,31 @@ CPPSRCS	= \
 	$(NULL)
 
 ifdef MOZ_ENABLE_DBUS
 CPPSRCS += nsDBusHandlerApp.cpp
 LOCAL_INCLUDES   += $(TK_CFLAGS) $(MOZ_DBUS_CFLAGS)
 EXTRA_DSO_LDOPTS += $(MOZ_DBUS_LIBS)
 endif
 
-ifdef MOZ_PLATFORM_MAEMO
+ifeq ($(MOZ_PLATFORM_MAEMO),5)
 ifdef MOZ_ENABLE_GNOMEVFS
 LOCAL_INCLUDES   += $(MOZ_GNOMEVFS_CFLAGS)
 EXTRA_DSO_LDOPTS += $(MOZ_GNOMEVFS_LIBS)
 endif
 ifdef MOZ_ENABLE_GIO
 LOCAL_INCLUDES   += $(MOZ_GIO_CFLAGS)
 EXTRA_DSO_LDOPTS += $(MOZ_GIO_LIBS)
 endif
 endif
 
+ifeq ($(MOZ_PLATFORM_MAEMO),6)
+CPPSRCS += nsContentHandlerApp.cpp
+endif
+
 ifeq ($(OS_ARCH),WINNT WINCE)
 OS_LIBS		+= shell32.lib
 GARBAGE		+= nsOSHelperAppService.cpp $(srcdir)/nsOSHelperAppService.cpp \
              nsMIMEInfoWin.cpp $(srcdir)/nsMIMEInfoWin.cpp
 endif
 
 EXTRA_COMPONENTS = \
   nsHandlerService.js \
new file mode 100644
--- /dev/null
+++ b/uriloader/exthandler/nsContentHandlerApp.cpp
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim:expandtab:shiftwidth=2:tabstop=2:cin:
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is libcontentaction integration.
+ *
+ * The Initial Developer of the Original Code is
+ * the Nokia Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Egor Starkov <starkov.egor@gmail.com>
+ *
+ * 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
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsContentHandlerApp.h"
+#include "nsIURI.h"
+#include "nsIGenericFactory.h"
+#include "nsIClassInfoImpl.h"
+#include "nsCOMPtr.h"
+#include "nsString.h"
+
+NS_IMPL_ISUPPORTS1_CI(nsContentHandlerApp, nsIHandlerApp)
+
+nsContentHandlerApp::nsContentHandlerApp(nsString aName, nsCString aType,
+                                         ContentAction::Action& aAction) :
+  mName(aName),
+  mType(aType),
+  mAction(aAction)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//// nsIHandlerInfo
+
+NS_IMETHODIMP nsContentHandlerApp::GetName(nsAString& aName)
+{
+  aName.Assign(mName);
+  return NS_OK;
+}
+
+NS_IMETHODIMP nsContentHandlerApp::SetName(const nsAString& aName)
+{
+  mName.Assign(aName);
+  return NS_OK;
+}
+
+NS_IMETHODIMP nsContentHandlerApp::Equals(nsIHandlerApp *aHandlerApp, PRBool *_retval)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP nsContentHandlerApp::GetDetailedDescription(nsAString& aDetailedDescription)
+{
+  aDetailedDescription.Assign(mDetailedDescription);
+  return NS_OK;
+}
+
+NS_IMETHODIMP nsContentHandlerApp::SetDetailedDescription(const nsAString& aDetailedDescription)
+{
+  mDetailedDescription.Assign(aDetailedDescription);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsContentHandlerApp::LaunchWithURI(nsIURI *aURI,
+                                   nsIInterfaceRequestor *aWindowContext)
+{
+  nsCAutoString spec;
+  nsresult rv = aURI->GetAsciiSpec(spec);
+  NS_ENSURE_SUCCESS(rv,rv);
+  const char* url = spec.get();
+
+  QList<ContentAction::Action> actions = 
+    ContentAction::Action::actionsForFile(QUrl(url), QString(mType.get()));
+  for (int i = 0; i < actions.size(); ++i) {
+    if (actions[i].name() == QString((QChar*)mName.get(), mName.Length())) {
+      actions[i].trigger();
+      break;
+    }
+  }
+
+  return NS_OK;
+}
+
+NS_DECL_CLASSINFO(nsContentHandlerApp)
+
new file mode 100644
--- /dev/null
+++ b/uriloader/exthandler/nsContentHandlerApp.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim:expandtab:shiftwidth=2:tabstop=2:cin:
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Mozilla browser.
+ *
+ * The Initial Developer of the Original Code is
+ * the Nokia Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Egor Starkov <starkov.egor@gmail.com>
+ *
+ * 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
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef __nsContentHandlerAppImpl_h__
+#define __nsContentHandlerAppImpl_h__
+
+#include <contentaction/contentaction.h>
+#include "nsString.h"
+#include "nsIMIMEInfo.h"
+
+class nsContentHandlerApp : public nsIHandlerApp
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIHANDLERAPP
+
+  nsContentHandlerApp(nsString aName, nsCString aType, ContentAction::Action& aAction);
+  virtual ~nsContentHandlerApp() { }
+
+protected:
+  nsString mName;
+  nsCString mType;
+  nsString mDetailedDescription;
+
+  ContentAction::Action mAction;
+};
+#endif
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
@@ -17,16 +17,17 @@
  *
  * The Initial Developer of the Original Code is
  * Mozilla Corporation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Shawn Wilsher <me@shawnwilsher.com> (Original Author)
+ *   Wolfgang Rosenauer <wr@rosenauer.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
@@ -38,42 +39,61 @@
  * ***** END LICENSE BLOCK ***** */
 
 #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
 #include <glib.h>
 #include <hildon-uri.h>
 #include <hildon-mime.h>
 #include <libosso.h>
 #endif
+#if (MOZ_PLATFORM_MAEMO == 6)
+#include <QDesktopServices>
+#include <QUrl>
+#include <QString>
+#include <contentaction/contentaction.h>
+#include "nsContentHandlerApp.h"
+#endif
 
 #include "nsMIMEInfoUnix.h"
 #include "nsGNOMERegistry.h"
 #include "nsIGIOService.h"
 #include "nsIGnomeVFSService.h"
 #include "nsAutoPtr.h"
 #ifdef MOZ_ENABLE_DBUS
 #include "nsDBusHandlerApp.h"
 #endif
 
 nsresult
 nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
 {
   nsresult rv = nsGNOMERegistry::LoadURL(aURI);
+
 #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
   if (NS_FAILED(rv)){
     HildonURIAction *action = hildon_uri_get_default_action(mSchemeOrType.get(), nsnull);
     if (action) {
       nsCAutoString spec;
       aURI->GetAsciiSpec(spec);
       if (hildon_uri_open(spec.get(), action, nsnull))
         rv = NS_OK;
       hildon_uri_action_unref(action);
     }
   }
 #endif
+
+#if (MOZ_PLATFORM_MAEMO == 6)
+  if (NS_FAILED(rv)) {
+    nsCAutoString spec;
+    aURI->GetAsciiSpec(spec);
+    if (QDesktopServices::openUrl(QUrl(spec.get()))) {
+      rv = NS_OK;
+    }
+  }
+#endif
+
   return rv;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
 {
   *_retval = PR_FALSE;
   nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mSchemeOrType);
@@ -94,31 +114,51 @@ nsMIMEInfoUnix::GetHasDefaultHandler(PRB
   HildonURIAction *action = hildon_uri_get_default_action(mSchemeOrType.get(), nsnull);
   if (action) {
     *_retval = PR_TRUE;
     hildon_uri_action_unref(action);
     return NS_OK;
   }
 #endif
 
+#if (MOZ_PLATFORM_MAEMO == 6)
+  ContentAction::Action action = 
+    ContentAction::Action::defaultActionForFile(QUrl(), QString(mSchemeOrType.get()));
+  if (action.isValid()) {
+    *_retval = PR_TRUE;
+    return NS_OK;
+  }
+#endif
+
   // If we didn't find a VFS handler, fallback.
   return nsMIMEInfoImpl::GetHasDefaultHandler(_retval);
 }
 
 nsresult
 nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile)
 {
   nsCAutoString nativePath;
   aFile->GetNativePath(nativePath);
 
 #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
   if(NS_SUCCEEDED(LaunchDefaultWithDBus(PromiseFlatCString(nativePath).get())))
     return NS_OK;
 #endif
 
+#if (MOZ_PLATFORM_MAEMO == 6)
+  QUrl uri = QUrl::fromLocalFile(QString::fromUtf8(nativePath.get()));
+  ContentAction::Action action =
+    ContentAction::Action::defaultActionForFile(uri, QString(mSchemeOrType.get()));
+  if (action.isValid()) {
+    action.trigger();
+    return NS_OK;
+  }
+  return NS_ERROR_FAILURE;
+#endif
+
   nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
   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);
   } else if (gnomevfs) {
     /* Fallback to GnomeVFS */
@@ -241,8 +281,36 @@ nsMIMEInfoUnix::GetPossibleApplicationHa
     hildon_uri_free_actions(actions);
   }
 
   *aPossibleAppHandlers = mPossibleApplications;
   NS_ADDREF(*aPossibleAppHandlers);
   return NS_OK;
 }
 #endif
+
+#if (MOZ_PLATFORM_MAEMO == 6)
+NS_IMETHODIMP
+nsMIMEInfoUnix::GetPossibleApplicationHandlers(nsIMutableArray ** aPossibleAppHandlers)
+{
+  if (!mPossibleApplications) {
+    mPossibleApplications = do_CreateInstance(NS_ARRAY_CONTRACTID);
+
+    if (!mPossibleApplications)
+      return NS_ERROR_OUT_OF_MEMORY;
+
+    QList<ContentAction::Action> actions =
+      ContentAction::Action::actionsForFile(QUrl(), QString(mSchemeOrType.get()));
+
+    for (int i = 0; i < actions.size(); ++i) {
+      nsContentHandlerApp* app =
+        new nsContentHandlerApp(nsString((PRUnichar*)actions[i].name().data()), 
+                                mSchemeOrType, actions[i]);
+      mPossibleApplications->AppendElement(app, PR_FALSE);
+    }
+  }
+
+  *aPossibleAppHandlers = mPossibleApplications;
+  NS_ADDREF(*aPossibleAppHandlers);
+  return NS_OK;
+}
+#endif
+
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.h
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.h
@@ -56,11 +56,14 @@ protected:
 
   virtual NS_HIDDEN_(nsresult) LoadUriInternal(nsIURI *aURI);
 
   virtual NS_HIDDEN_(nsresult) LaunchDefaultWithFile(nsIFile *aFile);
 #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
   nsresult LaunchDefaultWithDBus(const char *aFilePath);
   NS_IMETHOD GetPossibleApplicationHandlers(nsIMutableArray * *aPossibleAppHandlers);
 #endif
+#if (MOZ_PLATFORM_MAEMO == 6)
+  NS_IMETHOD GetPossibleApplicationHandlers(nsIMutableArray * *aPossibleAppHandlers);
+#endif
 };
 
 #endif // nsMIMEInfoUnix_h_
--- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
@@ -36,16 +36,21 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#if (MOZ_PLATFORM_MAEMO == 6)
+#include <contentaction/contentaction.h>
+#include <QString>
+#endif
+
 #include "nsOSHelperAppService.h"
 #include "nsMIMEInfoUnix.h"
 #ifdef MOZ_WIDGET_GTK2
 #include "nsGNOMERegistry.h"
 #endif
 #include "nsISupports.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
@@ -1203,16 +1208,25 @@ nsOSHelperAppService::GetHandlerAndDescr
 }
 
 nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
 {
   LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n",
        aProtocolScheme));
   *aHandlerExists = PR_FALSE;
 
+#if (MOZ_PLATFORM_MAEMO == 6)
+  // libcontentaction requires character ':' after scheme
+  ContentAction::Action action =
+    ContentAction::Action::defaultActionForScheme(QString(aProtocolScheme) + ':');
+
+  if (action.isValid())
+    *aHandlerExists = PR_TRUE;
+#endif
+
 #ifdef MOZ_WIDGET_GTK2
   // Check the GConf registry for a protocol handler
   *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
 #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
   *aHandlerExists = nsMIMEInfoUnix::HandlerExists(aProtocolScheme);
 #endif
 #endif
 
--- a/xpcom/io/Makefile.in
+++ b/xpcom/io/Makefile.in
@@ -193,13 +193,18 @@ DEFINES		+= -D_IMPL_NS_COM
 ifeq ($(OS_ARCH),Linux)
 ifneq (,$(findstring lib64,$(libdir)))
 DEFINES     += -DHAVE_USR_LIB64_DIR
 endif
 endif
 
 LOCAL_INCLUDES	= -I..
 
-ifeq ($(MOZ_PLATFORM_MAEMO), 5)
-CFLAGS          += $(MOZ_DBUS_CFLAGS) $(MOZ_PLATFORM_MAEMO_CFLAGS)
-CXXFLAGS        += $(MOZ_DBUS_CFLAGS) $(MOZ_PLATFORM_MAEMO_CFLAGS)
+ifeq ($(MOZ_PLATFORM_MAEMO),5)
+CFLAGS          += $(MOZ_DBUS_CFLAGS)
+CXXFLAGS        += $(MOZ_DBUS_CFLAGS)
 endif
 
+ifdef MOZ_PLATFORM_MAEMO
+CFLAGS          += $(MOZ_PLATFORM_MAEMO_CFLAGS)
+CXXFLAGS        += $(MOZ_PLATFORM_MAEMO_CFLAGS)
+endif
+
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -67,16 +67,22 @@
     #include <fabdef.h>
 #endif
 
 #if defined(HAVE_SYS_QUOTA_H) && defined(HAVE_LINUX_QUOTA_H)
 #define USE_LINUX_QUOTACTL
 #include <sys/quota.h>
 #endif
 
+#if (MOZ_PLATFORM_MAEMO == 6)
+#include <QUrl>
+#include <QString>
+#include <contentaction/contentaction.h>
+#endif
+
 #include "nsDirectoryServiceDefs.h"
 #include "nsCRT.h"
 #include "nsCOMPtr.h"
 #include "nsMemory.h"
 #include "nsIFile.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsLocalFile.h"
@@ -1886,16 +1892,27 @@ nsLocalFile::Launch()
       return giovfs->ShowURIForInput(mPath);
     } else if (gnomevfs) {
       /* GnomeVFS fallback */
       return gnomevfs->ShowURIForInput(mPath);
     }
     
     return NS_ERROR_FAILURE;
 #endif
+#elif (MOZ_PLATFORM_MAEMO == 6)
+    QUrl uri = QUrl::fromLocalFile(QString::fromUtf8(mPath.get()));
+    ContentAction::Action action =
+      ContentAction::Action::defaultActionForFile(uri);
+
+    if (action.isValid()) {
+      action.trigger();
+      return NS_OK;
+    }
+
+    return NS_ERROR_FAILURE;
 #elif defined(ANDROID)
     // Try to get a mimetype, if this fails just use the file uri alone
     nsresult rv;
     nsCAutoString type;
     nsCOMPtr<nsIMIMEService> mimeService(do_GetService("@mozilla.org/mime;1", &rv));
     if (NS_SUCCEEDED(rv))
         rv = mimeService->GetTypeFromFile(this, type);