diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | embed/mozilla/MozDownload.cpp | 28 | ||||
-rw-r--r-- | embed/mozilla/MozDownload.h | 4 |
3 files changed, 22 insertions, 18 deletions
@@ -1,3 +1,11 @@ +2003-12-22 Marco Pesenti Gritti <marco@gnome.org> + + * embed/mozilla/MozDownload.cpp: + * embed/mozilla/MozDownload.h: + + Correctly cancel the download instead of just + cancelling the request. + 2003-12-21 Xan Lopez <xan@gnome.org> * embed/downloader-view.c: (download_dialog_pause_cb): diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp index 2b9a9e4b6..62ff29c87 100644 --- a/embed/mozilla/MozDownload.cpp +++ b/embed/mozilla/MozDownload.cpp @@ -58,7 +58,6 @@ const char* const persistContractID = "@mozilla.org/embedding/browser/nsWebBrows MozDownload::MozDownload() : mGotFirstStateChange(false), mIsNetworkTransfer(false), - mUserCanceled(false), mStatus(NS_OK), mEmbedPersist(nsnull), mDownloadState(EPHY_DOWNLOAD_DOWNLOADING) @@ -251,7 +250,9 @@ MozDownload::GetObserver(nsIObserver **aObserver) NS_IMETHODIMP MozDownload::SetObserver(nsIObserver *aObserver) { - return NS_ERROR_NOT_IMPLEMENTED; + mObserver = aObserver; + + return NS_OK; } NS_IMETHODIMP @@ -320,15 +321,6 @@ MozDownload::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest mLastUpdate = now; - if (mUserCanceled) - { - if (aRequest) - { - aRequest->Cancel(NS_BINDING_ABORTED); - } - mUserCanceled = false; - } - if (aMaxTotalProgress == -1) { mPercentComplete = -1; @@ -371,11 +363,15 @@ MozDownload::OnSecurityChange (nsIWebProgress *aWebProgress, nsIRequest *aReques void MozDownload::Cancel() { - mUserCanceled = true; - /* nsWebBrowserPersist does the right thing: After canceling, next time through - * OnStateChange(), aStatus != NS_OK. This isn't the case with nsExternalHelperAppService.*/ - if (!mWebPersist) - mStatus = NS_ERROR_ABORT; + if (mWebPersist) + { + mWebPersist->CancelSave (); + } + + if (mObserver) + { + mObserver->Observe (nsnull, "oncancel", nsnull); + } } void diff --git a/embed/mozilla/MozDownload.h b/embed/mozilla/MozDownload.h index 7f40bc327..ec06a1cad 100644 --- a/embed/mozilla/MozDownload.h +++ b/embed/mozilla/MozDownload.h @@ -118,9 +118,9 @@ protected: PRInt32 mCurrentProgress; bool mGotFirstStateChange, mIsNetworkTransfer; - bool mUserCanceled; nsresult mStatus; - + + nsCOMPtr<nsIObserver> mObserver; nsCOMPtr<nsIWebBrowserPersist> mWebPersist; nsCOMPtr<nsIRequest> mRequest; EphyDownload *mEphyDownload; |