diff --git a/src/core/browser_context_adapter_client.h b/src/core/browser_context_adapter_client.h index 02bee8ed67aa9583da7b53b7132c4400f715cfcb..32a56bfce798d8f739729db0642ccc09c320ca20 100644 --- a/src/core/browser_context_adapter_client.h +++ b/src/core/browser_context_adapter_client.h @@ -69,13 +69,6 @@ public: MimeHtmlSaveFormat }; - enum DownloadType { - Attachment = 0, - DownloadAttribute, - UserRequested, - SavePage - }; - // Keep in sync with content::DownloadInterruptReason enum DownloadInterruptReason { NoReason = 0, @@ -120,7 +113,7 @@ public: bool accepted; bool paused; bool done; - int downloadType; + bool isSavePageDownload; int downloadInterruptReason; }; diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 5eb97c5eadbdd53f3f23f5ae7b45dc275e7984c4..191bb2267a5d5fece17d470b42b1e0bd96d1dd2a 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -65,7 +65,6 @@ DownloadManagerDelegateQt::DownloadManagerDelegateQt(BrowserContextAdapter *cont : m_contextAdapter(contextAdapter) , m_currentId(0) , m_weakPtrFactory(this) - , m_downloadType(BrowserContextAdapterClient::Attachment) { Q_ASSERT(m_contextAdapter); } @@ -123,11 +122,6 @@ 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()); @@ -173,7 +167,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i false /* accepted */, false /* paused */, false /* done */, - m_downloadType, + false /* isSavePageDownload */, item->GetLastReason() }; @@ -268,7 +262,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content acceptedByDefault, false, /* paused */ false, /* done */ - BrowserContextAdapterClient::SavePage, + true /* isSavePageDownload */, BrowserContextAdapterClient::NoReason }; @@ -308,7 +302,7 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *downloa true /* accepted */, download->IsPaused(), download->IsDone(), - m_downloadType, + download->IsSavePackageDownload(), download->GetLastReason() }; diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h index aec83cb412fa0bead4be47070b3f0b40bd1b6c08..dd8ebf6c4bbc837cbc0c9f26619db6685cf9c18e 100644 --- a/src/core/download_manager_delegate_qt.h +++ b/src/core/download_manager_delegate_qt.h @@ -86,8 +86,6 @@ public: void pauseDownload(quint32 downloadId); void resumeDownload(quint32 downloadId); - void setDownloadType(int downloadType) { m_downloadType = downloadType; } - // Inherited from content::DownloadItem::Observer void OnDownloadUpdated(content::DownloadItem *download) override; void OnDownloadDestroyed(content::DownloadItem *download) override; @@ -99,7 +97,6 @@ private: uint64_t m_currentId; base::WeakPtrFactory<DownloadManagerDelegateQt> m_weakPtrFactory; - int m_downloadType; friend class DownloadManagerDelegateInstance; DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegateQt); diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 59a917ae24f4980f78e1a2b68bb42218260cd59c..0b6a44d8d89c6d982e90b60652e062dc929fac18 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -975,14 +975,10 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN Q_D(WebContentsAdapter); content::BrowserContext *bctx = webContents()->GetBrowserContext(); content::DownloadManager *dlm = content::BrowserContext::GetDownloadManager(bctx); - DownloadManagerDelegateQt *dlmd = d->browserContextAdapter->downloadManagerDelegate(); if (!dlm) return; - dlmd->setDownloadType(BrowserContextAdapterClient::UserRequested); - dlm->SetDelegate(dlmd); - net::NetworkTrafficAnnotationTag traffic_annotation = net::DefineNetworkTrafficAnnotation( "WebContentsAdapter::download", R"( diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index 5afb195310d849498c044de31295f18e660d8a71..8d7550d6c32fcb3a39de5c09d1addf5392b63386 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -101,7 +101,7 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb , downloadId(-1) , downloadState(QQuickWebEngineDownloadItem::DownloadCancelled) , savePageFormat(QQuickWebEngineDownloadItem::UnknownSaveFormat) - , type(QQuickWebEngineDownloadItem::Attachment) + , isSavePageDownload(false) , interruptReason(QQuickWebEngineDownloadItem::NoReason) , totalBytes(-1) , receivedBytes(0) @@ -397,26 +397,33 @@ void QQuickWebEngineDownloadItem::setSavePageFormat(QQuickWebEngineDownloadItem: \qmlproperty enumeration WebEngineDownloadItem::type \readonly \since QtWebEngine 1.4 + \obsolete Describes the requested download's type. - \value WebEngineDownloadItem.Attachment The web server's response includes a - \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition - is present in the reply, the web server is indicating that the client should prompt the - user to save the content regardless of the content type. - See \l {RFC 2616 section 19.5.1} for details. - \value WebEngineDownloadItem.DownloadAttribute The user clicked a link with the \c download - attribute. See \l {HTML download attribute} for details. - \value WebEngineDownloadItem.UserRequested The user initiated the download, for example by - selecting a web action. - \value WebEngineDownloadItem.SavePage Saving of the current page was requested (for example by - the \l{WebEngineView::WebAction}{WebEngineView.SavePage} web action). + Unfortunately, this property only ever worked correctly for \c SavePage + downloads. In other cases, it followed the documented semantics rather + loosely, sometimes non-deterministically. Use \l isSavePageDownload instead. */ QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() const +{ + return isSavePageDownload() ? SavePage : UserRequested; +} + +/*! + \qmlproperty bool WebEngineDownloadItem::isSavePageDownload + \readonly + \since QtWebEngine 1.7 + + Whether this is a download request for saving a web page or a file. + + \sa savePageFormat +*/ +bool QQuickWebEngineDownloadItem::isSavePageDownload() const { Q_D(const QQuickWebEngineDownloadItem); - return d->type; + return d->isSavePageDownload; } /*! diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h index 972b130aa9da7ae272f445c1312d472a11d07054..1699ee9dc37448d7931845a1b85b991226854d3f 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p.h @@ -133,6 +133,7 @@ public: Q_PROPERTY(QString interruptReasonString READ interruptReasonString NOTIFY interruptReasonChanged REVISION 4 FINAL) Q_PROPERTY(bool isFinished READ isFinished NOTIFY isFinishedChanged REVISION 5 FINAL) Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged REVISION 5 FINAL) + Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT REVISION 6 FINAL) Q_INVOKABLE void accept(); Q_INVOKABLE void cancel(); @@ -148,11 +149,12 @@ public: void setPath(QString path); SavePageFormat savePageFormat() const; void setSavePageFormat(SavePageFormat format); - DownloadType type() const; + DownloadType Q_DECL_DEPRECATED type() const; DownloadInterruptReason interruptReason() const; QString interruptReasonString() const; bool isFinished() const; bool isPaused() const; + bool isSavePageDownload() const; Q_SIGNALS: void stateChanged(); diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h index 6b4f7c8d3d2be054792913593a3fd5f922af1d79..922b0379c831c0de2903c6e752d4b582dcd2886a 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h @@ -73,7 +73,7 @@ public: quint32 downloadId; QQuickWebEngineDownloadItem::DownloadState downloadState; QQuickWebEngineDownloadItem::SavePageFormat savePageFormat; - QQuickWebEngineDownloadItem::DownloadType type; + bool isSavePageDownload; QQuickWebEngineDownloadItem::DownloadInterruptReason interruptReason; qint64 totalBytes; qint64 receivedBytes; diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 57ad009b7da55d141c07bd0076f03c81038cb1a1..f966f2dc60f716c21c22560a390715edab3ac450 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -188,7 +188,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->downloadPath = info.path; itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>( info.savePageFormat); - itemPrivate->type = static_cast<QQuickWebEngineDownloadItem::DownloadType>(info.downloadType); + itemPrivate->isSavePageDownload = info.isSavePageDownload; QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q); diff --git a/src/webengine/doc/src/external-resources.qdoc b/src/webengine/doc/src/external-resources.qdoc index 6cced588ca1d94573ddec607f32452e15f66846e..c2faaa8d41e61a600edd4979db182197fd558798 100644 --- a/src/webengine/doc/src/external-resources.qdoc +++ b/src/webengine/doc/src/external-resources.qdoc @@ -112,11 +112,6 @@ \title RFC 2616 section 19.5.1 */ -/*! - \externalpage https://www.w3.org/TR/html5/links.html#downloading-resources - \title HTML download attribute -*/ - /*! \externalpage https://www.iana.org/assignments/uri-schemes/prov/view-source \title view-source URI scheme diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index a5569e4081eda0df27a4fabd41ff2066e9f9173b..ac7a7195979609ddd7561123458cb48a7c05f894 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -115,7 +115,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr , downloadId(-1) , downloadState(QWebEngineDownloadItem::DownloadCancelled) , savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat) - , type(QWebEngineDownloadItem::Attachment) + , isSavePageDownload(false) , interruptReason(QWebEngineDownloadItem::NoReason) , downloadUrl(url) , downloadPaused(false) @@ -317,20 +317,9 @@ quint32 QWebEngineDownloadItem::id() const /*! \enum QWebEngineDownloadItem::DownloadType \since 5.8 + \obsolete Describes the requested download's type. - - \value Attachment The web server's response includes a - \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition - is present in the reply, the web server is indicating that the client should prompt the - user to save the content regardless of the content type. - See \l {RFC 2616 section 19.5.1} for details. - \value DownloadAttribute The user clicked a link with the \c download - attribute. See \l {HTML download attribute} for details. - \value UserRequested The user initiated the download, for example by - selecting a web action. - \value SavePage Saving of the current page was requested (for example by - the \l{QWebEnginePage::WebAction}{QWebEnginePage::SavePage} web action). */ /*! @@ -512,13 +501,26 @@ void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageF /*! Returns the requested download's type. \since 5.8 + \obsolete + Unfortunately, this property only ever worked correctly for \c SavePage + downloads. In other cases, it followed the documented semantics rather + loosely, sometimes non-deterministically. Use \l isSavePageDownload instead. */ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const +{ + return isSavePageDownload() ? SavePage : UserRequested; +} + +/*! + Returns \c true if this is a download request for saving a web page. + \since 5.11 + */ +bool QWebEngineDownloadItem::isSavePageDownload() const { Q_D(const QWebEngineDownloadItem); - return d->type; + return d->isSavePageDownload; } /*! diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h index 2aca2bb2aad102835d0415f5c87baee9680e11f2..073b971706ce4f42399fd2c2593bd754d39c56fd 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem.h @@ -123,9 +123,10 @@ public: bool isPaused() const; SavePageFormat savePageFormat() const; void setSavePageFormat(SavePageFormat format); - DownloadType type() const; + DownloadType Q_DECL_DEPRECATED type() const; DownloadInterruptReason interruptReason() const; QString interruptReasonString() const; + bool isSavePageDownload() const; public Q_SLOTS: void accept(); diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h index da765e5c5a8a2f0a48b4fe59fe57d9d3e8b0b2b9..812a3f98b65de93a4fb1fedfc597965209088ad8 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h @@ -72,7 +72,7 @@ public: quint32 downloadId; QWebEngineDownloadItem::DownloadState downloadState; QWebEngineDownloadItem::SavePageFormat savePageFormat; - QWebEngineDownloadItem::DownloadType type; + bool isSavePageDownload; QWebEngineDownloadItem::DownloadInterruptReason interruptReason; QString downloadPath; const QUrl downloadUrl; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index c4de46b6717cb37dc32c7c27a6866bca0b7768f8..02fdfa113d8e1c8978fa2528446b5dd03eed5b3c 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -205,7 +205,7 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->downloadPath = info.path; itemPrivate->mimeType = info.mimeType; itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(info.savePageFormat); - itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType); + itemPrivate->isSavePageDownload = info.isSavePageDownload; QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q); diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp index 7094c8e4ba09ca0658bcd5b0ce718ee0da28147e..5df7223406a1f6abd447047b34454a5a2c443bb0 100644 --- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp +++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp @@ -86,7 +86,6 @@ void tst_QWebEngineDownloads::downloadLink_data() QTest::addColumn<QByteArray>("fileDisposition"); QTest::addColumn<bool>("fileHasReferer"); QTest::addColumn<DownloadTestFileAction>("fileAction"); - QTest::addColumn<QWebEngineDownloadItem::DownloadType>("downloadType"); // SaveLink should always trigger a download, even for empty files. QTest::newRow("save link to empty file") @@ -98,8 +97,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDownloaded; // SaveLink should always trigger a download, also for text files. QTest::newRow("save link to text file") @@ -111,8 +109,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDownloaded; // ... adding the "download" attribute should have no effect. QTest::newRow("save link to text file (attribute)") @@ -124,8 +121,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDownloaded; // ... adding the "attachment" content disposition should also have no effect. QTest::newRow("save link to text file (attachment)") @@ -137,8 +133,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("attachment") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::UserRequested; + /* fileAction */ << FileIsDownloaded; // ... even adding both should have no effect. QTest::newRow("save link to text file (attribute+attachment)") @@ -150,8 +145,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("attachment") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::UserRequested; + /* fileAction */ << FileIsDownloaded; // Navigating to an empty file should show an empty page. QTest::newRow("navigate to empty file") @@ -163,8 +157,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDisplayed - /* downloadType */ << /* unused */ QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDisplayed; // Navigating to a text file should show the text file. QTest::newRow("navigate to text file") @@ -176,8 +169,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDisplayed - /* downloadType */ << /* unused */ QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDisplayed; // ... unless the link has the "download" attribute: then the file should be downloaded. QTest::newRow("navigate to text file (attribute)") @@ -189,8 +181,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << false // crbug.com/455987 - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDownloaded; // ... same with the content disposition header save for the download type. QTest::newRow("navigate to text file (attachment)") @@ -202,8 +193,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("attachment") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::Attachment; + /* fileAction */ << FileIsDownloaded; // ... and both. QTest::newRow("navigate to text file (attribute+attachment)") @@ -215,8 +205,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("attachment") /* fileHasReferer */ << false // crbug.com/455987 - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::Attachment; + /* fileAction */ << FileIsDownloaded; // The file's extension has no effect. QTest::newRow("navigate to supposed zip file") @@ -228,8 +217,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDisplayed - /* downloadType */ << /* unused */ QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDisplayed; // ... the file's mime type however does. QTest::newRow("navigate to supposed zip file (application/zip)") @@ -241,8 +229,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("application/zip") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDownloaded; // ... but we're not very picky about the exact type. QTest::newRow("navigate to supposed zip file (application/octet-stream)") @@ -254,8 +241,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("application/octet-stream") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDownloaded; // empty zip file (consisting only of "end of central directory record") QByteArray zipFile = QByteArrayLiteral("PK\x05\x06") + QByteArray(18, 0); @@ -270,8 +256,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("application/octet-stream") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDownloaded; // The mime type is not guessed automatically if provided by the server. QTest::newRow("navigate to actual zip file (application/zip)") @@ -283,8 +268,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("application/zip") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* fileAction */ << FileIsDownloaded; } void tst_QWebEngineDownloads::downloadLink() @@ -298,7 +282,6 @@ void tst_QWebEngineDownloads::downloadLink() QFETCH(QByteArray, fileDisposition); QFETCH(bool, fileHasReferer); QFETCH(DownloadTestFileAction, fileAction); - QFETCH(QWebEngineDownloadItem::DownloadType, downloadType); HttpServer server; QWebEngineProfile profile; @@ -395,7 +378,8 @@ void tst_QWebEngineDownloads::downloadLink() QCOMPARE(item->totalBytes(), -1); QCOMPARE(item->receivedBytes(), 0); QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason); - QCOMPARE(item->type(), downloadType); + QCOMPARE(item->type(), QWebEngineDownloadItem::UserRequested); + QCOMPARE(item->isSavePageDownload(), false); QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected)); QCOMPARE(item->path(), suggestedPath); QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat); @@ -413,7 +397,8 @@ void tst_QWebEngineDownloads::downloadLink() QCOMPARE(item->totalBytes(), fileContents.size()); QCOMPARE(item->receivedBytes(), fileContents.size()); QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason); - QCOMPARE(item->type(), downloadType); + QCOMPARE(item->type(), QWebEngineDownloadItem::UserRequested); + QCOMPARE(item->isSavePageDownload(), false); QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected)); QCOMPARE(item->path(), downloadPath); QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat); @@ -485,7 +470,6 @@ void tst_QWebEngineDownloads::downloadTwoLinks() QCOMPARE(item->totalBytes(), -1); QCOMPARE(item->receivedBytes(), 0); QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason); - QCOMPARE(item->type(), QWebEngineDownloadItem::DownloadAttribute); QCOMPARE(item->mimeType(), QStringLiteral("text/plain")); QCOMPARE(item->path(), standardDir + QByteArrayLiteral("/file1")); QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat); @@ -504,7 +488,6 @@ void tst_QWebEngineDownloads::downloadTwoLinks() QCOMPARE(item->totalBytes(), -1); QCOMPARE(item->receivedBytes(), 0); QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason); - QCOMPARE(item->type(), QWebEngineDownloadItem::DownloadAttribute); QCOMPARE(item->mimeType(), QStringLiteral("text/plain")); QCOMPARE(item->path(), standardDir + QByteArrayLiteral("/file2")); QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat); @@ -565,6 +548,7 @@ void tst_QWebEngineDownloads::downloadPage() QCOMPARE(item->receivedBytes(), 0); QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason); QCOMPARE(item->type(), QWebEngineDownloadItem::SavePage); + QCOMPARE(item->isSavePageDownload(), true); // FIXME why is mimeType always the same? QCOMPARE(item->mimeType(), QStringLiteral("application/x-mimearchive")); QCOMPARE(item->path(), downloadPath); @@ -583,6 +567,7 @@ void tst_QWebEngineDownloads::downloadPage() QVERIFY(item->receivedBytes() > 0); QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason); QCOMPARE(item->type(), QWebEngineDownloadItem::SavePage); + QCOMPARE(item->isSavePageDownload(), true); QCOMPARE(item->mimeType(), QStringLiteral("application/x-mimearchive")); QCOMPARE(item->path(), downloadPath); QCOMPARE(item->savePageFormat(), savePageFormat);