summaryrefslogtreecommitdiffstats
path: root/src/core/download_manager_delegate_qt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/download_manager_delegate_qt.cpp')
-rw-r--r--src/core/download_manager_delegate_qt.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index 0eabd340c..33faa361c 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -270,6 +270,26 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
m_weakPtrFactory.GetWeakPtr()));
}
+bool DownloadManagerDelegateQt::IsMostRecentDownloadItemAtFilePath(content::DownloadItem *download)
+{
+ content::BrowserContext *context = download->GetBrowserContext();
+ std::vector<content::DownloadItem*> all_downloads;
+
+ content::DownloadManager* manager =
+ content::BrowserContext::GetDownloadManager(context);
+ if (manager)
+ manager->GetAllDownloads(&all_downloads);
+
+ for (const auto* item : all_downloads) {
+ if (item->GetGuid() == download->GetGuid() ||
+ item->GetTargetFilePath() != download->GetTargetFilePath())
+ continue;
+ if (item->GetState() == content::DownloadItem::IN_PROGRESS)
+ return false;
+ }
+ return true;
+}
+
void DownloadManagerDelegateQt::savePackageDownloadCreated(content::DownloadItem *item)
{
OnDownloadUpdated(item);