summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2017-11-14 16:23:18 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-02 20:45:07 +0000
commit7219986a18d45dd0e32a8004c748ce91d22a535b (patch)
tree1162c8e7050eba4afe833109b00f814ec76ec75c
parent9214f8e6092b48e7b596f343b5e9bb7afd430078 (diff)
Deprecate download type
This patch removes the download type property from QtWebEngineCore and replaces it with a simple boolean 'isSavePageDownload'. On the public API boundary the type property is reimplemented via this boolean and documented as obsolete. Rationale being that 1. This feature seems to lack practical use cases, other than perhaps distinguishing save-page downloads from normal file downloads, which can be done in a much simpler way. 2. This feature does not work as documented and never has. So far nobody has complained, hinting again at a lack of practical use cases. 3. In order to fix it we would need to maintain patches on top of Chromium and Blink (we would, for example, need to propagate the DownloadAttribute type from Blink to Chromium to WebEngine). [ChangeLog][Deprecation Notice] (QWebEngine)DownloadItem::type() is deprecated and replaced with the newly introduced isSavePageDownload() property. Task-number: QTBUG-62640 Change-Id: Icf4e1e5a635028986df7eab979f4c0527902ff0c Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r--src/core/browser_context_adapter_client.h9
-rw-r--r--src/core/download_manager_delegate_qt.cpp12
-rw-r--r--src/core/download_manager_delegate_qt.h3
-rw-r--r--src/core/web_contents_adapter.cpp4
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp33
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p.h4
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h2
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp2
-rw-r--r--src/webengine/doc/src/external-resources.qdoc5
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp30
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h3
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem_p.h2
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp2
-rw-r--r--tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp57
14 files changed, 70 insertions, 98 deletions
diff --git a/src/core/browser_context_adapter_client.h b/src/core/browser_context_adapter_client.h
index 02bee8ed6..32a56bfce 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 5eb97c5ea..191bb2267 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 aec83cb41..dd8ebf6c4 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 59a917ae2..0b6a44d8d 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 5afb19531..8d7550d6c 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 972b130aa..1699ee9dc 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 6b4f7c8d3..922b0379c 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 57ad009b7..f966f2dc6 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 6cced588c..c2faaa8d4 100644
--- a/src/webengine/doc/src/external-resources.qdoc
+++ b/src/webengine/doc/src/external-resources.qdoc
@@ -113,11 +113,6 @@
*/
/*!
- \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 a5569e408..ac7a71959 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 2aca2bb2a..073b97170 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 da765e5c5..812a3f98b 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 c4de46b67..02fdfa113 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 7094c8e4b..5df722340 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);