summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2018-03-07 18:36:25 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2018-03-16 05:21:36 +0000
commitfcb70831d8fba90cf9e24ea7d2747052dad8c176 (patch)
tree6c55deb29de896549856deee6884775a1ff4806e
parentaf51168412af89ff361505b6caec4024f54bcca5 (diff)
Implement IsMostRecentDownloadItemAtFilePath call
Implement IsMostRecentDownloadItemAtFilePath for download_manager_delegate_qt. This is required for CVE-2018-6033. Change-Id: I9f48dfa159d684f0fda894e68b81ff622aceaae2 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/download_manager_delegate_qt.cpp20
-rw-r--r--src/core/download_manager_delegate_qt.h2
2 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 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);
diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h
index d23a78b0b..7eaf4bafe 100644
--- a/src/core/download_manager_delegate_qt.h
+++ b/src/core/download_manager_delegate_qt.h
@@ -81,6 +81,8 @@ public:
const base::FilePath::StringType &default_extension,
bool can_save_as_complete,
const content::SavePackagePathPickedCallback &callback) override;
+ bool IsMostRecentDownloadItemAtFilePath(content::DownloadItem* download) override;
+
void cancelDownload(quint32 downloadId);