forwarded 488971 https://bugzilla.mozilla.org/show_bug.cgi?id=444440 thanks
On Wed, Jul 09, 2008 at 01:47:11PM +0200, Mike Hommey wrote: > Can you try the attached patch against xulrunner ? (not tested ; I /think/ > it should work and not break anything else, but I will have to do some > real testing) This patch was lacking a definition for one virtual member of nsMIMEInfoImpl. The newly attached patch does this, and some other stuff that should fix your issue, and some others that I saw at the same time. Mike
diff --git a/uriloader/exthandler/nsMIMEInfoImpl.h b/uriloader/exthandler/nsMIMEInfoImpl.h index 77813b5..a600ed1 100644 --- a/uriloader/exthandler/nsMIMEInfoImpl.h +++ b/uriloader/exthandler/nsMIMEInfoImpl.h @@ -219,7 +219,7 @@ class nsMIMEInfoImpl : public nsMIMEInfoBase { * Loads the URI with the OS default app. This should be overridden by each * OS's implementation. */ - virtual NS_HIDDEN_(nsresult) LoadUriInternal(nsIURI *aURI) = 0; + virtual NS_HIDDEN_(nsresult) LoadUriInternal(nsIURI *aURI) { return NS_ERROR_NOT_IMPLEMENTED; } nsCOMPtr<nsIFile> mDefaultApplication; ///< default application associated with this type. }; diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp index 2b14306..ae98211 100644 --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp @@ -51,18 +51,19 @@ 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) + if (mClass == eMIMEInfo) { + 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; + } + } else { + if (nsGNOMERegistry::HandlerExists(mType.get())) *_retval = PR_TRUE; } - if (*_retval) - return NS_OK; - - // If we didn't find a VFS handler, fallback. - return nsMIMEInfoImpl::GetHasDefaultHandler(_retval); + return NS_OK; } nsresult @@ -79,8 +80,5 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile) return app->Launch(nativePath); } - if (!mDefaultApplication) - return NS_ERROR_FILE_NOT_FOUND; - - return LaunchWithIProcess(mDefaultApplication, nativePath); + return NS_ERROR_FILE_NOT_FOUND; } diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp index 38bbf1f..002090d 100644 --- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp +++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp @@ -1252,28 +1252,34 @@ nsOSHelperAppService::GetHandlerAppFromPrefs(const char* aScheme, /*out*/ nsIFil return GetFileTokenForPath(utf16AppPath.get(), aApp); } -nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists) +/* Returns 0 for no handler, 1 for prefs handler and 2 for GNOME handler */ +int nsOSHelperAppService::GetProtocolHandlerType(const char * aProtocolScheme) { - LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n", - aProtocolScheme)); - *aHandlerExists = PR_FALSE; - nsCOMPtr<nsIFile> app; nsresult rv = GetHandlerAppFromPrefs(aProtocolScheme, getter_AddRefs(app)); if (NS_SUCCEEDED(rv)) { PRBool isExecutable = PR_FALSE, exists = PR_FALSE; nsresult rv1 = app->Exists(&exists); nsresult rv2 = app->IsExecutable(&isExecutable); - *aHandlerExists = (NS_SUCCEEDED(rv1) && exists && NS_SUCCEEDED(rv2) && isExecutable); - LOG((" handler exists: %s\n", *aHandlerExists ? "yes" : "no")); + if (NS_SUCCEEDED(rv1) && exists && NS_SUCCEEDED(rv2) && isExecutable) + return 1; } #ifdef MOZ_WIDGET_GTK2 // Check the GConf registry for a protocol handler - if (!*aHandlerExists) - *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme); + if (nsGNOMERegistry::HandlerExists(aProtocolScheme)) + return 2; #endif + return 0; +} + +nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists) +{ + LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n", + aProtocolScheme)); + *aHandlerExists = GetProtocolHandlerType(aProtocolScheme) ? PR_TRUE : PR_FALSE; + LOG((" handler exists: %s\n", *aHandlerExists ? "yes" : "no")); return NS_OK; } @@ -1413,7 +1419,7 @@ nsOSHelperAppService::GetFromExtension(const nsCString& aFileExt) { } nsCAutoString mimeType(asciiMajorType + NS_LITERAL_CSTRING("/") + asciiMinorType); - nsMIMEInfoUnix* mimeInfo = new nsMIMEInfoUnix(mimeType); + nsMIMEInfoImpl* mimeInfo = new nsMIMEInfoImpl(mimeType); if (!mimeInfo) return nsnull; NS_ADDREF(mimeInfo); @@ -1578,7 +1584,7 @@ nsOSHelperAppService::GetFromType(const nsCString& aMIMEType) { return nsnull; } - nsMIMEInfoUnix* mimeInfo = new nsMIMEInfoUnix(aMIMEType); + nsMIMEInfoImpl* mimeInfo = new nsMIMEInfoImpl(aMIMEType); if (!mimeInfo) return nsnull; NS_ADDREF(mimeInfo); @@ -1634,7 +1640,7 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType, // If we got nothing, make a new mimeinfo if (!retval) { *aFound = PR_FALSE; - retval = new nsMIMEInfoUnix(aType); + retval = new nsMIMEInfoImpl(aType); if (retval) { NS_ADDREF(retval); if (!aFileExt.IsEmpty()) @@ -1662,19 +1668,21 @@ nsOSHelperAppService::GetProtocolHandlerInfoFromOS(const nsACString &aScheme, // We must check that a registered handler exists so that gnome_url_show // doesn't fallback to gnomevfs. // See nsGNOMERegistry::LoadURL and bug 389632. - nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(), - found); - if (NS_FAILED(rv)) - return rv; - - nsMIMEInfoUnix *handlerInfo = - new nsMIMEInfoUnix(aScheme, nsMIMEInfoBase::eProtocolInfo); + nsMIMEInfoBase *handlerInfo; + int handlerType = GetProtocolHandlerType(nsPromiseFlatCString(aScheme).get()); + if (handlerType == 2) { + handlerInfo = new nsMIMEInfoUnix(aScheme, nsMIMEInfoBase::eProtocolInfo); + } else { + handlerInfo = new nsMIMEInfoImpl(aScheme, nsMIMEInfoBase::eProtocolInfo); + } NS_ENSURE_TRUE(handlerInfo, NS_ERROR_OUT_OF_MEMORY); NS_ADDREF(*_retval = handlerInfo); + *found = handlerType ? PR_TRUE : PR_FALSE; - if (!*found) { + if (handlerType != 1) { // Code that calls this requires an object regardless if the OS has // something for us, so we return the empty object. + // We also don't need to SetDefaultDescription for nsMIMEInfoUnix return NS_OK; } diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.h b/uriloader/exthandler/unix/nsOSHelperAppService.h index e7dbbea..f8b43c7 100644 --- a/uriloader/exthandler/unix/nsOSHelperAppService.h +++ b/uriloader/exthandler/unix/nsOSHelperAppService.h @@ -164,6 +164,8 @@ private: nsAString& aMozillaFlags); nsresult GetHandlerAppFromPrefs(const char* aScheme, nsIFile** aApp); + + int GetProtocolHandlerType(const char * aProtocolScheme); }; #endif // nsOSHelperAppService_h__