Fix helper apps not starting when the filename in the url is empty.

Also turn off caching of mime infos since we have no way to invalidate
this cache yet.  Bug 121644, r=law, sr=mscott


git-svn-id: svn://10.0.0.236/trunk@113742 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2002-02-06 03:35:31 +00:00
parent c4c291a120
commit c33a4dabe3
5 changed files with 26 additions and 9 deletions

View File

@@ -280,7 +280,8 @@ nsHelperAppDialog.prototype = {
try
{
var fileURL = url.QueryInterface( Components.interfaces.nsIFileURL);
if (fileURL)
// All URLs will QI to nsIFileURL. Need to check the scheme to determine type
if (fileURL.schemeIs("file"))
{
var fileObject = fileURL.file;
if (fileObject)

View File

@@ -175,8 +175,9 @@ NS_IMETHODIMP nsOSHelperAppService::GetFromExtension(const char * aFileExt, nsIM
rv = icService->GetMIMEInfoFromExtension(aFileExt, aMIMEInfo);
// if we got an entry, don't waste time hitting IC for this information next time, store it in our
// hash table....
if (NS_SUCCEEDED(rv) && *aMIMEInfo)
AddMimeInfoToCache(*aMIMEInfo);
// XXX Once cache can be invalidated, add the mime info to it. See bug 121644
// if (NS_SUCCEEDED(rv) && *aMIMEInfo)
// AddMimeInfoToCache(*aMIMEInfo);
}
if (!*aMIMEInfo) rv = NS_ERROR_FAILURE;
@@ -200,8 +201,9 @@ NS_IMETHODIMP nsOSHelperAppService::GetFromMIMEType(const char * aMIMEType, nsIM
rv = icService->FillInMIMEInfo(aMIMEType, nsnull, aMIMEInfo);
// if we got an entry, don't waste time hitting IC for this information next time, store it in our
// hash table....
if (NS_SUCCEEDED(rv) && *aMIMEInfo)
AddMimeInfoToCache(*aMIMEInfo);
// XXX Once cache can be invalidated, add the mime info to it. See bug 121644
// if (NS_SUCCEEDED(rv) && *aMIMEInfo)
// AddMimeInfoToCache(*aMIMEInfo);
}
if (!*aMIMEInfo) rv = NS_ERROR_FAILURE;

View File

@@ -288,7 +288,9 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType
}
PRBool matches = PR_FALSE;
mimeInfo->ExtensionExists(fileExtension.get(), &matches);
if (!fileExtension.IsEmpty()) {
mimeInfo->ExtensionExists(fileExtension.get(), &matches);
}
if (matches) {
mimeInfo->SetPrimaryExtension(fileExtension.get());
} else {
@@ -1331,6 +1333,15 @@ NS_IMETHODIMP nsExternalAppHandler::LaunchWithApplication(nsIFile * aApplication
#else
NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(fileToUse));
#endif
if (mSuggestedFileName.IsEmpty())
{
// Keep using the leafname of the temp file, since we're just starting a helper
PRUnichar* filename;
mTempFile->GetUnicodeLeafName(&filename);
mSuggestedFileName.Adopt(filename);
}
fileToUse->AppendUnicode(mSuggestedFileName.get());
// We'll make sure this results in a unique name later

View File

@@ -286,7 +286,8 @@ NS_IMETHODIMP nsOSHelperAppService::GetFromExtension(const char *aFileExt, nsIMI
// table so we don't hit the registry the next time we look up this content type.
*_retval = mimeInfo;
NS_ADDREF(*_retval);
AddMimeInfoToCache(mimeInfo);
// XXX Once cache can be invalidated, add the mime info to it. See bug 121644
// AddMimeInfoToCache(mimeInfo);
} /* endif */
// we failed to find a mime type.

View File

@@ -1205,7 +1205,8 @@ NS_IMETHODIMP nsOSHelperAppService::GetFromExtension(const char *aFileExt,
*_retval = mimeInfo;
NS_ADDREF(*_retval);
AddMimeInfoToCache(*_retval);
// XXX Once cache can be invalidated, add the mime info to it. See bug 121644
// AddMimeInfoToCache(*_retval);
return NS_OK;
}
@@ -1299,6 +1300,7 @@ NS_IMETHODIMP nsOSHelperAppService::GetFromMIMEType(const char *aMIMEType,
*_retval = mimeInfo;
NS_ADDREF(*_retval);
AddMimeInfoToCache(*_retval);
// XXX Once cache can be invalidated, add the mime info to it. See bug 121644
// AddMimeInfoToCache(*_retval);
return NS_OK;
}