Bug 1408010 - Fallback to app chooser dialog when external handler app not found, r=paolo draft
authorJan Horak <jhorak@redhat.com>
Thu, 19 Oct 2017 12:38:19 +0200
changeset 684717 9a7bb27f2ef2f045869ade2237e998f3e5786adf
parent 677139 4494c218fe4d16f1413d74b37b7fa178111951be
child 736943 57c63c2bfd7824fbb8bd91b504ecf565a0cbadb4
push id85703
push userbmo:jhorak@redhat.com
push dateMon, 23 Oct 2017 13:48:06 +0000
reviewerspaolo
bugs1408010
milestone58.0a1
Bug 1408010 - Fallback to app chooser dialog when external handler app not found, r=paolo The nsExternalHelperAppService has been changed to ask for application in case the preferred application has not been found (to cover the case the user has uninstalled the application). MozReview-Commit-ID: 63AFzPhzcxN
uriloader/exthandler/nsExternalHelperAppService.cpp
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1003,19 +1003,26 @@ nsExternalHelperAppService::LoadURI(nsIU
   nsHandlerInfoAction preferredAction;
   handler->GetPreferredAction(&preferredAction);
   bool alwaysAsk = true;
   handler->GetAlwaysAskBeforeHandling(&alwaysAsk);
 
   // if we are not supposed to ask, and the preferred action is to use
   // a helper app or the system default, we just launch the URI.
   if (!alwaysAsk && (preferredAction == nsIHandlerInfo::useHelperApp ||
-                     preferredAction == nsIHandlerInfo::useSystemDefault))
-    return handler->LaunchWithURI(uri, aWindowContext);
-  
+                     preferredAction == nsIHandlerInfo::useSystemDefault)) {
+    rv = handler->LaunchWithURI(uri, aWindowContext);
+    // We are not supposed to ask, but when file not found the user most likely
+    // uninstalled the application which handles the uri so we will continue
+    // by application chooser dialog.
+    if (rv != NS_ERROR_FILE_NOT_FOUND) {
+      return rv;
+    }
+  }
+
   nsCOMPtr<nsIContentDispatchChooser> chooser =
     do_CreateInstance("@mozilla.org/content-dispatch-chooser;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   
   return chooser->Ask(handler, aWindowContext, uri,
                       nsIContentDispatchChooser::REASON_CANNOT_HANDLE);
 }