bug 236988 - should show application icons in download manager when the file completes downloading. r=bryner sr=mscott a=asa on the nsIconURI part. make the download manager use proper file:/// URIs in the moz-icon:// uris it generates in response to GetTargets NC:IconURI instead of native paths. Make the download manager refresh the icon once the download is complete and have the icon image in download items always bypass the cache when loading its icon.

This commit is contained in:
ben%bengoodger.com 2004-03-17 21:23:52 +00:00
parent d8e468c5b9
commit 582a418b85
4 changed files with 42 additions and 19 deletions

View File

@ -177,8 +177,9 @@ nsMozIconURI::SetSpec(const nsACString &aSpec)
// and remember the rest in mDummyFilePath
mDummyFilePath.Cut(0, 2); // cut the first 2 bytes....
}
else // we must have a url
{
if (!nsCRT::strncmp("file://", mDummyFilePath.get(), 7))
{
// we have a file url.....so store it...
rv = ioService->NewURI(mDummyFilePath, nsnull, nsnull, getter_AddRefs(mFileIcon));
if (NS_FAILED(rv)) return NS_ERROR_MALFORMED_URI;

View File

@ -1224,14 +1224,14 @@ nsDownloadManager::Observe(nsISupports* aSubject, const char* aTopic, const PRUn
else if (nsCRT::strcmp(aTopic, "quit-application") == 0) {
gStoppingDownloads = PR_TRUE;
if (mCurrDownloads.Count()) {
mCurrDownloads.Enumerate(CancelAllDownloads, this);
mCurrDownloads.Enumerate(CancelAllDownloads, this);
// Download Manager is shutting down! Tell the XPInstallManager to stop
// transferring any files that may have been being downloaded.
gObserverService->NotifyObservers(mXPIProgress, "xpinstall-progress", NS_LITERAL_STRING("cancel").get());
// Now go and update the datasource so that we "cancel" all paused downloads.
SaveState();
// Download Manager is shutting down! Tell the XPInstallManager to stop
// transferring any files that may have been being downloaded.
gObserverService->NotifyObservers(mXPIProgress, "xpinstall-progress", NS_LITERAL_STRING("cancel").get());
// Now go and update the datasource so that we "cancel" all paused downloads.
SaveState();
}
// Now that active downloads have been canceled, remove all downloads if
@ -1609,9 +1609,19 @@ nsDownloadsDataSource::GetTarget(nsIRDFResource* aSource, nsIRDFResource* aPrope
nsXPIDLCString path;
nsCOMPtr<nsIRDFResource> res(do_QueryInterface(target));
res->GetValue(getter_Copies(path));
nsCOMPtr<nsILocalFile> lf(do_CreateInstance("@mozilla.org/file/local;1"));
lf->InitWithNativePath(path);
nsCOMPtr<nsIIOService> ios(do_GetService("@mozilla.org/network/io-service;1"));
nsCOMPtr<nsIProtocolHandler> ph;
ios->GetProtocolHandler("file", getter_AddRefs(ph));
nsCOMPtr<nsIFileProtocolHandler> fph(do_QueryInterface(ph));
nsCAutoString fileURL;
fph->GetURLSpecFromFile(lf, fileURL);
nsAutoString iconURL(NS_LITERAL_STRING("moz-icon://"));
nsAutoString pathTemp; pathTemp.AssignWithConversion(path);
nsAutoString pathTemp; pathTemp.AssignWithConversion(fileURL);
iconURL += pathTemp + NS_LITERAL_STRING("?size=32");
nsCOMPtr<nsIRDFResource> result;

View File

@ -131,7 +131,7 @@
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox pack="start" flex="1">
@ -151,7 +151,7 @@
<xul:hbox flex="1" class="downloadContentBox" xbl:inherits="animated,animated-temp">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox flex="1">
@ -292,7 +292,7 @@
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox flex="1">
@ -331,7 +331,7 @@
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox pack="start" flex="1">
@ -362,7 +362,7 @@
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox pack="start" flex="1">
@ -384,7 +384,7 @@
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox pack="start" flex="1">
@ -405,7 +405,7 @@
<content>
<xul:hbox flex="1" class="downloadContentBox" xbl:inherits="animated,animated-temp">
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
<xul:vbox flex="1">
<xul:hbox flex="1">
@ -427,7 +427,7 @@
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target" crop="center"/>
@ -441,7 +441,7 @@
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target" crop="center"/>

View File

@ -126,6 +126,18 @@ function downloadCompleted(aDownload)
rdfc.Init(db, rdf.GetResource("NC:DownloadsRoot"));
var id = aDownload.target.path;
// Refresh the icon, so that executable icons are shown.
var mimeService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"].getService(Components.interfaces.nsIMIMEService);
var contentType = mimeService.getTypeFromFile(aDownload.target);
var listItem = document.getElementById(id);
var oldImage = listItem.getAttribute("image");
// I tack on the content-type here as a hack to bypass the cache which seems
// to be interfering despite the fact the image has 'validate="always"' set
// on it.
listItem.setAttribute("image", oldImage + "&contentType=" + contentType);
var dlRes = rdf.GetUnicodeResource(id);
var insertIndex = gDownloadManager.activeDownloadCount + 1;