зеркало из https://github.com/mozilla/pjs.git
Download manager. Not part of build. a=asa
This commit is contained in:
Родитель
aab5fe14b4
Коммит
35f9a421a0
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -767,7 +767,7 @@ nsDownload::nsDownload():mStartTime(0),
|
|||
mMaxBytes(0),
|
||||
mDownloadState(NOTSTARTED),
|
||||
mLastUpdate(-500),
|
||||
mOpeningWith(nsnull)
|
||||
mOpeningWith(NS_LITERAL_STRING(""))
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
|
|
@ -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<nsIWebProgressListener> 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<nsIWebProgressListener> 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<nsIWebProgressListener> 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<nsIWebProgressListener> 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<nsIWebProgressListener> listener = do_QueryInterface(mInner);
|
||||
if (listener)
|
||||
return listener->OnSecurityChange(aWebProgress, aRequest, aState);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDownload> mInner;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDownloadProxy, nsIDownload)
|
||||
NS_IMPL_ISUPPORTS2(nsDownloadProxy, nsIDownload, nsIWebProgressListener)
|
||||
|
||||
#endif
|
||||
|
Загрузка…
Ссылка в новой задаче