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
--- 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);
}