diff options
author | Adam Kallai <kadam@inf.u-szeged.hu> | 2016-03-30 13:25:19 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2016-06-22 08:28:53 +0000 |
commit | 637f34d38b97cbfd5faf407756b32986a2607543 (patch) | |
tree | f69616c1983bcf1c3e569b6dd483ccf18ed2d767 /src/core/download_manager_delegate_qt.cpp | |
parent | 349e96d833493faaba2cd879e31811f07507cc37 (diff) |
Add a DownloadType enum property to WebEngineDownloadItem
With this property the user gets the requested download's type.
In other words, the user can identify the download where it comes from
based on the type.
Update public API list as well.
Change-Id: I2b066d7eb4df1134266ad67ade0066e3bcc2b454
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/download_manager_delegate_qt.cpp')
-rw-r--r-- | src/core/download_manager_delegate_qt.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 42b26072c..2cbfd121b 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -75,6 +75,7 @@ DownloadManagerDelegateQt::DownloadManagerDelegateQt(BrowserContextAdapter *cont : m_contextAdapter(contextAdapter) , m_currentId(0) , m_weakPtrFactory(this) + , m_downloadType(BrowserContextAdapterClient::Attachment) { Q_ASSERT(m_contextAdapter); } @@ -116,6 +117,11 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i QString suggestedFilename = toQt(item->GetSuggestedFilename()); QString mimeTypeString = toQt(item->GetMimeType()); + bool isAttachment = net::HttpContentDisposition(item->GetContentDisposition(), std::string()).is_attachment(); + + if (!isAttachment || !BrowserContextAdapterClient::UserRequested) + m_downloadType = BrowserContextAdapterClient::DownloadAttribute; + if (suggestedFilename.isEmpty()) suggestedFilename = toQt(net::HttpContentDisposition(item->GetContentDisposition(), std::string()).filename()); @@ -158,7 +164,8 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i mimeTypeString, suggestedFilePath, BrowserContextAdapterClient::UnknownSavePageFormat, - false /* accepted */ + false /* accepted */, + m_downloadType }; Q_FOREACH (BrowserContextAdapterClient *client, clients) { @@ -246,7 +253,8 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content QStringLiteral("application/x-mimearchive"), suggestedFilePath, suggestedSaveFormat, - acceptedByDefault + acceptedByDefault, + BrowserContextAdapterClient::SavePage }; Q_FOREACH (BrowserContextAdapterClient *client, clients) { @@ -282,7 +290,8 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *downloa toQt(download->GetMimeType()), QString(), BrowserContextAdapterClient::UnknownSavePageFormat, - true /* accepted */ + true /* accepted */, + m_downloadType }; Q_FOREACH (BrowserContextAdapterClient *client, clients) { |