diff options
Diffstat (limited to 'src/webenginewidgets/api')
-rw-r--r-- | src/webenginewidgets/api/qwebengineclientcertificateselection.cpp | 123 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineclientcertificateselection.h | 80 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem.cpp | 94 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem.h | 3 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem_p.h | 3 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 174 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.h | 10 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage_p.h | 7 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 137 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile_p.h | 12 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginescriptcollection.cpp | 8 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginesettings.cpp | 2 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginesettings.h | 1 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineview.cpp | 21 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineview.h | 2 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineview_p.h | 2 |
16 files changed, 518 insertions, 161 deletions
diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp b/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp new file mode 100644 index 000000000..8b5f49d6b --- /dev/null +++ b/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebengineclientcertificateselection.h" + +#if QT_CONFIG(ssl) + +#include "client_cert_select_controller.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QWebEngineClientCertificateSelection + \brief The QWebEngineClientCertSelection class wraps a client certificate selection. + \since 5.12 + \inmodule QtWebEngineWidgets + + Provides access to the certificates to choose from, and a method for selecting one. + + The selection is asynchronous. If no certificate is selected and no copy of the + object is kept alive, loading will continue without a certificate. +*/ + +/*! \internal +*/ +QWebEngineClientCertificateSelection::QWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController> selectController) + : d_ptr(selectController) +{} + +QWebEngineClientCertificateSelection::QWebEngineClientCertificateSelection(const QWebEngineClientCertificateSelection &other) + : d_ptr(other.d_ptr) +{} + +QWebEngineClientCertificateSelection &QWebEngineClientCertificateSelection::operator=(const QWebEngineClientCertificateSelection &other) +{ + d_ptr = other.d_ptr; + return *this; +} + +QWebEngineClientCertificateSelection::~QWebEngineClientCertificateSelection() +{ +} + +/*! + Returns the client certificates available to choose from. + + \sa select() +*/ +QVector<QSslCertificate> QWebEngineClientCertificateSelection::certificates() const +{ + return d_ptr->certificates(); +} + +/*! + Selects the client certificate \a certificate. The certificate must be one + of those offered in certificates(). + + \sa certificates(), selectNone() +*/ +void QWebEngineClientCertificateSelection::select(const QSslCertificate &certificate) +{ + d_ptr->select(certificate); +} + +/*! + Continue without using any of the offered certificates. This is the same + action as taken when destroying the last copy of this object if no + selection has been made. + + \sa select() +*/ +void QWebEngineClientCertificateSelection::selectNone() +{ + d_ptr->selectNone(); +} + +/*! + Returns the host and port of the server requesting the client certificate. +*/ +QUrl QWebEngineClientCertificateSelection::host() const +{ + return d_ptr->hostAndPort(); +} + +QT_END_NAMESPACE + +#endif // QT_CONFIG(ssl) diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.h b/src/webenginewidgets/api/qwebengineclientcertificateselection.h new file mode 100644 index 000000000..15b8a47c6 --- /dev/null +++ b/src/webenginewidgets/api/qwebengineclientcertificateselection.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINECLIENTCERTSELECTION_H +#define QWEBENGINECLIENTCERTSELECTION_H + +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> +#include <QtNetwork/qtnetwork-config.h> + +#if QT_CONFIG(ssl) + +#include <QtCore/qscopedpointer.h> +#include <QtCore/qvector.h> +#include <QtNetwork/qsslcertificate.h> + +QT_BEGIN_NAMESPACE +class ClientCertSelectController; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineClientCertificateSelection { +public: + QWebEngineClientCertificateSelection(const QWebEngineClientCertificateSelection &); + ~QWebEngineClientCertificateSelection(); + + QWebEngineClientCertificateSelection &operator=(const QWebEngineClientCertificateSelection &); + + QUrl host() const; + + void select(const QSslCertificate &certificate); + void selectNone(); + QVector<QSslCertificate> certificates() const; + +private: + friend class QWebEnginePagePrivate; + + QWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController>); + + QSharedPointer<ClientCertSelectController> d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QT_CONFIG(ssl) + +#endif // QWEBENGINECLIENTCERTSELECTION_H diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index ada7e058c..fc27e104d 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -40,52 +40,52 @@ #include "qwebenginedownloaditem.h" #include "qwebenginedownloaditem_p.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "qwebengineprofile_p.h" QT_BEGIN_NAMESPACE -using QtWebEngineCore::BrowserContextAdapterClient; - -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NoReason, QWebEngineDownloadItem::NoReason) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileFailed, QWebEngineDownloadItem::FileFailed) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileAccessDenied, QWebEngineDownloadItem::FileAccessDenied) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileNoSpace, QWebEngineDownloadItem::FileNoSpace) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileNameTooLong, QWebEngineDownloadItem::FileNameTooLong) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTooLarge, QWebEngineDownloadItem::FileTooLarge) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileVirusInfected, QWebEngineDownloadItem::FileVirusInfected) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTransientError, QWebEngineDownloadItem::FileTransientError) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileBlocked, QWebEngineDownloadItem::FileBlocked) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileSecurityCheckFailed, QWebEngineDownloadItem::FileSecurityCheckFailed) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTooShort, QWebEngineDownloadItem::FileTooShort) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileHashMismatch, QWebEngineDownloadItem::FileHashMismatch) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkFailed, QWebEngineDownloadItem::NetworkFailed) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkTimeout, QWebEngineDownloadItem::NetworkTimeout) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkDisconnected, QWebEngineDownloadItem::NetworkDisconnected) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkServerDown, QWebEngineDownloadItem::NetworkServerDown) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkInvalidRequest, QWebEngineDownloadItem::NetworkInvalidRequest) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerFailed, QWebEngineDownloadItem::ServerFailed) -//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerNoRange, QWebEngineDownloadItem::ServerNoRange) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerBadContent, QWebEngineDownloadItem::ServerBadContent) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerUnauthorized, QWebEngineDownloadItem::ServerUnauthorized) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerCertProblem, QWebEngineDownloadItem::ServerCertProblem) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerForbidden, QWebEngineDownloadItem::ServerForbidden) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerUnreachable, QWebEngineDownloadItem::ServerUnreachable) -ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::UserCanceled, QWebEngineDownloadItem::UserCanceled) -//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::UserShutdown, QWebEngineDownloadItem::UserShutdown) -//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::Crash, QWebEngineDownloadItem::Crash) +using QtWebEngineCore::ProfileAdapterClient; + +ASSERT_ENUMS_MATCH(ProfileAdapterClient::NoReason, QWebEngineDownloadItem::NoReason) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileFailed, QWebEngineDownloadItem::FileFailed) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileAccessDenied, QWebEngineDownloadItem::FileAccessDenied) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNoSpace, QWebEngineDownloadItem::FileNoSpace) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNameTooLong, QWebEngineDownloadItem::FileNameTooLong) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooLarge, QWebEngineDownloadItem::FileTooLarge) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileVirusInfected, QWebEngineDownloadItem::FileVirusInfected) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTransientError, QWebEngineDownloadItem::FileTransientError) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileBlocked, QWebEngineDownloadItem::FileBlocked) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileSecurityCheckFailed, QWebEngineDownloadItem::FileSecurityCheckFailed) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooShort, QWebEngineDownloadItem::FileTooShort) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileHashMismatch, QWebEngineDownloadItem::FileHashMismatch) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkFailed, QWebEngineDownloadItem::NetworkFailed) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkTimeout, QWebEngineDownloadItem::NetworkTimeout) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkDisconnected, QWebEngineDownloadItem::NetworkDisconnected) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkServerDown, QWebEngineDownloadItem::NetworkServerDown) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkInvalidRequest, QWebEngineDownloadItem::NetworkInvalidRequest) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerFailed, QWebEngineDownloadItem::ServerFailed) +//ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerNoRange, QWebEngineDownloadItem::ServerNoRange) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerBadContent, QWebEngineDownloadItem::ServerBadContent) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnauthorized, QWebEngineDownloadItem::ServerUnauthorized) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerCertProblem, QWebEngineDownloadItem::ServerCertProblem) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerForbidden, QWebEngineDownloadItem::ServerForbidden) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnreachable, QWebEngineDownloadItem::ServerUnreachable) +ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserCanceled, QWebEngineDownloadItem::UserCanceled) +//ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserShutdown, QWebEngineDownloadItem::UserShutdown) +//ASSERT_ENUMS_MATCH(ProfileAdapterClient::Crash, QWebEngineDownloadItem::Crash) static inline QWebEngineDownloadItem::DownloadState toDownloadState(int state) { switch (state) { - case BrowserContextAdapterClient::DownloadInProgress: + case ProfileAdapterClient::DownloadInProgress: return QWebEngineDownloadItem::DownloadInProgress; - case BrowserContextAdapterClient::DownloadCompleted: + case ProfileAdapterClient::DownloadCompleted: return QWebEngineDownloadItem::DownloadCompleted; - case BrowserContextAdapterClient::DownloadCancelled: + case ProfileAdapterClient::DownloadCancelled: return QWebEngineDownloadItem::DownloadCancelled; - case BrowserContextAdapterClient::DownloadInterrupted: + case ProfileAdapterClient::DownloadInterrupted: return QWebEngineDownloadItem::DownloadInterrupted; default: Q_UNREACHABLE(); @@ -169,6 +169,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr , downloadPaused(false) , totalBytes(-1) , receivedBytes(0) + , page(0) { } @@ -176,7 +177,7 @@ QWebEngineDownloadItemPrivate::~QWebEngineDownloadItemPrivate() { } -void QWebEngineDownloadItemPrivate::update(const BrowserContextAdapterClient::DownloadItemInfo &info) +void QWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadItemInfo &info) { Q_Q(QWebEngineDownloadItem); @@ -256,8 +257,8 @@ void QWebEngineDownloadItem::cancel() // We directly cancel the download request if the user cancels // before it even started, so no need to notify the profile here. if (state == QWebEngineDownloadItem::DownloadInProgress) { - if (auto browserContext = d->profile->browserContext()) - browserContext->cancelDownload(d->downloadId); + if (auto profileAdapter = d->profile->profileAdapter()) + profileAdapter->cancelDownload(d->downloadId); } else { d->downloadState = QWebEngineDownloadItem::DownloadCancelled; Q_EMIT stateChanged(d->downloadState); @@ -283,7 +284,7 @@ void QWebEngineDownloadItem::pause() if (state != QWebEngineDownloadItem::DownloadInProgress) return; - d->profile->browserContext()->pauseDownload(d->downloadId); + d->profile->profileAdapter()->pauseDownload(d->downloadId); } /*! @@ -303,7 +304,7 @@ void QWebEngineDownloadItem::resume() if (d->downloadFinished || (state != QWebEngineDownloadItem::DownloadInProgress && state != QWebEngineDownloadItem::DownloadInterrupted)) return; - d->profile->browserContext()->resumeDownload(d->downloadId); + d->profile->profileAdapter()->resumeDownload(d->downloadId); } /*! @@ -626,8 +627,19 @@ QWebEngineDownloadItem::DownloadInterruptReason QWebEngineDownloadItem::interrup QString QWebEngineDownloadItem::interruptReasonString() const { - return BrowserContextAdapterClient::downloadInterruptReasonToString( - static_cast<BrowserContextAdapterClient::DownloadInterruptReason>(interruptReason())); + return ProfileAdapterClient::downloadInterruptReasonToString( + static_cast<ProfileAdapterClient::DownloadInterruptReason>(interruptReason())); +} + +/*! + \since 5.12 + Returns the page the download was requested on. If the download was not triggered by content in a page, + \c nullptr is returned. +*/ +QWebEnginePage *QWebEngineDownloadItem::page() const +{ + Q_D(const QWebEngineDownloadItem); + return d->page; } QWebEngineDownloadItem::QWebEngineDownloadItem(QWebEngineDownloadItemPrivate *p, QObject *parent) diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h index 073b97170..981a3c374 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem.h @@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE +class QWebEnginePage; class QWebEngineDownloadItemPrivate; class QWebEngineProfilePrivate; @@ -128,6 +129,8 @@ public: QString interruptReasonString() const; bool isSavePageDownload() const; + QWebEnginePage *page() const; + public Q_SLOTS: void accept(); void cancel(); diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h index da765e5c5..bdcda5be6 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h @@ -81,8 +81,9 @@ public: qint64 totalBytes; qint64 receivedBytes; + QWebEnginePage *page; - void update(const QtWebEngineCore::BrowserContextAdapterClient::DownloadItemInfo &info); + void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info); }; QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 745ce03fc..187565a76 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -41,12 +41,16 @@ #include "qwebenginepage_p.h" #include "authentication_dialog_controller.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "certificate_error_controller.h" #include "color_chooser_controller.h" #include "favicon_manager.h" #include "file_picker_controller.h" #include "javascript_dialog_controller.h" +#if QT_CONFIG(webengine_printing_and_pdf) +#include "printing/pdfium_document_wrapper_qt.h" +#endif +#include "qwebenginecertificateerror.h" #include "qwebenginefullscreenrequest.h" #include "qwebenginehistory.h" #include "qwebenginehistory_p.h" @@ -67,18 +71,28 @@ #include <QApplication> #include <QAuthenticator> #include <QClipboard> +#if QT_CONFIG(colordialog) #include <QColorDialog> +#endif #include <QContextMenuEvent> +#if QT_CONFIG(filedialog) #include <QFileDialog> +#endif #include <QKeyEvent> #include <QIcon> +#if QT_CONFIG(inputdialog) #include <QInputDialog> +#endif #include <QLayout> #include <QLoggingCategory> +#if QT_CONFIG(menu) #include <QMenu> +#endif +#if QT_CONFIG(messagebox) #include <QMessageBox> +#endif #include <QMimeData> -#ifdef ENABLE_PRINTING +#if QT_CONFIG(webengine_printing_and_pdf) #include <QPrinter> #endif #include <QStandardPaths> @@ -86,17 +100,13 @@ #include <QTimer> #include <QUrl> -#if defined(ENABLE_PRINTING) && defined(ENABLE_PDF) -#include "printing/pdfium_document_wrapper_qt.h" -#endif - QT_BEGIN_NAMESPACE using namespace QtWebEngineCore; static const int MaxTooltipLength = 1024; -#if defined(ENABLE_PRINTING) && defined(ENABLE_PDF) +#if QT_CONFIG(webengine_printing_and_pdf) static bool printPdfDataOnPrinter(const QByteArray& data, QPrinter& printer) { if (!data.size()) { @@ -177,7 +187,7 @@ static bool printPdfDataOnPrinter(const QByteArray& data, QPrinter& printer) return true; } -#endif // defined(ENABLE_PRINTING) && defined(ENABLE_PDF) +#endif // QT_CONFIG(webengine_printing_and_pdf) static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::WindowOpenDisposition disposition) { @@ -223,7 +233,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , settings(new QWebEngineSettings(profile->settings())) , view(0) , isLoading(false) - , scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userResourceController(), adapter)) + , scriptCollection(new QWebEngineScriptCollectionPrivate(profileAdapter()->userResourceController(), adapter)) , m_isBeingAdopted(false) , m_backgroundColor(Qt::white) , fullscreenMode(false) @@ -231,7 +241,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , webChannelWorldId(QWebEngineScript::MainWorld) , defaultAudioMuted(false) , defaultZoomFactor(1.0) -#if defined(ENABLE_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) , currentPrinter(nullptr) #endif { @@ -271,9 +281,11 @@ RenderWidgetHostViewQtDelegate *QWebEnginePagePrivate::CreateRenderWidgetHostVie void QWebEnginePagePrivate::initializationFinished() { if (m_backgroundColor != Qt::white) - adapter->backgroundColorChanged(); + adapter->setBackgroundColor(m_backgroundColor); +#if QT_CONFIG(webengine_webchannel) if (webChannel) adapter->setWebChannel(webChannel, webChannelWorldId); +#endif if (defaultAudioMuted != adapter->isAudioMuted()) adapter->setAudioMuted(defaultAudioMuted); if (!qFuzzyCompare(adapter->currentZoomFactor(), defaultZoomFactor)) @@ -310,7 +322,7 @@ void QWebEnginePagePrivate::iconChanged(const QUrl &url) void QWebEnginePagePrivate::loadProgressChanged(int progress) { Q_Q(QWebEnginePage); - Q_EMIT q->loadProgress(progress); + QTimer::singleShot(0, q, [q, progress] () { Q_EMIT q->loadProgress(progress); }); } void QWebEnginePagePrivate::didUpdateTargetURL(const QUrl &hoveredUrl) @@ -498,8 +510,7 @@ void QWebEnginePagePrivate::didFindText(quint64 requestId, int matchCount) void QWebEnginePagePrivate::didPrintPage(quint64 requestId, const QByteArray &result) { -#if defined(ENABLE_PDF) -#if defined(ENABLE_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) // If no currentPrinter is set that means that were printing to PDF only. if (!currentPrinter) { m_callbacks.invoke(requestId, result); @@ -508,16 +519,13 @@ void QWebEnginePagePrivate::didPrintPage(quint64 requestId, const QByteArray &re bool printerResult = printPdfDataOnPrinter(result, *currentPrinter); - m_callbacks.invoke(requestId, printerResult); currentPrinter = nullptr; -#else // If print support is disabled, only PDF printing is available. - m_callbacks.invoke(requestId, result); -#endif // defined(ENABLE_PRINTING) -#else // defined(ENABLE_PDF) + m_callbacks.invoke(requestId, printerResult); +#else // we should never enter this branch, but just for safe-keeping... Q_UNUSED(result); m_callbacks.invoke(requestId, QByteArray()); -#endif // defined(ENABLE_PDF) +#endif } void QWebEnginePagePrivate::passOnFocus(bool reverse) @@ -548,6 +556,7 @@ void QWebEnginePagePrivate::authenticationRequired(QSharedPointer<Authentication void QWebEnginePagePrivate::showColorDialog(QSharedPointer<ColorChooserController> controller) { +#if QT_CONFIG(colordialog) QColorDialog *dialog = new QColorDialog(controller.data()->initialColor(), view); QColorDialog::connect(dialog, SIGNAL(colorSelected(QColor)), controller.data(), SLOT(accept(QColor))); @@ -558,6 +567,9 @@ void QWebEnginePagePrivate::showColorDialog(QSharedPointer<ColorChooserControlle QColorDialog::connect(dialog, SIGNAL(rejected()), dialog, SLOT(deleteLater())); dialog->open(); +#else + Q_UNUSED(controller); +#endif } void QWebEnginePagePrivate::runMediaAccessPermissionRequest(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags requestFlags) @@ -696,9 +708,9 @@ void QWebEnginePagePrivate::setFullScreenMode(bool fullscreen) } } -QSharedPointer<BrowserContextAdapter> QWebEnginePagePrivate::browserContextAdapter() +ProfileAdapter* QWebEnginePagePrivate::profileAdapter() { - return profile->d_ptr->browserContext(); + return profile->d_ptr->profileAdapter(); } WebContentsAdapter *QWebEnginePagePrivate::webContentsAdapter() @@ -729,6 +741,16 @@ QWebEnginePage::QWebEnginePage(QObject* parent) } /*! + \fn void QWebEnginePage::printRequested() + \since 5.12 + + This signal is emitted when the JavaScript \c{window.print()} method is called. + Typically, the signal handler can simply call printToPdf(). + + \sa printToPdf() +*/ + +/*! \enum QWebEnginePage::RenderProcessTerminationStatus \since 5.6 @@ -880,7 +902,7 @@ QWebEnginePage::~QWebEnginePage() Q_D(QWebEnginePage); setDevToolsPage(nullptr); d->adapter->stopFinding(); - QWebEngineViewPrivate::bind(d->view, 0); + QWebEngineViewPrivate::bind(nullptr, this, true); } QWebEngineHistory *QWebEnginePage::history() const @@ -905,8 +927,12 @@ QWebEngineSettings *QWebEnginePage::settings() const */ QWebChannel *QWebEnginePage::webChannel() const { +#if QT_CONFIG(webengine_webchannel) Q_D(const QWebEnginePage); return d->webChannel; +#endif + qWarning("WebEngine compiled without webchannel support"); + return nullptr; } /*! @@ -943,12 +969,18 @@ void QWebEnginePage::setWebChannel(QWebChannel *channel) */ void QWebEnginePage::setWebChannel(QWebChannel *channel, uint worldId) { +#if QT_CONFIG(webengine_webchannel) Q_D(QWebEnginePage); if (d->webChannel != channel || d->webChannelWorldId != worldId) { d->webChannel = channel; d->webChannelWorldId = worldId; d->adapter->setWebChannel(channel, worldId); } +#else + Q_UNUSED(channel) + Q_UNUSED(worldId) + qWarning("WebEngine compiled without webchannel support"); +#endif } /*! @@ -975,7 +1007,7 @@ void QWebEnginePage::setBackgroundColor(const QColor &color) if (d->m_backgroundColor == color) return; d->m_backgroundColor = color; - d->adapter->backgroundColorChanged(); + d->adapter->setBackgroundColor(color); } /*! @@ -1543,6 +1575,7 @@ void QWebEnginePagePrivate::wasHidden() void QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData &data) { +#if QT_CONFIG(action) if (!view) return; @@ -1571,6 +1604,9 @@ void QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData } Q_UNREACHABLE(); +#else + Q_UNUSED(data); +#endif // QT_CONFIG(action) } void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) @@ -1616,7 +1652,9 @@ void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogCont accepted = q->javaScriptConfirm(controller->securityOrigin(), QCoreApplication::translate("QWebEnginePage", "Are you sure you want to leave this page? Changes that you made may not be saved.")); break; case InternalAuthorizationDialog: +#if QT_CONFIG(messagebox) accepted = (QMessageBox::question(view, controller->title(), controller->message(), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes); +#endif // QT_CONFIG(messagebox) break; } if (accepted) @@ -1637,6 +1675,36 @@ void QWebEnginePagePrivate::allowCertificateError(const QSharedPointer<Certifica controller->accept(accepted); } +void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller) +{ +#if QT_CONFIG(ssl) + Q_Q(QWebEnginePage); + QWebEngineClientCertificateSelection certSelection(controller); + + Q_EMIT q->selectClientCertificate(certSelection); +#else + Q_UNUSED(controller); +#endif +} + +#if QT_CONFIG(ssl) +/*! + \fn void QWebEnginePage::selectClientCertificate(QWebEngineClientCertificateSelection clientCertificateSelection) + \since 5.12 + + This signal is emitted when a web site requests an SSL client certificate, and one or more were + found in system's client certificate store. + + Handling the signal is asynchronous, and loading will be waiting until a certificate is selected, + or the last copy of \a clientCertificateSelection is destroyed. + + If the signal is not handled, \a clientCertificateSelection is automatically destroyed, and loading + will continue without a client certificate. + + \sa QWebEngineClientCertificateSelection +*/ +#endif + void QWebEnginePagePrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) { Q_Q(QWebEnginePage); @@ -1705,6 +1773,15 @@ void QWebEnginePagePrivate::setToolTip(const QString &toolTipText) view->setToolTip(wrappedTip); } +void QWebEnginePagePrivate::printRequested() +{ + Q_Q(QWebEnginePage); + QTimer::singleShot(0, q, [q](){ + Q_EMIT q->printRequested(); + }); +} + +#if QT_CONFIG(menu) QMenu *QWebEnginePage::createStandardContextMenu() { Q_D(QWebEnginePage); @@ -1723,6 +1800,7 @@ QMenu *QWebEnginePage::createStandardContextMenu() return menu; } +#endif // QT_CONFIG(menu) void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEnginePage::Feature feature, QWebEnginePage::PermissionPolicy policy) { @@ -2098,6 +2176,7 @@ ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, QWebEnginePage::FileSelec QStringList QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) { +#if QT_CONFIG(filedialog) // FIXME: Should we expose this in QWebPage's API ? Right now it is very open and can contain a mix and match of file extensions (which QFileDialog // can work with) and mimetypes ranging from text/plain or images/* to application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Q_UNUSED(acceptedMimeTypes); @@ -2125,27 +2204,50 @@ QStringList QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringLis break; } return ret; +#else + Q_UNUSED(mode); + Q_UNUSED(oldFiles); + Q_UNUSED(acceptedMimeTypes); + + return QStringList(); +#endif // QT_CONFIG(filedialog) } void QWebEnginePage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg) { Q_UNUSED(securityOrigin); +#if QT_CONFIG(messagebox) QMessageBox::information(view(), QStringLiteral("Javascript Alert - %1").arg(url().toString()), msg); +#else + Q_UNUSED(msg); +#endif // QT_CONFIG(messagebox) } bool QWebEnginePage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg) { Q_UNUSED(securityOrigin); +#if QT_CONFIG(messagebox) return (QMessageBox::information(view(), QStringLiteral("Javascript Confirm - %1").arg(url().toString()), msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok); +#else + Q_UNUSED(msg); + return false; +#endif // QT_CONFIG(messagebox) } bool QWebEnginePage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString *result) { Q_UNUSED(securityOrigin); +#if QT_CONFIG(inputdialog) bool ret = false; if (result) *result = QInputDialog::getText(view(), QStringLiteral("Javascript Prompt - %1").arg(url().toString()), msg, QLineEdit::Normal, defaultValue, &ret); return ret; +#else + Q_UNUSED(msg); + Q_UNUSED(defaultValue); + Q_UNUSED(result); + return false; +#endif // QT_CONFIG(inputdialog) } void QWebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) @@ -2212,20 +2314,18 @@ QSizeF QWebEnginePage::contentsSize() const */ void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &pageLayout) { -#if defined(ENABLE_PDF) +#if QT_CONFIG(webengine_printing_and_pdf) Q_D(const QWebEnginePage); -#if defined(ENABLE_PRINTING) if (d->currentPrinter) { qWarning("Cannot print to PDF while at the same time printing on printer %ls", qUtf16Printable(d->currentPrinter->printerName())); return; } -#endif // ENABLE_PRINTING d->ensureInitialized(); d->adapter->printToPDF(pageLayout, filePath); #else Q_UNUSED(filePath); Q_UNUSED(pageLayout); -#endif // if defined(ENABLE_PDF) +#endif } @@ -2242,21 +2342,19 @@ void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &page void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &resultCallback, const QPageLayout &pageLayout) { Q_D(QWebEnginePage); -#if defined(ENABLE_PDF) -#if defined(ENABLE_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) if (d->currentPrinter) { qWarning("Cannot print to PDF while at the same time printing on printer %ls", qUtf16Printable(d->currentPrinter->printerName())); d->m_callbacks.invokeEmpty(resultCallback); return; } -#endif // ENABLE_PRINTING d->ensureInitialized(); quint64 requestId = d->adapter->printToPDFCallbackResult(pageLayout); d->m_callbacks.registerCallback(requestId, resultCallback); -#else // if defined(ENABLE_PDF) +#else Q_UNUSED(pageLayout); d->m_callbacks.invokeEmpty(resultCallback); -#endif // if defined(ENABLE_PDF) +#endif } /*! @@ -2279,24 +2377,22 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback) { Q_D(QWebEnginePage); -#if defined(ENABLE_PDF) -#if defined(ENABLE_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) if (d->currentPrinter) { qWarning("Cannot print page on printer %ls: Already printing on %ls.", qUtf16Printable(printer->printerName()), qUtf16Printable(d->currentPrinter->printerName())); d->m_callbacks.invokeDirectly(resultCallback, false); return; } d->currentPrinter = printer; -#endif // ENABLE_PRINTING d->ensureInitialized(); quint64 requestId = d->adapter->printToPDFCallbackResult(printer->pageLayout(), printer->colorMode() == QPrinter::Color, false); d->m_callbacks.registerCallback(requestId, resultCallback); -#else // if defined(ENABLE_PDF) +#else Q_UNUSED(printer); d->m_callbacks.invokeDirectly(resultCallback, false); -#endif // if defined(ENABLE_PDF) +#endif } /*! @@ -2313,6 +2409,7 @@ const QWebEngineContextMenuData &QWebEnginePage::contextMenuData() const return d->contextData; } +#if QT_CONFIG(action) QContextMenuBuilder::QContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data, QWebEnginePage *page, QMenu *menu) @@ -2480,6 +2577,7 @@ bool QContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem) } Q_UNREACHABLE(); } +#endif // QT_CONFIG(action) QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 3edfb96d0..6dd2da21c 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -41,7 +41,7 @@ #define QWEBENGINEPAGE_H #include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> -#include <QtWebEngineWidgets/qwebenginecertificateerror.h> +#include <QtWebEngineWidgets/qwebengineclientcertificateselection.h> #include <QtWebEngineWidgets/qwebenginedownloaditem.h> #include <QtWebEngineCore/qwebenginecallback.h> #include <QtWebEngineCore/qwebenginehttprequest.h> @@ -59,6 +59,8 @@ class QPrinter; class QContextMenuBuilder; class QWebChannel; +class QWebEngineCertificateError; +class QWebEngineClientCertificateSelection; class QWebEngineContextMenuData; class QWebEngineFullScreenRequest; class QWebEngineHistory; @@ -246,7 +248,9 @@ public: void findText(const QString &subString, FindFlags options = FindFlags(), const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>()); +#if QT_CONFIG(menu) QMenu *createStandardContextMenu(); +#endif void setFeaturePermission(const QUrl &securityOrigin, Feature feature, PermissionPolicy policy); @@ -318,6 +322,9 @@ Q_SIGNALS: void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest); void quotaRequested(QWebEngineQuotaRequest quotaRequest); void registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request); +#if QT_CONFIG(ssl) + void selectClientCertificate(QWebEngineClientCertificateSelection clientCertSelection); +#endif void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator); void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost); @@ -336,6 +343,7 @@ Q_SIGNALS: void recentlyAudibleChanged(bool recentlyAudible); void pdfPrintingFinished(const QString &filePath, bool success); + void printRequested(); protected: virtual QWebEnginePage *createWindow(WebWindowType type); diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index fde877255..66a92dec9 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -136,6 +136,7 @@ public: QObject *accessibilityParentObject() override; QtWebEngineCore::WebEngineSettings *webEngineSettings() const override; void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) override; + void selectClientCert(const QSharedPointer<ClientCertSelectController> &controller) override; void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override; void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override; void updateScrollPosition(const QPointF &position) override; @@ -145,9 +146,11 @@ public: bool supportsDragging() const override; bool isEnabled() const override; void setToolTip(const QString &toolTipText) override; + void printRequested() override; const QObject *holdingQObject() const override; + ClientType clientType() override { return QtWebEngineCore::WebContentsAdapterClient::WidgetsClient; } - QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() override; + QtWebEngineCore::ProfileAdapter *profileAdapter() override; QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void updateAction(QWebEnginePage::WebAction) const; @@ -187,7 +190,7 @@ public: mutable QtWebEngineCore::CallbackDirectory m_callbacks; mutable QAction *actions[QWebEnginePage::WebActionCount]; -#if defined(ENABLE_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) QPrinter *currentPrinter; #endif }; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 1885f2085..537cf41fd 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -38,29 +38,29 @@ ****************************************************************************/ #include "qwebengineprofile.h" +#include "qwebengineprofile_p.h" #include "qwebenginecookiestore.h" #include "qwebenginedownloaditem.h" #include "qwebenginedownloaditem_p.h" #include "qwebenginepage.h" -#include "qwebengineprofile_p.h" +#include "qwebenginepage_p.h" #include "qwebenginesettings.h" #include "qwebenginescriptcollection_p.h" - -#include "qwebenginebrowsercontext_p.h" #include "qtwebenginecoreglobal.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "visited_links_manager_qt.h" #include "web_engine_settings.h" + QT_BEGIN_NAMESPACE -ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::UnknownSavePageFormat) -ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::SingleHtmlSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::SingleHtmlSaveFormat) -ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::CompleteHtmlSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::CompleteHtmlSaveFormat) -ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::MimeHtmlSaveFormat) +ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::ProfileAdapterClient::UnknownSavePageFormat) +ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::SingleHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::SingleHtmlSaveFormat) +ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::CompleteHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::CompleteHtmlSaveFormat) +ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::MimeHtmlSaveFormat) -using QtWebEngineCore::BrowserContextAdapter; +using QtWebEngineCore::ProfileAdapter; /*! \class QWebEngineProfile @@ -155,32 +155,41 @@ using QtWebEngineCore::BrowserContextAdapter; \sa QWebEngineDownloadItem, QWebEnginePage::download() */ -QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext) - : m_settings(new QWebEngineSettings()) - , m_scriptCollection(new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userResourceController()))) - , m_browserContext(new QWebEngineBrowserContext(browserContext, this)) +QWebEngineProfilePrivate::QWebEngineProfilePrivate(ProfileAdapter* profileAdapter) + : m_settings(new QWebEngineSettings()) + , m_profileAdapter(profileAdapter) + , m_scriptCollection(new QWebEngineScriptCollection( + new QWebEngineScriptCollectionPrivate(profileAdapter->userResourceController()))) { + m_profileAdapter->addClient(this); m_settings->d_ptr->initDefaults(); } QWebEngineProfilePrivate::~QWebEngineProfilePrivate() { - delete m_settings; - m_settings = 0; + 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. + m_profileAdapter->setRequestInterceptor(nullptr); + m_profileAdapter->removeClient(this); + } - Q_FOREACH (QWebEngineDownloadItem* download, m_ongoingDownloads) { + for (QWebEngineDownloadItem *download : qAsConst(m_ongoingDownloads)) { if (download) download->cancel(); } m_ongoingDownloads.clear(); - if (m_browserContext) - m_browserContext->shutdown(); + + if (m_profileAdapter != QtWebEngineCore::ProfileAdapter::defaultProfileAdapter()) + delete m_profileAdapter; + + delete m_settings; } -QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QWebEngineProfilePrivate::browserContext() const +ProfileAdapter* QWebEngineProfilePrivate::profileAdapter() const { - return m_browserContext ? m_browserContext->browserContextRef : nullptr; + return m_profileAdapter; } void QWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) @@ -201,6 +210,10 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->mimeType = info.mimeType; itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(info.savePageFormat); itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType); + if (info.page && info.page->clientType() == QtWebEngineCore::WebContentsAdapterClient::WidgetsClient) + itemPrivate->page = static_cast<QWebEnginePagePrivate *>(info.page)->q_ptr; + else + itemPrivate->page = nullptr; QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q); @@ -211,7 +224,7 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) QWebEngineDownloadItem::DownloadState state = download->state(); info.path = download->path(); - info.savePageFormat = static_cast<QtWebEngineCore::BrowserContextAdapterClient::SavePageFormat>( + info.savePageFormat = static_cast<QtWebEngineCore::ProfileAdapterClient::SavePageFormat>( download->savePageFormat()); info.accepted = state != QWebEngineDownloadItem::DownloadCancelled; @@ -252,7 +265,7 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info) */ QWebEngineProfile::QWebEngineProfile(QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter>::create(true))) + , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::ProfileAdapter())) { d_ptr->q_ptr = this; } @@ -269,7 +282,7 @@ QWebEngineProfile::QWebEngineProfile(QObject *parent) */ QWebEngineProfile::QWebEngineProfile(const QString &storageName, QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter>::create(storageName))) + , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::ProfileAdapter(storageName))) { d_ptr->q_ptr = this; } @@ -297,7 +310,7 @@ QWebEngineProfile::~QWebEngineProfile() QString QWebEngineProfile::storageName() const { const Q_D(QWebEngineProfile); - return d->browserContext()->storageName(); + return d->profileAdapter()->storageName(); } /*! @@ -309,7 +322,7 @@ QString QWebEngineProfile::storageName() const bool QWebEngineProfile::isOffTheRecord() const { const Q_D(QWebEngineProfile); - return d->browserContext()->isOffTheRecord(); + return d->profileAdapter()->isOffTheRecord(); } /*! @@ -328,7 +341,7 @@ bool QWebEngineProfile::isOffTheRecord() const QString QWebEngineProfile::persistentStoragePath() const { const Q_D(QWebEngineProfile); - return d->browserContext()->dataPath(); + return d->profileAdapter()->dataPath(); } /*! @@ -341,7 +354,7 @@ QString QWebEngineProfile::persistentStoragePath() const void QWebEngineProfile::setPersistentStoragePath(const QString &path) { const Q_D(QWebEngineProfile); - d->browserContext()->setDataPath(path); + d->profileAdapter()->setDataPath(path); } /*! @@ -358,7 +371,7 @@ void QWebEngineProfile::setPersistentStoragePath(const QString &path) QString QWebEngineProfile::cachePath() const { const Q_D(QWebEngineProfile); - return d->browserContext()->cachePath(); + return d->profileAdapter()->cachePath(); } /*! @@ -371,7 +384,7 @@ QString QWebEngineProfile::cachePath() const void QWebEngineProfile::setCachePath(const QString &path) { Q_D(QWebEngineProfile); - d->browserContext()->setCachePath(path); + d->profileAdapter()->setCachePath(path); } /*! @@ -386,7 +399,7 @@ void QWebEngineProfile::setCachePath(const QString &path) QString QWebEngineProfile::httpUserAgent() const { const Q_D(QWebEngineProfile); - return d->browserContext()->httpUserAgent(); + return d->profileAdapter()->httpUserAgent(); } /*! @@ -397,7 +410,7 @@ QString QWebEngineProfile::httpUserAgent() const void QWebEngineProfile::setHttpUserAgent(const QString &userAgent) { Q_D(QWebEngineProfile); - d->browserContext()->setHttpUserAgent(userAgent); + d->profileAdapter()->setHttpUserAgent(userAgent); } /*! @@ -410,7 +423,7 @@ void QWebEngineProfile::setHttpUserAgent(const QString &userAgent) QWebEngineProfile::HttpCacheType QWebEngineProfile::httpCacheType() const { const Q_D(QWebEngineProfile); - return QWebEngineProfile::HttpCacheType(d->browserContext()->httpCacheType()); + return QWebEngineProfile::HttpCacheType(d->profileAdapter()->httpCacheType()); } /*! @@ -421,7 +434,7 @@ QWebEngineProfile::HttpCacheType QWebEngineProfile::httpCacheType() const void QWebEngineProfile::setHttpCacheType(QWebEngineProfile::HttpCacheType httpCacheType) { Q_D(QWebEngineProfile); - d->browserContext()->setHttpCacheType(BrowserContextAdapter::HttpCacheType(httpCacheType)); + d->profileAdapter()->setHttpCacheType(ProfileAdapter::HttpCacheType(httpCacheType)); } /*! @@ -432,7 +445,7 @@ void QWebEngineProfile::setHttpCacheType(QWebEngineProfile::HttpCacheType httpCa void QWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage) { Q_D(QWebEngineProfile); - d->browserContext()->setHttpAcceptLanguage(httpAcceptLanguage); + d->profileAdapter()->setHttpAcceptLanguage(httpAcceptLanguage); } /*! @@ -443,7 +456,7 @@ void QWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage) QString QWebEngineProfile::httpAcceptLanguage() const { Q_D(const QWebEngineProfile); - return d->browserContext()->httpAcceptLanguage(); + return d->profileAdapter()->httpAcceptLanguage(); } /*! @@ -456,7 +469,7 @@ QString QWebEngineProfile::httpAcceptLanguage() const QWebEngineProfile::PersistentCookiesPolicy QWebEngineProfile::persistentCookiesPolicy() const { const Q_D(QWebEngineProfile); - return QWebEngineProfile::PersistentCookiesPolicy(d->browserContext()->persistentCookiesPolicy()); + return QWebEngineProfile::PersistentCookiesPolicy(d->profileAdapter()->persistentCookiesPolicy()); } /*! @@ -467,7 +480,7 @@ QWebEngineProfile::PersistentCookiesPolicy QWebEngineProfile::persistentCookiesP void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy newPersistentCookiesPolicy) { Q_D(QWebEngineProfile); - d->browserContext()->setPersistentCookiesPolicy(BrowserContextAdapter::PersistentCookiesPolicy(newPersistentCookiesPolicy)); + d->profileAdapter()->setPersistentCookiesPolicy(ProfileAdapter::PersistentCookiesPolicy(newPersistentCookiesPolicy)); } /*! @@ -480,7 +493,7 @@ void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::Persistent int QWebEngineProfile::httpCacheMaximumSize() const { const Q_D(QWebEngineProfile); - return d->browserContext()->httpCacheMaxSize(); + return d->profileAdapter()->httpCacheMaxSize(); } /*! @@ -493,7 +506,7 @@ int QWebEngineProfile::httpCacheMaximumSize() const void QWebEngineProfile::setHttpCacheMaximumSize(int maxSize) { Q_D(QWebEngineProfile); - d->browserContext()->setHttpCacheMaxSize(maxSize); + d->profileAdapter()->setHttpCacheMaxSize(maxSize); } /*! @@ -505,7 +518,7 @@ void QWebEngineProfile::setHttpCacheMaximumSize(int maxSize) QWebEngineCookieStore* QWebEngineProfile::cookieStore() { Q_D(QWebEngineProfile); - return d->browserContext()->cookieStore(); + return d->profileAdapter()->cookieStore(); } @@ -521,7 +534,7 @@ QWebEngineCookieStore* QWebEngineProfile::cookieStore() void QWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { Q_D(QWebEngineProfile); - d->browserContext()->setRequestInterceptor(interceptor); + d->profileAdapter()->setRequestInterceptor(interceptor); } /*! @@ -532,7 +545,7 @@ void QWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *i void QWebEngineProfile::clearAllVisitedLinks() { Q_D(QWebEngineProfile); - d->browserContext()->visitedLinksManager()->deleteAllVisitedLinkData(); + d->profileAdapter()->visitedLinksManager()->deleteAllVisitedLinkData(); } /*! @@ -543,7 +556,7 @@ void QWebEngineProfile::clearAllVisitedLinks() void QWebEngineProfile::clearVisitedLinks(const QList<QUrl> &urls) { Q_D(QWebEngineProfile); - d->browserContext()->visitedLinksManager()->deleteVisitedLinkDataForUrls(urls); + d->profileAdapter()->visitedLinksManager()->deleteVisitedLinkDataForUrls(urls); } /*! @@ -552,7 +565,7 @@ void QWebEngineProfile::clearVisitedLinks(const QList<QUrl> &urls) bool QWebEngineProfile::visitedLinksContainsUrl(const QUrl &url) const { Q_D(const QWebEngineProfile); - return d->browserContext()->visitedLinksManager()->containsUrl(url); + return d->profileAdapter()->visitedLinksManager()->containsUrl(url); } /*! @@ -577,8 +590,8 @@ QWebEngineScriptCollection *QWebEngineProfile::scripts() const QWebEngineProfile *QWebEngineProfile::defaultProfile() { static QWebEngineProfile* profile = new QWebEngineProfile( - new QWebEngineProfilePrivate(BrowserContextAdapter::defaultContext()), - BrowserContextAdapter::globalQObjectRoot()); + new QWebEngineProfilePrivate(ProfileAdapter::createDefaultProfileAdapter()), + ProfileAdapter::globalQObjectRoot()); return profile; } @@ -600,7 +613,7 @@ QWebEngineProfile *QWebEngineProfile::defaultProfile() void QWebEngineProfile::setSpellCheckLanguages(const QStringList &languages) { Q_D(QWebEngineProfile); - d->browserContext()->setSpellCheckLanguages(languages); + d->profileAdapter()->setSpellCheckLanguages(languages); } /*! @@ -611,7 +624,7 @@ void QWebEngineProfile::setSpellCheckLanguages(const QStringList &languages) QStringList QWebEngineProfile::spellCheckLanguages() const { const Q_D(QWebEngineProfile); - return d->browserContext()->spellCheckLanguages(); + return d->profileAdapter()->spellCheckLanguages(); } /*! @@ -623,7 +636,7 @@ QStringList QWebEngineProfile::spellCheckLanguages() const void QWebEngineProfile::setSpellCheckEnabled(bool enable) { Q_D(QWebEngineProfile); - d->browserContext()->setSpellCheckEnabled(enable); + d->profileAdapter()->setSpellCheckEnabled(enable); } /*! \since 5.8 @@ -634,7 +647,7 @@ void QWebEngineProfile::setSpellCheckEnabled(bool enable) bool QWebEngineProfile::isSpellCheckEnabled() const { const Q_D(QWebEngineProfile); - return d->browserContext()->isSpellCheckEnabled(); + return d->profileAdapter()->isSpellCheckEnabled(); } /*! @@ -654,8 +667,8 @@ QWebEngineSettings *QWebEngineProfile::settings() const const QWebEngineUrlSchemeHandler *QWebEngineProfile::urlSchemeHandler(const QByteArray &scheme) const { const Q_D(QWebEngineProfile); - if (d->browserContext()->customUrlSchemeHandlers().contains(scheme)) - return d->browserContext()->customUrlSchemeHandlers().value(scheme); + if (d->profileAdapter()->customUrlSchemeHandlers().contains(scheme)) + return d->profileAdapter()->customUrlSchemeHandlers().value(scheme); return 0; } @@ -674,22 +687,26 @@ static bool checkInternalScheme(const QByteArray &scheme) \since 5.6 Registers a handler \a handler for custom URL scheme \a scheme in the profile. + + It is recommended to first register the scheme with \l + QWebEngineUrlScheme::registerScheme at application startup. */ void QWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler) { Q_D(QWebEngineProfile); Q_ASSERT(handler); - if (checkInternalScheme(scheme)) { + QByteArray canonicalScheme = scheme.toLower(); + if (checkInternalScheme(canonicalScheme)) { qWarning("Cannot install a URL scheme handler overriding internal scheme: %s", scheme.constData()); return; } - if (d->browserContext()->customUrlSchemeHandlers().contains(scheme)) { - if (d->browserContext()->customUrlSchemeHandlers().value(scheme) != handler) + if (d->profileAdapter()->customUrlSchemeHandlers().contains(canonicalScheme)) { + if (d->profileAdapter()->customUrlSchemeHandlers().value(canonicalScheme) != handler) qWarning("URL scheme handler already installed for the scheme: %s", scheme.constData()); return; } - d->browserContext()->addCustomUrlSchemeHandler(scheme, handler); + d->profileAdapter()->addCustomUrlSchemeHandler(canonicalScheme, handler); connect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); } @@ -704,7 +721,7 @@ void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handl { Q_D(QWebEngineProfile); Q_ASSERT(handler); - if (!d->browserContext()->removeCustomUrlSchemeHandler(handler)) + if (!d->profileAdapter()->removeCustomUrlSchemeHandler(handler)) return; disconnect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); } @@ -719,7 +736,7 @@ void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handl void QWebEngineProfile::removeUrlScheme(const QByteArray &scheme) { Q_D(QWebEngineProfile); - QWebEngineUrlSchemeHandler *handler = d->browserContext()->takeCustomUrlSchemeHandler(scheme); + QWebEngineUrlSchemeHandler *handler = d->profileAdapter()->takeCustomUrlSchemeHandler(scheme); if (!handler) return; disconnect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); @@ -733,7 +750,7 @@ void QWebEngineProfile::removeUrlScheme(const QByteArray &scheme) void QWebEngineProfile::removeAllUrlSchemeHandlers() { Q_D(QWebEngineProfile); - d->browserContext()->clearCustomUrlSchemeHandlers(); + d->profileAdapter()->clearCustomUrlSchemeHandlers(); } void QWebEngineProfile::destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler *obj) @@ -749,7 +766,7 @@ void QWebEngineProfile::destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler *ob void QWebEngineProfile::clearHttpCache() { Q_D(QWebEngineProfile); - d->browserContext()->clearHttpCache(); + d->profileAdapter()->clearHttpCache(); } QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index 72fa904e4..9ff8df849 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "browser_context_adapter_client.h" +#include "profile_adapter_client.h" #include "qwebengineprofile.h" #include "qwebenginescriptcollection.h" @@ -61,7 +61,7 @@ #include <QSharedPointer> namespace QtWebEngineCore { -class BrowserContextAdapter; +class ProfileAdapter; } QT_BEGIN_NAMESPACE @@ -70,13 +70,13 @@ class QWebEngineBrowserContext; class QWebEngineProfilePrivate; class QWebEngineSettings; -class QWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { +class QWebEngineProfilePrivate : public QtWebEngineCore::ProfileAdapterClient { public: Q_DECLARE_PUBLIC(QWebEngineProfile) - QWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext); + QWebEngineProfilePrivate(QtWebEngineCore::ProfileAdapter *profileAdapter); ~QWebEngineProfilePrivate(); - QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext() const; + QtWebEngineCore::ProfileAdapter* profileAdapter() const; QWebEngineSettings *settings() const { return m_settings; } void downloadDestroyed(quint32 downloadId); @@ -87,8 +87,8 @@ public: private: QWebEngineProfile *q_ptr; QWebEngineSettings *m_settings; + QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter; QScopedPointer<QWebEngineScriptCollection> m_scriptCollection; - QPointer<QWebEngineBrowserContext> m_browserContext; QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads; }; diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp index bcf0c127c..5ef0ffd44 100644 --- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp +++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp @@ -135,7 +135,7 @@ void QWebEngineScriptCollection::insert(const QWebEngineScript &s) void QWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list) { d->reserve(list.size()); - Q_FOREACH (const QWebEngineScript &s, list) + for (const QWebEngineScript &s : list) d->insert(s); } @@ -207,7 +207,7 @@ QList<QWebEngineScript> QWebEngineScriptCollectionPrivate::toList(const QString return m_scripts; QList<QWebEngineScript> ret; - Q_FOREACH (const QWebEngineScript &script, m_scripts) + for (const QWebEngineScript &script : qAsConst(m_scripts)) if (scriptName == script.name()) ret.append(script); return ret; @@ -215,7 +215,7 @@ QList<QWebEngineScript> QWebEngineScriptCollectionPrivate::toList(const QString QWebEngineScript QWebEngineScriptCollectionPrivate::find(const QString &name) const { - Q_FOREACH (const QWebEngineScript &script, m_scripts) + for (const QWebEngineScript &script : qAsConst(m_scripts)) if (name == script.name()) return script; return QWebEngineScript(); @@ -240,7 +240,7 @@ void QWebEngineScriptCollectionPrivate::initializationFinished(QSharedPointer<Qt Q_ASSERT(m_contents); Q_ASSERT(contents); - Q_FOREACH (const QWebEngineScript &script, m_scripts) + for (const QWebEngineScript &script : qAsConst(m_scripts)) m_scriptController->addUserScript(*script.d, contents.data()); m_contents = contents; } diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp index 32f9b75cd..d91eb3f97 100644 --- a/src/webenginewidgets/api/qwebenginesettings.cpp +++ b/src/webenginewidgets/api/qwebenginesettings.cpp @@ -107,6 +107,8 @@ static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::Web return WebEngineSettings::WebRTCPublicInterfacesOnly; case QWebEngineSettings::JavascriptCanPaste: return WebEngineSettings::JavascriptCanPaste; + case QWebEngineSettings::DnsPrefetchEnabled: + return WebEngineSettings::DnsPrefetchEnabled; default: return WebEngineSettings::UnsupportedInCoreSettings; diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h index 1815396b6..9100e32d5 100644 --- a/src/webenginewidgets/api/qwebenginesettings.h +++ b/src/webenginewidgets/api/qwebenginesettings.h @@ -95,6 +95,7 @@ public: PlaybackRequiresUserGesture, WebRTCPublicInterfacesOnly, JavascriptCanPaste, + DnsPrefetchEnabled, }; enum FontSize { diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp index f515f0c9f..aa51e5b0e 100644 --- a/src/webenginewidgets/api/qwebengineview.cpp +++ b/src/webenginewidgets/api/qwebengineview.cpp @@ -43,15 +43,19 @@ #include "qwebenginepage_p.h" #include "web_contents_adapter.h" +#if QT_CONFIG(action) #include <QAction> +#endif +#if QT_CONFIG(menu) #include <QMenu> +#endif #include <QContextMenuEvent> #include <QToolTip> #include <QVBoxLayout> QT_BEGIN_NAMESPACE -void QWebEngineViewPrivate::bind(QWebEngineView *view, QWebEnginePage *page) +void QWebEngineViewPrivate::bind(QWebEngineView *view, QWebEnginePage *page, bool pageBeingDeleted) { if (view && page == view->d_func()->page) return; @@ -60,20 +64,22 @@ void QWebEngineViewPrivate::bind(QWebEngineView *view, QWebEnginePage *page) // Un-bind page from its current view. if (QWebEngineView *oldView = page->d_func()->view) { page->disconnect(oldView); - oldView->d_func()->page = 0; + oldView->d_func()->page = nullptr; } page->d_func()->view = view; - page->d_func()->adapter->reattachRWHV(); + if (!pageBeingDeleted) + page->d_func()->adapter->reattachRWHV(); } if (view) { // Un-bind view from its current page. if (QWebEnginePage *oldPage = view->d_func()->page) { oldPage->disconnect(view); - oldPage->d_func()->view = 0; - oldPage->d_func()->adapter->reattachRWHV(); + oldPage->d_func()->view = nullptr; if (oldPage->parent() == view) delete oldPage; + else + oldPage->d_func()->adapter->reattachRWHV(); } view->d_func()->page = page; } @@ -143,8 +149,7 @@ QWebEngineView::QWebEngineView(QWidget *parent) QWebEngineView::~QWebEngineView() { - Q_D(QWebEngineView); - QWebEngineViewPrivate::bind(0, d->page); + QWebEngineViewPrivate::bind(this, nullptr); } QWebEnginePage* QWebEngineView::page() const @@ -339,11 +344,13 @@ bool QWebEngineView::event(QEvent *ev) /*! * \reimp */ +#if QT_CONFIG(contextmenu) void QWebEngineView::contextMenuEvent(QContextMenuEvent *event) { QMenu *menu = page()->createStandardContextMenu(); menu->popup(event->globalPos()); } +#endif // QT_CONFIG(contextmenu) /*! * \reimp diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h index 77d26b8ec..e3cb7ad75 100644 --- a/src/webenginewidgets/api/qwebengineview.h +++ b/src/webenginewidgets/api/qwebengineview.h @@ -120,7 +120,9 @@ Q_SIGNALS: protected: virtual QWebEngineView *createWindow(QWebEnginePage::WebWindowType type); +#if QT_CONFIG(contextmenu) void contextMenuEvent(QContextMenuEvent*) override; +#endif // QT_CONFIG(contextmenu) bool event(QEvent*) override; void showEvent(QShowEvent *) override; void hideEvent(QHideEvent *) override; diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h index 7f0cdac45..bfb44bec5 100644 --- a/src/webenginewidgets/api/qwebengineview_p.h +++ b/src/webenginewidgets/api/qwebengineview_p.h @@ -65,7 +65,7 @@ public: Q_DECLARE_PUBLIC(QWebEngineView) QWebEngineView *q_ptr; - static void bind(QWebEngineView *view, QWebEnginePage *page); + static void bind(QWebEngineView *view, QWebEnginePage *page, bool pageBeingDeleted = false); QWebEngineViewPrivate(); |