summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/api/qwebenginedownloaditem.cpp109
-rw-r--r--src/core/api/qwebenginedownloaditem.h25
-rw-r--r--src/core/api/qwebenginedownloaditem_p.h2
-rw-r--r--src/core/download_manager_delegate_qt.cpp16
-rw-r--r--src/core/download_manager_delegate_qt.h3
-rw-r--r--src/core/profile_adapter_client.h9
-rw-r--r--src/core/web_contents_adapter.cpp1
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp2
-rw-r--r--src/webengine/doc/src/webengine_download_item.qdoc43
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp2
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp7
-rw-r--r--tests/auto/widgets/loadsignals/tst_loadsignals.cpp4
-rw-r--r--tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp152
13 files changed, 11 insertions, 364 deletions
diff --git a/src/core/api/qwebenginedownloaditem.cpp b/src/core/api/qwebenginedownloaditem.cpp
index f7ddf024b..967a7e3f9 100644
--- a/src/core/api/qwebenginedownloaditem.cpp
+++ b/src/core/api/qwebenginedownloaditem.cpp
@@ -163,13 +163,13 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QtWebEngineCore::Pr
, downloadId(-1)
, downloadState(QWebEngineDownloadItem::DownloadCancelled)
, savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat)
- , type(QWebEngineDownloadItem::Attachment)
, interruptReason(QWebEngineDownloadItem::NoReason)
, downloadUrl(url)
, downloadPaused(false)
, isCustomFileName(false)
, totalBytes(-1)
, receivedBytes(0)
+ , isSavePageDownload(false)
, page(nullptr)
{
}
@@ -397,25 +397,6 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
- \enum QWebEngineDownloadItem::DownloadType
- \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.
- \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).
-*/
-
-/*!
\enum QWebEngineDownloadItem::DownloadInterruptReason
Describes the reason why a download was interrupted:
@@ -510,78 +491,6 @@ QString QWebEngineDownloadItem::mimeType() const
}
/*!
- \obsolete
-
- Use \l suggestedFileName(), \l downloadDirectory(), and
- \l downloadFileName() instead.
-
- Returns the full target path where data is being downloaded to.
-
- The path includes the file name. The default suggested path is the standard download location
- and file name is deduced not to overwrite already existing files.
-*/
-
-QString QWebEngineDownloadItem::path() const
-{
- Q_D(const QWebEngineDownloadItem);
- return QDir::cleanPath(QDir(d->downloadDirectory).filePath(d->downloadFileName));
-}
-
-/*!
- \obsolete
-
- Use \l setDownloadDirectory() and \l setDownloadFileName() instead.
-
- Sets the full target path to download the file to.
-
- The \a path should also include the file name. The download path can only be set in response
- to the QWebEngineProfile::downloadRequested() signal before the download is accepted.
- Past that point, this function has no effect on the download item's state.
-*/
-void QWebEngineDownloadItem::setPath(QString path)
-{
- Q_D(QWebEngineDownloadItem);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download path is not allowed after the download has been accepted.");
- return;
- }
- if (QDir(d->downloadDirectory).filePath(d->downloadFileName) != path) {
- if (QFileInfo(path).fileName().isEmpty()) {
- qWarning("The download path does not include file name.");
- return;
- }
-
- if (QFileInfo(path).isDir()) {
- qWarning("The download path matches with an already existing directory path.");
- return;
- }
-
- QString newDirectory;
- QString newFileName;
-
- if (QFileInfo(path).fileName() == path) {
- newDirectory = QStringLiteral("");
- newFileName = path;
- } else {
- newDirectory = QFileInfo(path).path();
- newFileName = QFileInfo(path).fileName();
- }
-
- if (d->downloadDirectory != newDirectory) {
- d->downloadDirectory = newDirectory;
- Q_EMIT pathChanged();
- Q_EMIT downloadDirectoryChanged();
- }
-
- if (d->downloadFileName != newFileName) {
- d->downloadFileName = newFileName;
- Q_EMIT pathChanged();
- Q_EMIT downloadFileNameChanged();
- }
- }
-}
-
-/*!
Returns the download directory path.
*/
@@ -707,20 +616,6 @@ void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageF
}
/*!
- Returns the requested download's type.
- \obsolete
-
- \note This property works unreliably, except for \c SavePage
- downloads. Use \l isSavePageDownload() instead.
- */
-
-QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->type;
-}
-
-/*!
Returns \c true if this is a download request for saving a web page.
\sa savePageFormat(), setSavePageFormat()
@@ -728,7 +623,7 @@ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const
bool QWebEngineDownloadItem::isSavePageDownload() const
{
Q_D(const QWebEngineDownloadItem);
- return d->type == QWebEngineDownloadItem::SavePage;
+ return d->isSavePageDownload;
}
/*!
diff --git a/src/core/api/qwebenginedownloaditem.h b/src/core/api/qwebenginedownloaditem.h
index 9310d95db..095c4f79e 100644
--- a/src/core/api/qwebenginedownloaditem.h
+++ b/src/core/api/qwebenginedownloaditem.h
@@ -61,8 +61,6 @@ public:
Q_PROPERTY(qint64 totalBytes READ totalBytes NOTIFY totalBytesChanged FINAL)
Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY receivedBytesChanged FINAL)
Q_PROPERTY(QString mimeType READ mimeType REVISION 1 FINAL)
- Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged FINAL)
- Q_PROPERTY(DownloadType type READ type REVISION 3 FINAL)
Q_PROPERTY(DownloadInterruptReason interruptReason READ interruptReason NOTIFY interruptReasonChanged REVISION 4 FINAL)
Q_PROPERTY(QString interruptReasonString READ interruptReasonString NOTIFY interruptReasonChanged REVISION 4 FINAL)
Q_PROPERTY(bool isFinished READ isFinished NOTIFY isFinishedChanged REVISION 5 FINAL)
@@ -124,38 +122,16 @@ public:
};
Q_ENUM(DownloadInterruptReason)
- enum DownloadType {
- Attachment = 0,
- DownloadAttribute,
- UserRequested,
- SavePage
- };
- Q_ENUM(DownloadType)
-
quint32 id() const;
DownloadState state() const;
qint64 totalBytes() const;
qint64 receivedBytes() const;
QUrl url() const;
QString mimeType() const;
-#if QT_DEPRECATED_SINCE(5, 14)
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- QT_DEPRECATED_VERSION_X(5, 14, "Use downloadDirectory() and downloadFileName() instead")
- QString path() const;
- QT_DEPRECATED_VERSION_X(5, 14, "Use setDownloadDirectory() and setDownloadFileName() instead")
- void setPath(QString path);
-#else
- QT_DEPRECATED_X("Use downloadDirectory() and downloadFileName() instead")
- QString path() const;
- QT_DEPRECATED_X("Use setDownloadDirectory() and setDownloadFileName() instead")
- void setPath(QString path);
-#endif
-#endif
bool isFinished() const;
bool isPaused() const;
SavePageFormat savePageFormat() const;
void setSavePageFormat(SavePageFormat format);
- DownloadType Q_DECL_DEPRECATED type() const;
DownloadInterruptReason interruptReason() const;
QString interruptReasonString() const;
bool isSavePageDownload() const;
@@ -181,7 +157,6 @@ Q_SIGNALS:
Q_REVISION(2) void savePageFormatChanged();
void receivedBytesChanged();
void totalBytesChanged();
- void pathChanged();
Q_REVISION(4) void interruptReasonChanged();
Q_REVISION(5) void isFinishedChanged();
Q_REVISION(5) void isPausedChanged();
diff --git a/src/core/api/qwebenginedownloaditem_p.h b/src/core/api/qwebenginedownloaditem_p.h
index b40a21250..8e38335c2 100644
--- a/src/core/api/qwebenginedownloaditem_p.h
+++ b/src/core/api/qwebenginedownloaditem_p.h
@@ -76,7 +76,6 @@ public:
qint64 startTime;
QWebEngineDownloadItem::DownloadState downloadState;
QWebEngineDownloadItem::SavePageFormat savePageFormat;
- QWebEngineDownloadItem::DownloadType type;
QWebEngineDownloadItem::DownloadInterruptReason interruptReason;
QString downloadPath;
const QUrl downloadUrl;
@@ -88,6 +87,7 @@ public:
bool isCustomFileName;
qint64 totalBytes;
qint64 receivedBytes;
+ bool isSavePageDownload;
QWebEngineDownloadItem *q_ptr;
QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter;
QObject *page;
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index ebf498fdf..9b87d489a 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -68,7 +68,6 @@ DownloadManagerDelegateQt::DownloadManagerDelegateQt(ProfileAdapter *profileAdap
: m_profileAdapter(profileAdapter)
, m_currentId(0)
, m_weakPtrFactory(this)
- , m_nextDownloadIsUserRequested(false)
{
Q_ASSERT(m_profileAdapter);
}
@@ -138,17 +137,6 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
QString suggestedFilename = toQt(item->GetSuggestedFilename());
QString mimeTypeString = toQt(item->GetMimeType());
- int downloadType = 0;
- if (m_nextDownloadIsUserRequested) {
- downloadType = ProfileAdapterClient::UserRequested;
- m_nextDownloadIsUserRequested = false;
- } else {
- bool isAttachment = net::HttpContentDisposition(item->GetContentDisposition(), std::string()).is_attachment();
- if (isAttachment)
- downloadType = ProfileAdapterClient::Attachment;
- else
- downloadType = ProfileAdapterClient::DownloadAttribute;
- }
if (suggestedFilename.isEmpty())
suggestedFilename = toQt(net::HttpContentDisposition(item->GetContentDisposition(), net::kCharsetLatin1).filename());
@@ -191,7 +179,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
false /* accepted */,
false /* paused */,
false /* done */,
- downloadType,
+ false /* isSavePageDownload */,
item->GetLastReason(),
adapterClient,
suggestedFilename,
@@ -292,7 +280,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
acceptedByDefault,
false, /* paused */
false, /* done */
- ProfileAdapterClient::SavePage,
+ true, /* isSavePageDownload */
ProfileAdapterClient::NoReason,
adapterClient,
QFileInfo(suggestedFilePath).fileName(),
diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h
index 0cdbd6ee3..f254d23c9 100644
--- a/src/core/download_manager_delegate_qt.h
+++ b/src/core/download_manager_delegate_qt.h
@@ -89,8 +89,6 @@ public:
void resumeDownload(quint32 downloadId);
void removeDownload(quint32 downloadId);
- void markNextDownloadAsUserRequested() { m_nextDownloadIsUserRequested = true; }
-
// Inherited from content::DownloadItem::Observer
void OnDownloadUpdated(download::DownloadItem *download) override;
void OnDownloadDestroyed(download::DownloadItem *download) override;
@@ -103,7 +101,6 @@ private:
uint32_t m_currentId;
base::WeakPtrFactory<DownloadManagerDelegateQt> m_weakPtrFactory;
- bool m_nextDownloadIsUserRequested;
friend class DownloadManagerDelegateInstance;
friend class ProfileAdapter;
diff --git a/src/core/profile_adapter_client.h b/src/core/profile_adapter_client.h
index 394f92270..07c00044b 100644
--- a/src/core/profile_adapter_client.h
+++ b/src/core/profile_adapter_client.h
@@ -85,13 +85,6 @@ public:
MimeHtmlSaveFormat
};
- enum DownloadType {
- Attachment = 0,
- DownloadAttribute,
- UserRequested,
- SavePage
- };
-
// Keep in sync with content::DownloadInterruptReason
enum DownloadInterruptReason {
NoReason = 0,
@@ -136,7 +129,7 @@ public:
bool accepted;
bool paused;
bool done;
- int downloadType;
+ bool isSavePageDownload;
int downloadInterruptReason;
WebContentsAdapterClient *page;
QString suggestedFileName;
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 21bdea657..2005cdce9 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1113,7 +1113,6 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN
if (!dlm)
return;
- dlmd->markNextDownloadAsUserRequested();
dlm->SetDelegate(dlmd);
net::NetworkTrafficAnnotationTag traffic_annotation =
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index 479fa820d..6ae997da4 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -247,7 +247,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
itemPrivate->suggestedFileName = info.suggestedFileName;
itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(
info.savePageFormat);
- itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType);
+ itemPrivate->isSavePageDownload = info.isSavePageDownload;
if (info.page && info.page->clientType() == QtWebEngineCore::WebContentsAdapterClient::QmlClient)
itemPrivate->page = static_cast<QQuickWebEngineViewPrivate *>(info.page)->q_ptr;
else
diff --git a/src/webengine/doc/src/webengine_download_item.qdoc b/src/webengine/doc/src/webengine_download_item.qdoc
index 5695a2967..9bfa97768 100644
--- a/src/webengine/doc/src/webengine_download_item.qdoc
+++ b/src/webengine/doc/src/webengine_download_item.qdoc
@@ -177,25 +177,6 @@
*/
/*!
- \qmlproperty string WebEngineDownloadItem::path
- \obsolete
-
- Use \l suggestedFileName, \l downloadDirectory, and
- \l downloadFileName instead.
-
- Holds the full target path where data is being downloaded to.
-
- The path includes the file name. The default suggested path is the standard
- download location and file name is deduced not to overwrite already existing files.
-
- The download path can only be set in the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
- the download is accepted.
-
- \sa WebEngineProfile::downloadRequested(), accept()
-*/
-
-/*!
\qmlproperty string WebEngineDownloadItem::downloadDirectory
\since QtWebEngine 1.10
@@ -247,30 +228,6 @@
*/
/*!
- \qmlproperty enumeration WebEngineDownloadItem::type
- \readonly
- \since QtWebEngine 1.4
- \obsolete
-
- Describes the requested download's type.
-
- \note This property works unreliably, except for \c SavePage
- downloads. Use \l isSavePageDownload instead.
-
- \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.
- \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).
-*/
-
-/*!
\qmlproperty bool WebEngineDownloadItem::isSavePageDownload
\readonly
\since QtWebEngine 1.7
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 8dd007d16..499d6df9d 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -233,7 +233,7 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
itemPrivate->suggestedFileName = info.suggestedFileName;
itemPrivate->mimeType = info.mimeType;
itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(info.savePageFormat);
- itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType);
+ itemPrivate->isSavePageDownload = info.isSavePageDownload;
if (info.page && info.page->clientType() == QtWebEngineCore::WebContentsAdapterClient::WidgetsClient)
itemPrivate->page = static_cast<QWebEnginePagePrivate *>(info.page)->q_ptr;
else
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index 3e24632e0..1ffaa13da 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -199,9 +199,7 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineContextMenuRequest.selectedText --> QString"
<< "QWebEngineContextMenuRequest.spellCheckerSuggestions --> QStringList"
<< "QWebEngineContextMenuRequest.position --> QPoint"
- << "QWebEngineDownloadItem.Attachment --> DownloadType"
<< "QWebEngineDownloadItem.CompleteHtmlSaveFormat --> SavePageFormat"
- << "QWebEngineDownloadItem.DownloadAttribute --> DownloadType"
<< "QWebEngineDownloadItem.DownloadCancelled --> DownloadState"
<< "QWebEngineDownloadItem.DownloadCompleted --> DownloadState"
<< "QWebEngineDownloadItem.DownloadInProgress --> DownloadState"
@@ -225,7 +223,6 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadItem.NetworkServerDown --> DownloadInterruptReason"
<< "QWebEngineDownloadItem.NetworkTimeout --> DownloadInterruptReason"
<< "QWebEngineDownloadItem.NoReason --> DownloadInterruptReason"
- << "QWebEngineDownloadItem.SavePage --> DownloadType"
<< "QWebEngineDownloadItem.ServerBadContent --> DownloadInterruptReason"
<< "QWebEngineDownloadItem.ServerCertProblem --> DownloadInterruptReason"
<< "QWebEngineDownloadItem.ServerFailed --> DownloadInterruptReason"
@@ -235,7 +232,6 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadItem.SingleHtmlSaveFormat --> SavePageFormat"
<< "QWebEngineDownloadItem.UnknownSaveFormat --> SavePageFormat"
<< "QWebEngineDownloadItem.UserCanceled --> DownloadInterruptReason"
- << "QWebEngineDownloadItem.UserRequested --> DownloadType"
<< "QWebEngineDownloadItem.accept() --> void"
<< "QWebEngineDownloadItem.cancel() --> void"
<< "QWebEngineDownloadItem.id --> uint"
@@ -248,8 +244,6 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadItem.isPausedChanged() --> void"
<< "QWebEngineDownloadItem.isSavePageDownload --> bool"
<< "QWebEngineDownloadItem.mimeType --> QString"
- << "QWebEngineDownloadItem.path --> QString"
- << "QWebEngineDownloadItem.pathChanged() --> void"
<< "QWebEngineDownloadItem.pause() --> void"
<< "QWebEngineDownloadItem.receivedBytes --> qlonglong"
<< "QWebEngineDownloadItem.receivedBytesChanged() --> void"
@@ -260,7 +254,6 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadItem.stateChanged(QWebEngineDownloadItem::DownloadState) --> void"
<< "QWebEngineDownloadItem.totalBytes --> qlonglong"
<< "QWebEngineDownloadItem.totalBytesChanged() --> void"
- << "QWebEngineDownloadItem.type --> DownloadType"
// FIXME << "QWebEngineDownloadItem.view --> QQuickWebEngineView*"
<< "QWebEngineDownloadItem.url --> QUrl"
<< "QWebEngineDownloadItem.suggestedFileName --> QString"
diff --git a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
index 20e5fbf0d..31874c5e7 100644
--- a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
+++ b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
@@ -238,8 +238,8 @@ void tst_LoadSignals::fileDownloadDoesNotTriggerLoadSignals_qtbug66661()
connect(item, &QWebEngineDownloadItem::stateChanged, [&downloadState](QWebEngineDownloadItem::DownloadState newState){
downloadState = newState;
});
- item->setDownloadDirectory(tempDir.filePath(QFileInfo(item->path()).path()));
- item->setDownloadFileName(QFileInfo(item->path()).fileName());
+ item->setDownloadDirectory(tempDir.path());
+ item->setDownloadFileName(item->suggestedFileName());
item->accept();
});
diff --git a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
index 46de44d08..3d2ad4332 100644
--- a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
+++ b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
@@ -77,9 +77,6 @@ private Q_SLOTS:
void downloadToDefaultLocation();
void downloadToNonExistentDir();
void downloadToReadOnlyDir();
-#if QT_DEPRECATED_SINCE(5, 14)
- void downloadPathValidation();
-#endif
void downloadToDirectoryWithFileName_data();
void downloadToDirectoryWithFileName();
@@ -88,10 +85,6 @@ private:
void clickLink(QPoint linkPos);
void simulateUserAction(QPoint linkPos, UserAction action);
- QWebEngineDownloadItem::DownloadType expectedDownloadType(
- UserAction userAction,
- const QByteArray &contentDisposition = QByteArray());
-
HttpServer *m_server;
QWebEngineProfile *m_profile;
QWebEnginePage *m_page;
@@ -192,16 +185,6 @@ void tst_QWebEngineDownloadItem::simulateUserAction(QPoint linkPos, UserAction a
}
}
-QWebEngineDownloadItem::DownloadType tst_QWebEngineDownloadItem::expectedDownloadType(
- UserAction userAction, const QByteArray &contentDisposition)
-{
- if (userAction == SaveLink)
- return QWebEngineDownloadItem::UserRequested;
- if (contentDisposition == QByteArrayLiteral("attachment"))
- return QWebEngineDownloadItem::Attachment;
- return QWebEngineDownloadItem::DownloadAttribute;
-}
-
void tst_QWebEngineDownloadItem::downloadLink_data()
{
QTest::addColumn<UserAction>("userAction");
@@ -213,7 +196,6 @@ void tst_QWebEngineDownloadItem::downloadLink_data()
QTest::addColumn<QByteArray>("fileDisposition");
QTest::addColumn<bool>("fileHasReferer");
QTest::addColumn<FileAction>("fileAction");
- QTest::addColumn<QWebEngineDownloadItem::DownloadType>("downloadType");
// SaveLink should always trigger a download, even for empty files.
QTest::newRow("save link to empty file")
@@ -463,7 +445,6 @@ void tst_QWebEngineDownloadItem::downloadLink()
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), expectedDownloadType(userAction, fileDisposition));
QCOMPARE(item->isSavePageDownload(), false);
QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected));
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), suggestedPath);
@@ -477,7 +458,6 @@ void tst_QWebEngineDownloadItem::downloadLink()
QCOMPARE(item->totalBytes(), fileContents.size());
QCOMPARE(item->receivedBytes(), fileContents.size());
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), expectedDownloadType(userAction, fileDisposition));
QCOMPARE(item->isSavePageDownload(), false);
QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected));
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), downloadPath);
@@ -586,14 +566,8 @@ void tst_QWebEngineDownloadItem::downloadTwoLinks()
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), standardDir + filePart);
// type() is broken due to race condition in DownloadManagerDelegateQt
- if (action1 == ClickLink && action2 == ClickLink) {
- if (filePart == QStringLiteral("/file1"))
- QCOMPARE(item->type(), expectedDownloadType(action1));
- else if (filePart == QStringLiteral("/file2"))
- QCOMPARE(item->type(), expectedDownloadType(action2, QByteArrayLiteral("attachment")));
- else
+ if (action1 == ClickLink && action2 == ClickLink && filePart != QStringLiteral("/file1") && filePart != QStringLiteral("/file2"))
QFAIL(qPrintable("Unexpected file name: " + filePart));
- }
connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&]() {
finishedCount++;
@@ -663,7 +637,6 @@ void tst_QWebEngineDownloadItem::downloadPage()
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::SavePage);
QCOMPARE(item->isSavePageDownload(), true);
// FIXME(juvaldma): why is mimeType always the same?
QCOMPARE(item->mimeType(), QStringLiteral("application/x-mimearchive"));
@@ -687,7 +660,6 @@ void tst_QWebEngineDownloadItem::downloadPage()
QCOMPARE(item->totalBytes(), item->receivedBytes());
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(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), downloadPath);
@@ -924,7 +896,6 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilename()
QCOMPARE(item->totalBytes(), item->receivedBytes());
QVERIFY(item->receivedBytes() > 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::Attachment);
QCOMPARE(item->isSavePageDownload(), false);
downloadedFilePath = QDir(item->downloadDirectory()).filePath(item->downloadFileName());
downloadFinished = true;
@@ -1159,126 +1130,6 @@ void tst_QWebEngineDownloadItem::downloadToReadOnlyDir()
QFile(m_profile->downloadPath()).setPermissions(QFileDevice::WriteOwner);
}
-#if QT_DEPRECATED_SINCE(5, 14)
-void tst_QWebEngineDownloadItem::downloadPathValidation()
-{
- const QString fileName = "test.txt";
- QString downloadPath;
- QString originalDownloadPath;
-
- QTemporaryDir tmpDir;
- QVERIFY(tmpDir.isValid());
- m_profile->setDownloadPath(tmpDir.path());
-
- // Set up HTTP server
- ScopedConnection sc1 = connect(m_server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
- auto requestPath = QString::fromUtf8(rr->requestPath());
- if (rr->requestMethod() == "GET" && requestPath == ("/" + fileName)) {
- rr->setResponseHeader(QByteArrayLiteral("content-type"), QByteArrayLiteral("application/octet-stream"));
- rr->setResponseHeader(QByteArrayLiteral("content-disposition"), QByteArrayLiteral("attachment"));
- rr->setResponseBody(QByteArrayLiteral("a"));
- rr->sendResponse();
- } else {
- rr->setResponseStatus(404);
- rr->sendResponse();
- }
- });
-
- // Set up profile and download handler
- QPointer<QWebEngineDownloadItem> downloadItem;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
- downloadItem = item;
- originalDownloadPath = item->path();
-
- item->setPath(downloadPath);
- item->accept();
-
- connect(item, &QWebEngineDownloadItem::stateChanged, [&, item](QWebEngineDownloadItem::DownloadState downloadState) {
- if (downloadState == QWebEngineDownloadItem::DownloadInterrupted) {
- item->cancel();
- }
- });
-
- connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {
- QCOMPARE(item->isFinished(), true);
- QCOMPARE(item->totalBytes(), item->receivedBytes());
- QVERIFY(item->receivedBytes() > 0);
- QCOMPARE(item->page(), m_page);
- });
- });
-
- QString oldPath = QDir::currentPath();
- QDir::setCurrent(tmpDir.path());
-
- // Set only the file name.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = fileName;
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), fileName);
-
- // Set only the directory path.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = tmpDir.path();
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- // Set only the directory path with separator.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = tmpDir.path() + QDir::separator();
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- // Set only the directory with the current directory path without ending separator.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = ".";
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- // Set only the directory with the current directory path with ending separator.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = "./";
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = "...";
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
-#if !defined(Q_OS_WIN)
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCancelled);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::FileFailed);
- QCOMPARE(downloadItem->path(), downloadPath);
-#else
- // Windows interprets the "..." path as a valid path. It will be the current path.
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-#endif // !defined(Q_OS_WIN)
- QDir::setCurrent(oldPath);
-}
-#endif
-
void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName_data()
{
QTest::addColumn<bool>("setDirectoryFirst");
@@ -1335,7 +1186,6 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
QCOMPARE(item->downloadDirectory(), downloadDirectory);
}
- QCOMPARE(item->path(), QDir(item->downloadDirectory()).filePath(item->downloadFileName()));
item->accept();
connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {