summaryrefslogtreecommitdiffstats
path: root/src/webengine/api
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 /src/webengine/api
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>
Diffstat (limited to 'src/webengine/api')
-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
4 files changed, 25 insertions, 16 deletions
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);