Skip to content

Commit fcb7083

Browse files
Michal Klocekjaheikk
authored andcommitted
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 <[email protected]>
1 parent af51168 commit fcb7083

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/core/download_manager_delegate_qt.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,26 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
270270
m_weakPtrFactory.GetWeakPtr()));
271271
}
272272

273+
bool DownloadManagerDelegateQt::IsMostRecentDownloadItemAtFilePath(content::DownloadItem *download)
274+
{
275+
content::BrowserContext *context = download->GetBrowserContext();
276+
std::vector<content::DownloadItem*> all_downloads;
277+
278+
content::DownloadManager* manager =
279+
content::BrowserContext::GetDownloadManager(context);
280+
if (manager)
281+
manager->GetAllDownloads(&all_downloads);
282+
283+
for (const auto* item : all_downloads) {
284+
if (item->GetGuid() == download->GetGuid() ||
285+
item->GetTargetFilePath() != download->GetTargetFilePath())
286+
continue;
287+
if (item->GetState() == content::DownloadItem::IN_PROGRESS)
288+
return false;
289+
}
290+
return true;
291+
}
292+
273293
void DownloadManagerDelegateQt::savePackageDownloadCreated(content::DownloadItem *item)
274294
{
275295
OnDownloadUpdated(item);

src/core/download_manager_delegate_qt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class DownloadManagerDelegateQt
8181
const base::FilePath::StringType &default_extension,
8282
bool can_save_as_complete,
8383
const content::SavePackagePathPickedCallback &callback) override;
84+
bool IsMostRecentDownloadItemAtFilePath(content::DownloadItem* download) override;
85+
8486

8587
void cancelDownload(quint32 downloadId);
8688

0 commit comments

Comments
 (0)