78919 part 1. r=bzbarsky, sr=darin. This adds an |hasDefaultHandler| attribute
to nsIMIMEInfo that should be used to check if a default application is available for this mimeinfo. git-svn-id: svn://10.0.0.236/trunk@144559 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
db9bab2b0c
commit
c80cb4ba6c
@ -143,17 +143,17 @@ MimeTypeArrayImpl::NamedItem(const nsAString& aName,
|
||||
nsMIMEInfoHandleAction action = nsIMIMEInfo::saveToDisk;
|
||||
mimeInfo->GetPreferredAction(&action);
|
||||
if (action != nsIMIMEInfo::handleInternally) {
|
||||
nsCOMPtr<nsIFile> helper;
|
||||
mimeInfo->GetDefaultApplicationHandler(getter_AddRefs(helper));
|
||||
if (!helper) {
|
||||
PRBool hasHelper = PR_FALSE;
|
||||
mimeInfo->GetHasDefaultHandler(&hasHelper);
|
||||
if (!hasHelper) {
|
||||
nsCOMPtr<nsIFile> 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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
},
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -330,19 +330,20 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType
|
||||
else if (url)
|
||||
{
|
||||
// Get default app/description.
|
||||
nsCOMPtr<nsIFile> 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<nsIMIMEInfo> osInfo;
|
||||
url->GetFileExtension(fileExtension);
|
||||
if (NS_SUCCEEDED(GetMIMEInfoForExtensionFromOS(fileExtension.get(), getter_AddRefs(osInfo))))
|
||||
{
|
||||
// Extract default application and default description.
|
||||
nsCOMPtr<nsIFile> defaultApp;
|
||||
osInfo->GetDefaultApplicationHandler(getter_AddRefs(defaultApp));
|
||||
osInfo->GetDefaultDescription(getter_Copies(defaultDescription));
|
||||
// Copy to result mime info object.
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user