Comment 29 for bug 589236

Revision history for this message
In , Mozilla (mozilla) wrote :

(From update of attachment 334886)
>--- uriloader/exthandler/nsMIMEInfoImpl.cpp 19 Oct 2007 04:15:43 -0000 1.69
>+++ uriloader/exthandler/nsMIMEInfoImpl.cpp 20 Aug 2008 15:45:32 -0000
>@@ -408,13 +408,13 @@ nsMIMEInfoBase::LaunchWithURI(nsIURI* aU
> }
>
> void
> nsMIMEInfoBase::CopyBasicDataTo(nsMIMEInfoBase* aOther)
> {
> aOther->mType = mType;
>- aOther->mDefaultAppDescription = mDefaultAppDescription;
>+ //aOther->mDefaultAppDescription = mDefaultAppDescription;

When it comes to gnome-vfs support overwriting mDefaultAppDescription is wrong in any case.
From looking at the code I'm not sure when it would make sense.

> NS_IMETHODIMP
> nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
> {
> *_retval = PR_FALSE;
>- nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
>- if (vfs) {
>- nsCOMPtr<nsIGnomeVFSMimeApp> app;
>- if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
>- *_retval = PR_TRUE;
>+ nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mType);
>+ if (!mimeInfo) {
>+ nsCAutoString ext;
>+ if (NS_SUCCEEDED(GetPrimaryExtension(ext)))
>+ mimeInfo = nsGNOMERegistry::GetFromExtension(ext);

I changed that to use nsGNOMERegistry since it's a bit shorter to implement.
I'm not sure why it was using the gnome-vfs component directly while the module already depends on nsGNOMERegistry but if there was a valid reason that could be changed.

> if (vfs) {
> nsCOMPtr<nsIGnomeVFSMimeApp> app;
> if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
> return app->Launch(nativePath);
>+
>+ // If we haven't got an app we try to get a valid one by searching for the
>+ // extension mapped type
>+ nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath);
>+ if (mimeInfo) {
>+ nsCAutoString type;
>+ mimeInfo->GetType(type);
>+ if (NS_SUCCEEDED(vfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
>+ return app->Launch(nativePath);
>+ }

While commenting that part I actually think there should be a return value check for GetType()?

> // Copy the attributes of retval onto miByExt, to return it
> retval->CopyBasicDataTo(miByExt);
>+ // But set the extensions primary since CopyBasicDataTo overwrites the
>+ // list
>+ if (!aFileExt.IsEmpty())
>+ retval->SetPrimaryExtension(aFileExt);

This was actually a side effect by trying to fix the issue.
I _think_ that should be done but I might be wrong.