summaryrefslogtreecommitdiffstats
path: root/src/core/download_manager_delegate_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-07-23 17:17:40 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-02 20:52:02 +0000
commit595589197313178551cf7ccd645d2732643875bf (patch)
tree8ed5686b3de206775425eb5c9fcca8dfb3a01320 /src/core/download_manager_delegate_qt.cpp
parent1481e8d87fe89d9e27d9de593767b55a0e84a31f (diff)
Add QWebEngineDownloadItem page/view accessor
To be able to determine where a download was triggered. [ChangeLog][DownloadItem] Added a page/view accessor to tell were the download was triggered. Change-Id: I21843a545a3e0eb66f5e5fa8a50e77564f2118a7 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'src/core/download_manager_delegate_qt.cpp')
-rw-r--r--src/core/download_manager_delegate_qt.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index 813657365..4ed77688e 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -168,6 +168,11 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
item->AddObserver(this);
QList<ProfileAdapterClient*> clients = m_profileAdapter->clients();
if (!clients.isEmpty()) {
+ content::WebContents *webContents = content::DownloadItemUtils::GetWebContents(item);
+ WebContentsAdapterClient *adapterClient = nullptr;
+ if (webContents)
+ adapterClient = static_cast<WebContentsDelegateQt *>(webContents->GetDelegate())->adapterClient();
+
ProfileAdapterClient::DownloadItemInfo info = {
item->GetId(),
toQt(item->GetURL()),
@@ -181,7 +186,8 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
false /* paused */,
false /* done */,
downloadType,
- item->GetLastReason()
+ item->GetLastReason(),
+ adapterClient
};
for (ProfileAdapterClient *client : qAsConst(clients)) {
@@ -263,6 +269,10 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
// Clear the delegate's SavePageInfo. It's only valid for the page currently being saved.
contentsDelegate->setSavePageInfo(SavePageInfo());
+ WebContentsAdapterClient *adapterClient = nullptr;
+ if (web_contents)
+ adapterClient = static_cast<WebContentsDelegateQt *>(web_contents->GetDelegate())->adapterClient();
+
ProfileAdapterClient::DownloadItemInfo info = {
m_currentId + 1,
toQt(web_contents->GetURL()),
@@ -276,7 +286,8 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
false, /* paused */
false, /* done */
ProfileAdapterClient::SavePage,
- ProfileAdapterClient::NoReason
+ ProfileAdapterClient::NoReason,
+ adapterClient
};
for (ProfileAdapterClient *client : qAsConst(clients)) {
@@ -323,6 +334,11 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(download::DownloadItem *downlo
{
QList<ProfileAdapterClient*> clients = m_profileAdapter->clients();
if (!clients.isEmpty()) {
+ WebContentsAdapterClient *adapterClient = nullptr;
+ content::WebContents *webContents = content::DownloadItemUtils::GetWebContents(download);
+ if (webContents)
+ adapterClient = static_cast<WebContentsDelegateQt *>(webContents->GetDelegate())->adapterClient();
+
ProfileAdapterClient::DownloadItemInfo info = {
download->GetId(),
toQt(download->GetURL()),
@@ -336,7 +352,8 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(download::DownloadItem *downlo
download->IsPaused(),
download->IsDone(),
0 /* downloadType (unused) */,
- download->GetLastReason()
+ download->GetLastReason(),
+ adapterClient
};
for (ProfileAdapterClient *client : qAsConst(clients)) {