diff options
Diffstat (limited to 'src/webengine/api')
-rw-r--r-- | src/webengine/api/qquickwebengineclientcertificateselection.cpp | 19 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineclientcertificateselection_p.h | 6 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedialogrequests.cpp | 6 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem.cpp | 26 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem_p_p.h | 1 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 65 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.h | 5 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile_p.h | 9 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginesettings.cpp | 22 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginesettings_p.h | 4 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 4 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p_p.h | 2 |
12 files changed, 109 insertions, 60 deletions
diff --git a/src/webengine/api/qquickwebengineclientcertificateselection.cpp b/src/webengine/api/qquickwebengineclientcertificateselection.cpp index 56cf1ff64..c48a59887 100644 --- a/src/webengine/api/qquickwebengineclientcertificateselection.cpp +++ b/src/webengine/api/qquickwebengineclientcertificateselection.cpp @@ -55,23 +55,10 @@ QT_BEGIN_NAMESPACE \sa {WebEngineClientCertificateSelection::certificates} {WebEngineClientCertificateSelection.certificates} */ -QQuickWebEngineClientCertificateOption::QQuickWebEngineClientCertificateOption() = default; - QQuickWebEngineClientCertificateOption::QQuickWebEngineClientCertificateOption(QQuickWebEngineClientCertificateSelection *selection, int index) - : QObject(), m_selection(selection), m_index(index) -{} - -QQuickWebEngineClientCertificateOption::QQuickWebEngineClientCertificateOption(const QQuickWebEngineClientCertificateOption &other) - : QObject(), m_selection(other.m_selection), m_index(other.m_index) + : QObject(selection), m_selection(selection), m_index(index) {} -QQuickWebEngineClientCertificateOption &QQuickWebEngineClientCertificateOption::operator=(const QQuickWebEngineClientCertificateOption &other) -{ - m_selection = other.m_selection; - m_index = other.m_index; - return *this; -} - /*! \qmlproperty string WebEngineClientCertificateOption::issuer \brief The issuer of the certificate. @@ -164,7 +151,7 @@ QQuickWebEngineClientCertificateOption *QQuickWebEngineClientCertificateSelectio QQuickWebEngineClientCertificateSelection *d = static_cast<QQuickWebEngineClientCertificateSelection *>(p->object); if (idx < 0 || idx >= d->m_certificates.size()) return nullptr; - return &d->m_certificates[idx]; + return d->m_certificates[idx]; } /*! @@ -177,7 +164,7 @@ QQmlListProperty<QQuickWebEngineClientCertificateOption> QQuickWebEngineClientCe if (m_certificates.empty()) { QVector<QSslCertificate> certificates = d_ptr->certificates(); for (int i = 0; i < certificates.count(); ++i) - m_certificates.push_back(QQuickWebEngineClientCertificateOption(this, i)); + m_certificates.push_back(new QQuickWebEngineClientCertificateOption(this, i)); } return QQmlListProperty<QQuickWebEngineClientCertificateOption>( diff --git a/src/webengine/api/qquickwebengineclientcertificateselection_p.h b/src/webengine/api/qquickwebengineclientcertificateselection_p.h index 7f5a26296..adf8b5f7c 100644 --- a/src/webengine/api/qquickwebengineclientcertificateselection_p.h +++ b/src/webengine/api/qquickwebengineclientcertificateselection_p.h @@ -76,10 +76,6 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineClientCertificateOption : public Q_PROPERTY(bool isSelfSigned READ isSelfSigned CONSTANT FINAL) public: - QQuickWebEngineClientCertificateOption(); - QQuickWebEngineClientCertificateOption(const QQuickWebEngineClientCertificateOption &); - QQuickWebEngineClientCertificateOption &operator=(const QQuickWebEngineClientCertificateOption &); - QString issuer() const; QString subject() const; QDateTime effectiveDate() const; @@ -120,7 +116,7 @@ private: explicit QQuickWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController>); - mutable QVector<QQuickWebEngineClientCertificateOption> m_certificates; + mutable QVector<QQuickWebEngineClientCertificateOption *> m_certificates; QSharedPointer<ClientCertSelectController> d_ptr; }; diff --git a/src/webengine/api/qquickwebenginedialogrequests.cpp b/src/webengine/api/qquickwebenginedialogrequests.cpp index 01e757375..da1aecaf6 100644 --- a/src/webengine/api/qquickwebenginedialogrequests.cpp +++ b/src/webengine/api/qquickwebenginedialogrequests.cpp @@ -343,8 +343,8 @@ QString QQuickWebEngineJavaScriptDialogRequest::title() const \qmlproperty enumeration JavaScriptDialogRequest::type \readonly - Returns the type of the requested dialog box, see HTML5's - + Returns the type of the requested dialog box. For more information, see + HTML5's \l{https://www.w3.org/TR/html5/webappapis.html#simple-dialogs}{Simple Dialogs}. \value JavaScriptDialogRequest.DialogTypeAlert @@ -353,7 +353,7 @@ QString QQuickWebEngineJavaScriptDialogRequest::title() const A JavaScript confirmation dialog. \value JavaScriptDialogRequest.DialogTypePrompt A JavaScript prompt dialog. - \value JavaScriptDialogRequest.DialogTypeUnload + \value JavaScriptDialogRequest.DialogTypeBeforeUnload The users should be asked if they want to leave the page. */ diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index a80f163d5..981d11633 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -185,10 +185,8 @@ void QQuickWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::Down Q_EMIT q->totalBytesChanged(); } - if (info.done != downloadFinished) { - downloadFinished = info.done; - Q_EMIT q->isFinishedChanged(); - } + if (info.done) + setFinished(); if (info.paused != downloadPaused) { downloadPaused = info.paused; @@ -206,6 +204,17 @@ void QQuickWebEngineDownloadItemPrivate::updateState(QQuickWebEngineDownloadItem } } +void QQuickWebEngineDownloadItemPrivate::setFinished() +{ + Q_Q(QQuickWebEngineDownloadItem); + + if (downloadFinished) + return; + + downloadFinished = true; + Q_EMIT q->isFinishedChanged(); +} + /*! \qmlmethod void WebEngineDownloadItem::accept() @@ -255,6 +264,7 @@ void QQuickWebEngineDownloadItem::cancel() return; d->updateState(QQuickWebEngineDownloadItem::DownloadCancelled); + d->setFinished(); // We directly cancel the download if the user cancels before // it even started, so no need to notify the profile here. @@ -593,12 +603,14 @@ bool QQuickWebEngineDownloadItem::isPaused() const } /*! - \qmlproperty bool WebEngineDownloadItem::view + \qmlproperty WebEngineView WebEngineDownloadItem::view \readonly \since QtWebEngine 1.8 Returns the view the download was requested on. If the download was not triggered by content in a view, \c nullptr is returned. + + \sa WebEngineView */ QQuickWebEngineView *QQuickWebEngineDownloadItem::view() const { @@ -615,8 +627,8 @@ QQuickWebEngineDownloadItem::QQuickWebEngineDownloadItem(QQuickWebEngineDownload QQuickWebEngineDownloadItem::~QQuickWebEngineDownloadItem() { - if (d_ptr->profile) - d_ptr->profile->d_ptr->profileAdapter()->removeDownload(d_ptr->downloadId); + if (!isFinished()) + cancel(); } QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h index 4b89335bd..f444c04a5 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h @@ -85,6 +85,7 @@ public: void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info); void updateState(QQuickWebEngineDownloadItem::DownloadState newState); + void setFinished(); }; QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index cf9dae90a..ac75b5356 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -171,11 +171,6 @@ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(ProfileAdapter *pro QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() { - - while (!m_webContentsAdapterClients.isEmpty()) { - m_webContentsAdapterClients.first()->destroy(); - } - if (m_profileAdapter) { // In the case the user sets this profile as the parent of the interceptor // it can be deleted before the browser-context still referencing it is. @@ -183,25 +178,20 @@ QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() m_profileAdapter->removeClient(this); } - for (QQuickWebEngineDownloadItem *download : qAsConst(m_ongoingDownloads)) { - if (download) - download->cancel(); - } - - m_ongoingDownloads.clear(); - if (m_profileAdapter != QtWebEngineCore::ProfileAdapter::defaultProfileAdapter()) delete m_profileAdapter; } -void QQuickWebEngineProfilePrivate::addWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter) +void QQuickWebEngineProfilePrivate::addWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter) { - m_webContentsAdapterClients.append(adapter); + Q_ASSERT(m_profileAdapter); + m_profileAdapter->addWebContentsAdapterClient(adapter); } -void QQuickWebEngineProfilePrivate::removeWebContentsAdapterClient(QQuickWebEngineViewPrivate*adapter) +void QQuickWebEngineProfilePrivate::removeWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient*adapter) { - m_webContentsAdapterClients.removeAll(adapter); + Q_ASSERT(m_profileAdapter); + m_profileAdapter->removeWebContentsAdapterClient(adapter); } QtWebEngineCore::ProfileAdapter *QQuickWebEngineProfilePrivate::profileAdapter() const @@ -223,6 +213,23 @@ void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId) void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) { m_ongoingDownloads.remove(downloadId); + if (m_profileAdapter) + m_profileAdapter->removeDownload(downloadId); +} + +void QQuickWebEngineProfilePrivate::cleanDownloads() +{ + for (auto download : m_ongoingDownloads.values()) { + if (!download) + continue; + + if (!download->isFinished()) + download->cancel(); + + if (m_profileAdapter) + m_profileAdapter->removeDownload(download->id()); + } + m_ongoingDownloads.clear(); } void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) @@ -247,6 +254,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q); m_ongoingDownloads.insert(info.id, download); + QObject::connect(download, &QQuickWebEngineDownloadItem::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); }); QQmlEngine::setObjectOwnership(download, QQmlEngine::JavaScriptOwnership); Q_EMIT q->downloadRequested(download); @@ -260,7 +268,6 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) if (state == QQuickWebEngineDownloadItem::DownloadRequested) { // Delete unaccepted downloads. info.accepted = false; - m_ongoingDownloads.remove(info.id); delete download; } } @@ -283,7 +290,6 @@ void QQuickWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info if (info.state != ProfileAdapterClient::DownloadInProgress) { Q_EMIT q->downloadFinished(download); - m_ongoingDownloads.remove(info.id); } } @@ -382,6 +388,7 @@ void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty<QQuickWeb /*! \qmlsignal WebEngineProfile::userNotification(WebEngineNotification notification) + \since QtWebEngine 1.9 This signal is emitted whenever there is a newly created user notification. The \a notification argument holds the notification instance to query data and interact with. @@ -409,6 +416,7 @@ QQuickWebEngineProfile::QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *pr */ QQuickWebEngineProfile::~QQuickWebEngineProfile() { + d_ptr->cleanDownloads(); } /*! @@ -880,7 +888,7 @@ bool QQuickWebEngineProfile::isUsedForGlobalCertificateVerification() const Overrides the default path used for download location. - If set to the null string, the default path is restored. + If set to an empty string, the default path is restored. \note By default, the download path is QStandardPaths::DownloadLocation. */ @@ -893,7 +901,7 @@ bool QQuickWebEngineProfile::isUsedForGlobalCertificateVerification() const Overrides the default path used for download location, setting it to \a path. - If set to the null string, the default path is restored. + If set to an empty string, the default path is restored. \note By default, the download path is QStandardPaths::DownloadLocation. */ @@ -1056,7 +1064,7 @@ QQuickWebEngineSettings *QQuickWebEngineProfile::settings() const \property QQuickWebEngineProfile::userScripts \since 5.9 - \brief the collection of scripts that are injected into all pages that share + \brief The collection of scripts that are injected into all pages that share this profile. \sa QQuickWebEngineScript, QQmlListReference @@ -1071,4 +1079,19 @@ QQmlListProperty<QQuickWebEngineScript> QQuickWebEngineProfile::userScripts() d->userScripts_clear); } +/*! + \since 5.13 + + Returns the profile's client certificate store. +*/ +QWebEngineClientCertificateStore *QQuickWebEngineProfile::clientCertificateStore() +{ +#if QT_CONFIG(ssl) + Q_D(QQuickWebEngineProfile); + return d->profileAdapter()->clientCertificateStore(); +#else + return nullptr; +#endif +} + QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h index ce3285ec9..e6f9fb73d 100644 --- a/src/webengine/api/qquickwebengineprofile.h +++ b/src/webengine/api/qquickwebengineprofile.h @@ -54,6 +54,7 @@ class QQuickWebEngineDownloadItem; class QQuickWebEngineProfilePrivate; class QQuickWebEngineScript; class QQuickWebEngineSettings; +class QWebEngineClientCertificateStore; class QWebEngineCookieStore; class QWebEngineNotification; class QWebEngineUrlRequestInterceptor; @@ -153,6 +154,8 @@ public: QString downloadPath() const; void setDownloadPath(const QString &path); + QWebEngineClientCertificateStore *clientCertificateStore(); + static QQuickWebEngineProfile *defaultProfile(); Q_SIGNALS: @@ -173,7 +176,7 @@ Q_SIGNALS: void downloadRequested(QQuickWebEngineDownloadItem *download); void downloadFinished(QQuickWebEngineDownloadItem *download); - void userNotification(QWebEngineNotification *notification); + Q_REVISION(5) void userNotification(QWebEngineNotification *notification); private: Q_DECLARE_PRIVATE(QQuickWebEngineProfile) diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index 322ec0101..c6d412ab3 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -53,7 +53,7 @@ #include "profile_adapter_client.h" #include "profile_adapter.h" -#include "qquickwebengineprofile_p.h" +#include "qquickwebengineprofile.h" #include <QExplicitlySharedDataPointer> #include <QMap> @@ -71,8 +71,8 @@ public: Q_DECLARE_PUBLIC(QQuickWebEngineProfile) QQuickWebEngineProfilePrivate(QtWebEngineCore::ProfileAdapter *profileAdapter); ~QQuickWebEngineProfilePrivate(); - void addWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter); - void removeWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter); + void addWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter) override; + void removeWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter) override; QtWebEngineCore::ProfileAdapter* profileAdapter() const; QQuickWebEngineSettings *settings() const; @@ -80,6 +80,8 @@ public: void cancelDownload(quint32 downloadId); void downloadDestroyed(quint32 downloadId); + void cleanDownloads(); + void downloadRequested(DownloadItemInfo &info) override; void downloadUpdated(const DownloadItemInfo &info) override; @@ -100,7 +102,6 @@ private: QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter; QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads; QList<QQuickWebEngineScript *> m_userScripts; - QVector<QQuickWebEngineViewPrivate *> m_webContentsAdapterClients; }; QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index 6e96e76cf..93a3668ed 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -457,6 +457,20 @@ bool QQuickWebEngineSettings::dnsPrefetchEnabled() const } /*! + \qmlproperty bool WebEngineSettings::pdfViewerEnabled + \since QtWebEngine 1.9 + + Specifies that PDF documents will be opened in the internal PDF viewer + instead of being downloaded. + + Enabled by default. +*/ +bool QQuickWebEngineSettings::pdfViewerEnabled() const +{ + return d_ptr->testAttribute(WebEngineSettings::PdfViewerEnabled); +} + +/*! \qmlproperty string WebEngineSettings::defaultTextEncoding \since QtWebEngine 1.2 @@ -714,6 +728,14 @@ void QQuickWebEngineSettings::setDnsPrefetchEnabled(bool on) Q_EMIT dnsPrefetchEnabledChanged(); } +void QQuickWebEngineSettings::setPdfViewerEnabled(bool on) +{ + bool wasOn = d_ptr->testAttribute(WebEngineSettings::PdfViewerEnabled); + d_ptr->setAttribute(WebEngineSettings::PdfViewerEnabled, on); + if (wasOn != on) + Q_EMIT pdfViewerEnabledChanged(); +} + void QQuickWebEngineSettings::setUnknownUrlSchemePolicy(QQuickWebEngineSettings::UnknownUrlSchemePolicy policy) { WebEngineSettings::UnknownUrlSchemePolicy oldPolicy = d_ptr->unknownUrlSchemePolicy(); diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h index 6e1aaca39..ce43e0e9c 100644 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ b/src/webengine/api/qquickwebenginesettings_p.h @@ -93,6 +93,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject { Q_PROPERTY(bool webRTCPublicInterfacesOnly READ webRTCPublicInterfacesOnly WRITE setWebRTCPublicInterfacesOnly NOTIFY webRTCPublicInterfacesOnlyChanged REVISION 6 FINAL) Q_PROPERTY(bool javascriptCanPaste READ javascriptCanPaste WRITE setJavascriptCanPaste NOTIFY javascriptCanPasteChanged REVISION 6 FINAL) Q_PROPERTY(bool dnsPrefetchEnabled READ dnsPrefetchEnabled WRITE setDnsPrefetchEnabled NOTIFY dnsPrefetchEnabledChanged REVISION 7 FINAL) + Q_PROPERTY(bool pdfViewerEnabled READ pdfViewerEnabled WRITE setPdfViewerEnabled NOTIFY pdfViewerEnabledChanged REVISION 8 FINAL) public: enum UnknownUrlSchemePolicy { @@ -135,6 +136,7 @@ public: bool webRTCPublicInterfacesOnly() const; bool javascriptCanPaste() const; bool dnsPrefetchEnabled() const; + bool pdfViewerEnabled() const; void setAutoLoadImages(bool on); void setJavascriptEnabled(bool on); @@ -166,6 +168,7 @@ public: void setWebRTCPublicInterfacesOnly(bool on); void setJavascriptCanPaste(bool on); void setDnsPrefetchEnabled(bool on); + void setPdfViewerEnabled(bool on); signals: void autoLoadImagesChanged(); @@ -198,6 +201,7 @@ signals: Q_REVISION(6) void webRTCPublicInterfacesOnlyChanged(); Q_REVISION(6) void javascriptCanPasteChanged(); Q_REVISION(7) void dnsPrefetchEnabledChanged(); + Q_REVISION(8) void pdfViewerEnabledChanged(); private: explicit QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings = 0); diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index b6b542f15..f17265cfd 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -190,7 +190,7 @@ bool QQuickWebEngineViewPrivate::profileInitialized() const return m_profileInitialized; } -void QQuickWebEngineViewPrivate::destroy() +void QQuickWebEngineViewPrivate::releaseProfile() { // The profile for this web contents is about to be // garbage collected, delete WebContents first and @@ -1326,7 +1326,7 @@ void QQuickWebEngineView::setBackgroundColor(const QColor &color) /*! \property QQuickWebEngineView::audioMuted - \brief the state of whether the current page audio is muted. + \brief The state of whether the current page audio is muted. \since 5.7 The default value is false. diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 543d7b119..e625e0ccc 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -94,7 +94,7 @@ public: QQuickWebEngineView *q_ptr; QQuickWebEngineViewPrivate(); ~QQuickWebEngineViewPrivate(); - void destroy(); + void releaseProfile() override; void initializeProfile(); QtWebEngineCore::UIDelegatesManager *ui(); |