Bug 514823. r=Mardak, r=sdwilsh, a1.9.0=dveditz

git-svn-id: svn://10.0.0.236/trunk@258556 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sdwilsh%shawnwilsher.com 2009-10-02 19:34:37 +00:00
parent e64f2dcea6
commit 3bc6c8bea8
2 changed files with 25 additions and 8 deletions

View File

@ -2031,10 +2031,6 @@ nsDownload::SetState(DownloadState aState)
PRInt16 oldState = mDownloadState; PRInt16 oldState = mDownloadState;
mDownloadState = aState; mDownloadState = aState;
nsresult rv;
nsCOMPtr<nsIPrefBranch> pref = do_GetService(NS_PREFSERVICE_CONTRACTID);
// We don't want to lose access to our member variables // We don't want to lose access to our member variables
nsRefPtr<nsDownload> kungFuDeathGrip = this; nsRefPtr<nsDownload> kungFuDeathGrip = this;
@ -2066,11 +2062,19 @@ nsDownload::SetState(DownloadState aState)
case nsIDownloadManager::DOWNLOAD_FINISHED: case nsIDownloadManager::DOWNLOAD_FINISHED:
{ {
// Do what exthandler would have done if necessary // Do what exthandler would have done if necessary
(void)ExecuteDesiredAction(); nsresult rv = ExecuteDesiredAction();
if (NS_FAILED(rv)) {
// We've failed to execute the desired action. As a result, we should
// fail the download so the user can try again.
(void)FailDownload(rv, nsnull);
return rv;
}
// Now that we're done with handling the download, clean it up // Now that we're done with handling the download, clean it up
Finalize(); Finalize();
nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
// Master pref to control this function. // Master pref to control this function.
PRBool showTaskbarAlert = PR_TRUE; PRBool showTaskbarAlert = PR_TRUE;
if (pref) if (pref)
@ -2156,7 +2160,7 @@ nsDownload::SetState(DownloadState aState)
// Before notifying the listener, we must update the database so that calls // Before notifying the listener, we must update the database so that calls
// to it work out properly. // to it work out properly.
rv = UpdateDB(); nsresult rv = UpdateDB();
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
mDownloadManager->NotifyListenersOnDownloadStateChange(oldState, this); mDownloadManager->NotifyListenersOnDownloadStateChange(oldState, this);

View File

@ -1805,6 +1805,19 @@ nsresult nsExternalAppHandler::ExecuteDesiredAction()
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
rv = OpenWithApplication(); rv = OpenWithApplication();
} }
else
{
// Cancel the download and report an error. We do not want to end up in
// a state where it appears that we have a normal download that is
// pointing to a file that we did not actually create.
nsAutoString path;
mTempFile->GetPath(path);
SendStatusChange(kWriteError, rv, nsnull, path);
Cancel(rv);
// We still need to notify if we have a progress listener, so we cannot
// return at this point.
}
} }
else // Various unknown actions go here too else // Various unknown actions go here too
{ {