diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-11-03 13:42:50 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-06-23 08:19:37 +0000 |
commit | b288dd5352f6c77c875812c7f9043c266c59c505 (patch) | |
tree | ec07ada1b26f76fe4fb812139b9f5254b55f7970 /src/core/download_manager_delegate_qt.cpp | |
parent | 84b72e6b2387991f90293984f2666563c93cf13c (diff) |
Implement pause and resume action in Download Items
Adds the ability to pause downloads, and resume paused or interrupted
downloads.
Task-number: QTBUG-56840
Change-Id: I018bd30c3a772a36d48e4154d94f69cb8d8319e4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/core/download_manager_delegate_qt.cpp')
-rw-r--r-- | src/core/download_manager_delegate_qt.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 77469a8ea..67c809032 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -92,6 +92,22 @@ void DownloadManagerDelegateQt::cancelDownload(quint32 downloadId) download->Cancel(/* user_cancel */ true); } +void DownloadManagerDelegateQt::pauseDownload(quint32 downloadId) +{ + content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_contextAdapter->browserContext()); + content::DownloadItem *download = dlm->GetDownload(downloadId); + if (download) + download->Pause(); +} + +void DownloadManagerDelegateQt::resumeDownload(quint32 downloadId) +{ + content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_contextAdapter->browserContext()); + content::DownloadItem *download = dlm->GetDownload(downloadId); + if (download) + download->Resume(); +} + bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* item, const content::DownloadTargetCallback& callback) { @@ -155,6 +171,8 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i suggestedFilePath, BrowserContextAdapterClient::UnknownSavePageFormat, false /* accepted */, + false /* paused */, + false /* done */, m_downloadType, item->GetLastReason() }; @@ -245,6 +263,8 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content suggestedFilePath, suggestedSaveFormat, acceptedByDefault, + false, /* paused */ + false, /* done */ BrowserContextAdapterClient::SavePage, BrowserContextAdapterClient::NoReason }; @@ -283,6 +303,8 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *downloa QString(), BrowserContextAdapterClient::UnknownSavePageFormat, true /* accepted */, + download->IsPaused(), + download->IsDone(), m_downloadType, download->GetLastReason() }; |