mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Make the helper app dialog report the correct mime type after we've
tried to use extensions to guess the type. Bug 78943, r=law, sr=mscott
This commit is contained in:
parent
55c3a599a0
commit
637153585a
@ -84,6 +84,13 @@ interface nsIMIMEInfo : nsISupports {
|
||||
*/
|
||||
void AppendExtension(in string aExtension);
|
||||
|
||||
/* Returns a clone of this MIMEInfo.
|
||||
*
|
||||
* @return A clone of the MIMEInfo
|
||||
*/
|
||||
|
||||
nsIMIMEInfo clone();
|
||||
|
||||
/* The MIME type of this MIMEInfo.
|
||||
*
|
||||
* @return String representing the MIME type.
|
||||
|
@ -126,6 +126,35 @@ NS_IMETHODIMP nsMIMEInfoImpl::AppendExtension(const char *aExtension)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMIMEInfoImpl::Clone(nsIMIMEInfo** aClone) {
|
||||
NS_ENSURE_ARG_POINTER(aClone);
|
||||
|
||||
nsMIMEInfoImpl* clone = new nsMIMEInfoImpl(mMIMEType.get());
|
||||
if (!clone) {
|
||||
*aClone = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
clone->mExtensions = mExtensions;
|
||||
clone->mDescription = mDescription;
|
||||
nsresult result = NS_OK;
|
||||
if (mURI) {
|
||||
result = mURI->Clone(getter_AddRefs(clone->mURI));
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "Failed to clone URI");
|
||||
}
|
||||
clone->mMacType = mMacType;
|
||||
clone->mMacCreator = mMacCreator;
|
||||
if (mPreferredApplication) {
|
||||
result = mPreferredApplication->Clone(getter_AddRefs(clone->mPreferredApplication));
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "Failed to clone preferred handler application");
|
||||
}
|
||||
clone->mPreferredAction = mPreferredAction;
|
||||
clone->mPreferredAppDescription = mPreferredAppDescription;
|
||||
|
||||
return CallQueryInterface(clone, aClone);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMIMEInfoImpl::GetMIMEType(char * *aMIMEType) {
|
||||
if (!aMIMEType) return NS_ERROR_NULL_POINTER;
|
||||
|
@ -242,16 +242,14 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType
|
||||
if (url)
|
||||
{
|
||||
url->GetFileExtension(getter_Copies(fileExtension));
|
||||
nsCOMPtr<nsIMIMEInfo> tempMIMEObject;
|
||||
GetFromExtension(fileExtension, getter_AddRefs(tempMIMEObject));
|
||||
// only over write mimeInfo if we got a non-null temp mime info object.
|
||||
if (tempMIMEObject)
|
||||
GetFromExtension(fileExtension, getter_AddRefs(mimeInfo));
|
||||
// only over write mimeInfo if we got a non-null mime info object.
|
||||
if (mimeInfo)
|
||||
{
|
||||
mimeInfo = tempMIMEObject;
|
||||
// The OS might have thought this extension was a different mime type.
|
||||
// We must reset this to match the actual mime type. Otherwise, we
|
||||
// won't use this MIMEInfo when we see the real mime type next time.
|
||||
//mimeInfo->SetMIMEType(aMimeContentType);
|
||||
mimeInfo->SetMIMEType(aMimeContentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1410,8 +1408,10 @@ NS_IMETHODIMP nsExternalHelperAppService::GetFromExtension(const char *aFileExt,
|
||||
|
||||
nsCStringKey key(fileExt.get());
|
||||
|
||||
*_retval = (nsIMIMEInfo *) mMimeInfoCache->Get(&key);
|
||||
NS_IF_ADDREF(*_retval);
|
||||
nsIMIMEInfo *cachedInfo = (nsIMIMEInfo *) mMimeInfoCache->Get(&key);
|
||||
if (cachedInfo) {
|
||||
cachedInfo->Clone(_retval);
|
||||
}
|
||||
|
||||
// if we don't have a match in our hash table, then query the user provided
|
||||
// data source
|
||||
@ -1433,8 +1433,10 @@ NS_IMETHODIMP nsExternalHelperAppService::GetFromMIMEType(const char *aMIMEType,
|
||||
|
||||
nsCStringKey key(MIMEType.get());
|
||||
|
||||
*_retval = (nsIMIMEInfo *) mMimeInfoCache->Get(&key);
|
||||
NS_IF_ADDREF(*_retval);
|
||||
nsIMIMEInfo *cachedInfo = (nsIMIMEInfo *) mMimeInfoCache->Get(&key);
|
||||
if (cachedInfo) {
|
||||
cachedInfo->Clone(_retval);
|
||||
}
|
||||
|
||||
// if we don't have a match in our hash table, then query the user provided
|
||||
// data source containing additional content types...
|
||||
|
@ -126,6 +126,35 @@ NS_IMETHODIMP nsMIMEInfoImpl::AppendExtension(const char *aExtension)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMIMEInfoImpl::Clone(nsIMIMEInfo** aClone) {
|
||||
NS_ENSURE_ARG_POINTER(aClone);
|
||||
|
||||
nsMIMEInfoImpl* clone = new nsMIMEInfoImpl(mMIMEType.get());
|
||||
if (!clone) {
|
||||
*aClone = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
clone->mExtensions = mExtensions;
|
||||
clone->mDescription = mDescription;
|
||||
nsresult result = NS_OK;
|
||||
if (mURI) {
|
||||
result = mURI->Clone(getter_AddRefs(clone->mURI));
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "Failed to clone URI");
|
||||
}
|
||||
clone->mMacType = mMacType;
|
||||
clone->mMacCreator = mMacCreator;
|
||||
if (mPreferredApplication) {
|
||||
result = mPreferredApplication->Clone(getter_AddRefs(clone->mPreferredApplication));
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "Failed to clone preferred handler application");
|
||||
}
|
||||
clone->mPreferredAction = mPreferredAction;
|
||||
clone->mPreferredAppDescription = mPreferredAppDescription;
|
||||
|
||||
return CallQueryInterface(clone, aClone);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMIMEInfoImpl::GetMIMEType(char * *aMIMEType) {
|
||||
if (!aMIMEType) return NS_ERROR_NULL_POINTER;
|
||||
|
Loading…
Reference in New Issue
Block a user