diff --git a/uriloader/base/nsIDownload.idl b/uriloader/base/nsIDownload.idl index cf9f7cbefd9..d73d8e2e9cd 100644 --- a/uriloader/base/nsIDownload.idl +++ b/uriloader/base/nsIDownload.idl @@ -47,10 +47,28 @@ interface nsIWebProgressListener; [scriptable, uuid(06cb92f2-1dd2-11b2-95f2-96dfdfb804a1)] interface nsIDownload : nsISupports { + /** + * Initializes the download with certain properties. + * + * @param aSource The source (nsIURI) of the download. + * + * @param aTarget The local file to which the download is being saved. + * + * @param aDisplayName The user-readable description of the download. + * + * @param aPersist The "persist" used to transfer the download. If set, + * the manager will set its listener to the download item + * and use it for cancellation. If not set, the client + * is expected to set the download item as the listener on + * whatever transfer component is being used, and to + * set an observer on the download item that listens for + * the "oncancel" topic and cancels the download. + */ void init(in nsIURI aSource, in nsILocalFile aTarget, in wstring aDisplayName, in nsIWebBrowserPersist aPersist); + /** * The source of the download. */ diff --git a/xpfe/components/download-manager/public/nsIDownloadManager.idl b/xpfe/components/download-manager/public/nsIDownloadManager.idl index 02f207b9be9..c2858c9ed48 100644 --- a/xpfe/components/download-manager/public/nsIDownloadManager.idl +++ b/xpfe/components/download-manager/public/nsIDownloadManager.idl @@ -59,6 +59,8 @@ interface nsIDownloadManager : nsISupports { * * @param aTarget The local file to which the download is being saved. * + * @param aDisplayName The user-readable description of the download. + * * @param aPersist The "persist" used to transfer the download. If set, * the manager will set its listener to the download item * and use it for cancellation. If not set, the client diff --git a/xpfe/components/download-manager/src/nsDownloadManager.cpp b/xpfe/components/download-manager/src/nsDownloadManager.cpp index df9f1fdb14a..9c7ab17c37a 100644 --- a/xpfe/components/download-manager/src/nsDownloadManager.cpp +++ b/xpfe/components/download-manager/src/nsDownloadManager.cpp @@ -767,7 +767,7 @@ nsDownload::nsDownload():mStartTime(0), mMaxBytes(0), mDownloadState(NOTSTARTED), mLastUpdate(-500), - mOpeningWith(nsnull) + mOpeningWith(NS_LITERAL_STRING("")) { NS_INIT_ISUPPORTS(); } diff --git a/xpfe/components/download-manager/src/nsDownloadProxy.h b/xpfe/components/download-manager/src/nsDownloadProxy.h index 6d5f617c023..81761901fcd 100644 --- a/xpfe/components/download-manager/src/nsDownloadProxy.h +++ b/xpfe/components/download-manager/src/nsDownloadProxy.h @@ -42,7 +42,8 @@ #include "nsIDownload.h" #include "nsIDownloadManager.h" -class nsDownloadProxy : nsIDownload +class nsDownloadProxy : public nsIDownload, + public nsIWebProgressListener { public: @@ -66,6 +67,7 @@ public: aTarget->GetPersistentDescriptor(&persistentDescriptor); return dm->OpenProgressDialogFor(persistentDescriptor, nsnull); } + NS_IMETHODIMP GetDisplayName(PRUnichar** aDisplayName) { @@ -136,11 +138,64 @@ public: { return mInner->GetPersist(aPersist); } + + NS_IMETHODIMP OnStateChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, PRInt32 aStateFlags, + PRUint32 aStatus) + { + nsCOMPtr listener = do_QueryInterface(mInner); + if (listener) + return listener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus); + return NS_ERROR_FAILURE; + } + + NS_IMETHODIMP OnStatusChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, nsresult aStatus, + const PRUnichar *aMessage) + { + nsCOMPtr listener = do_QueryInterface(mInner); + if (listener) + return listener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage); + return NS_ERROR_FAILURE; + } + + NS_IMETHODIMP OnLocationChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, nsIURI *aLocation) + { + nsCOMPtr listener = do_QueryInterface(mInner); + if (listener) + return listener->OnLocationChange(aWebProgress, aRequest, aLocation); + return NS_ERROR_FAILURE; + } + + NS_IMETHODIMP OnProgressChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 aCurSelfProgress, + PRInt32 aMaxSelfProgress, + PRInt32 aCurTotalProgress, + PRInt32 aMaxTotalProgress) + { + nsCOMPtr listener = do_QueryInterface(mInner); + if (listener) + return listener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, + aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress); + return NS_ERROR_FAILURE; + } + + NS_IMETHODIMP OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, PRInt32 aState) + { + nsCOMPtr listener = do_QueryInterface(mInner); + if (listener) + return listener->OnSecurityChange(aWebProgress, aRequest, aState); + return NS_ERROR_FAILURE; + } + private: nsCOMPtr mInner; }; -NS_IMPL_ISUPPORTS1(nsDownloadProxy, nsIDownload) +NS_IMPL_ISUPPORTS2(nsDownloadProxy, nsIDownload, nsIWebProgressListener) #endif \ No newline at end of file