diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2017-11-14 16:23:18 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-02 20:45:07 +0000 |
commit | 7219986a18d45dd0e32a8004c748ce91d22a535b (patch) | |
tree | 1162c8e7050eba4afe833109b00f814ec76ec75c /src/webenginewidgets/api/qwebenginedownloaditem.cpp | |
parent | 9214f8e6092b48e7b596f343b5e9bb7afd430078 (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>
Diffstat (limited to 'src/webenginewidgets/api/qwebenginedownloaditem.cpp')
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
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; } /*! |