diff --git a/mozilla/dom/src/base/nsMimeTypeArray.cpp b/mozilla/dom/src/base/nsMimeTypeArray.cpp index c676a0ccc04..c10d4f3cabc 100644 --- a/mozilla/dom/src/base/nsMimeTypeArray.cpp +++ b/mozilla/dom/src/base/nsMimeTypeArray.cpp @@ -143,17 +143,17 @@ MimeTypeArrayImpl::NamedItem(const nsAString& aName, nsMIMEInfoHandleAction action = nsIMIMEInfo::saveToDisk; mimeInfo->GetPreferredAction(&action); if (action != nsIMIMEInfo::handleInternally) { - nsCOMPtr helper; - mimeInfo->GetDefaultApplicationHandler(getter_AddRefs(helper)); - if (!helper) { + PRBool hasHelper = PR_FALSE; + mimeInfo->GetHasDefaultHandler(&hasHelper); + if (!hasHelper) { + nsCOMPtr helper; mimeInfo->GetPreferredApplicationHandler(getter_AddRefs(helper)); if (!helper) { - // mime info from the OS may not have a PreferredApplicaitonHandler + // mime info from the OS may not have a PreferredApplicationHandler // so just check for an empty default description nsXPIDLString defaultDescription; mimeInfo->GetDefaultDescription(getter_Copies(defaultDescription)); if (defaultDescription.IsEmpty()) { - // no support; just leave return NS_OK; } diff --git a/mozilla/embedding/components/ui/helperAppDlg/nsHelperAppDlg.js b/mozilla/embedding/components/ui/helperAppDlg/nsHelperAppDlg.js index 3dbc0abf4fa..169ebe4ed42 100644 --- a/mozilla/embedding/components/ui/helperAppDlg/nsHelperAppDlg.js +++ b/mozilla/embedding/components/ui/helperAppDlg/nsHelperAppDlg.js @@ -374,7 +374,7 @@ nsHelperAppDialog.prototype = { // On other platforms, default is Ok if there is a default app. // Note that nsIMIMEInfo providers need to ensure that this holds true // on each platform. - result = this.mLauncher.MIMEInfo.defaultApplicationHandler; + result = this.mLauncher.MIMEInfo.hasDefaultHandler; } return result; }, diff --git a/mozilla/netwerk/mime/public/nsIMIMEInfo.idl b/mozilla/netwerk/mime/public/nsIMIMEInfo.idl index e7a205e3f8d..6421151e0a9 100644 --- a/mozilla/netwerk/mime/public/nsIMIMEInfo.idl +++ b/mozilla/netwerk/mime/public/nsIMIMEInfo.idl @@ -135,11 +135,17 @@ interface nsIMIMEInfo : nsISupports { */ attribute wstring applicationDescription; + /** + * Indicates whether a default application handler exists, + * i.e. whether the defaultApplicationHandler attribute is valid + */ + readonly attribute boolean hasDefaultHandler; + /** * Returns a nsIFile that points to the application that is associated * by default with this content type. This will usually be specified in - * the platform settings somehow. This is not always guaranteed - * to be set!! + * the platform settings somehow. This is only guaranteed to be set if + * hasDefaultHandler is true! */ attribute nsIFile defaultApplicationHandler; diff --git a/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp b/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp index 80d90c18a7a..cc67ddce4a9 100644 --- a/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp +++ b/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp @@ -296,6 +296,13 @@ NS_IMETHODIMP nsMIMEInfoImpl::SetPreferredApplicationHandler(nsIFile * aPreferre return NS_OK; } +NS_IMETHODIMP nsMIMEInfoImpl::GetHasDefaultHandler(PRBool * _retval) +{ + *_retval = mDefaultApplication != nsnull; + return NS_OK; +} + + NS_IMETHODIMP nsMIMEInfoImpl::GetDefaultApplicationHandler(nsIFile ** aDefaultAppHandler) { *aDefaultAppHandler = mDefaultApplication; diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp index b861f25cf66..61c475240a8 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -330,19 +330,20 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType else if (url) { // Get default app/description. - nsCOMPtr defaultApp; - nsXPIDLString defaultDescription; - mimeInfo->GetDefaultApplicationHandler(getter_AddRefs(defaultApp)); + PRBool hasDefaultApp = PR_FALSE; + nsXPIDLString defaultDescription; + mimeInfo->GetHasDefaultHandler(&hasDefaultApp); mimeInfo->GetDefaultDescription(getter_Copies(defaultDescription)); // If neither description nor app are specified, then we try to get // these from the per-platform OS settings based on the file extension. - if (defaultDescription.IsEmpty() && !defaultApp) + if (defaultDescription.IsEmpty() && !hasDefaultApp) { nsCOMPtr osInfo; url->GetFileExtension(fileExtension); if (NS_SUCCEEDED(GetMIMEInfoForExtensionFromOS(fileExtension.get(), getter_AddRefs(osInfo)))) { // Extract default application and default description. + nsCOMPtr defaultApp; osInfo->GetDefaultApplicationHandler(getter_AddRefs(defaultApp)); osInfo->GetDefaultDescription(getter_Copies(defaultDescription)); // Copy to result mime info object. diff --git a/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp b/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp index 80d90c18a7a..cc67ddce4a9 100644 --- a/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp +++ b/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp @@ -296,6 +296,13 @@ NS_IMETHODIMP nsMIMEInfoImpl::SetPreferredApplicationHandler(nsIFile * aPreferre return NS_OK; } +NS_IMETHODIMP nsMIMEInfoImpl::GetHasDefaultHandler(PRBool * _retval) +{ + *_retval = mDefaultApplication != nsnull; + return NS_OK; +} + + NS_IMETHODIMP nsMIMEInfoImpl::GetDefaultApplicationHandler(nsIFile ** aDefaultAppHandler) { *aDefaultAppHandler = mDefaultApplication;