diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/browser_context_adapter_client.h | 9 | ||||
-rw-r--r-- | src/core/download_manager_delegate_qt.cpp | 12 | ||||
-rw-r--r-- | src/core/download_manager_delegate_qt.h | 3 | ||||
-rw-r--r-- | src/core/web_contents_adapter.cpp | 4 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem.cpp | 33 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem_p.h | 4 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem_p_p.h | 2 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 2 | ||||
-rw-r--r-- | src/webengine/doc/src/external-resources.qdoc | 5 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem.cpp | 30 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem.h | 3 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem_p.h | 2 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 2 |
13 files changed, 49 insertions, 62 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); |