summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp75
-rw-r--r--src/webenginewidgets/api/qwebenginecertificateerror.cpp266
-rw-r--r--src/webenginewidgets/api/qwebenginecertificateerror.h104
-rw-r--r--src/webenginewidgets/api/qwebengineclientcertificateselection.cpp127
-rw-r--r--src/webenginewidgets/api/qwebengineclientcertificateselection.h80
-rw-r--r--src/webenginewidgets/api/qwebenginecontextmenudata.cpp306
-rw-r--r--src/webenginewidgets/api/qwebenginecontextmenudata.h133
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp786
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h174
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem_p.h99
-rw-r--r--src/webenginewidgets/api/qwebenginefullscreenrequest.cpp136
-rw-r--r--src/webenginewidgets/api/qwebenginefullscreenrequest.h70
-rw-r--r--src/webenginewidgets/api/qwebenginehistory.cpp280
-rw-r--r--src/webenginewidgets/api/qwebenginehistory.h128
-rw-r--r--src/webenginewidgets/api/qwebenginehistory_p.h81
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp2849
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h409
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h232
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp899
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.h167
-rw-r--r--src/webenginewidgets/api/qwebengineprofile_p.h108
-rw-r--r--src/webenginewidgets/api/qwebenginescript.cpp293
-rw-r--r--src/webenginewidgets/api/qwebenginescript.h113
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection.cpp248
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection.h82
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection_p.h91
-rw-r--r--src/webenginewidgets/api/qwebenginesettings.cpp254
-rw-r--r--src/webenginewidgets/api/qwebenginesettings.h154
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp591
-rw-r--r--src/webenginewidgets/api/qwebengineview.h8
-rw-r--r--src/webenginewidgets/api/qwebengineview_p.h52
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc9
-rw-r--r--src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc310
-rw-r--r--src/webenginewidgets/printer_worker.cpp159
-rw-r--r--src/webenginewidgets/printer_worker.h88
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp171
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h9
-rw-r--r--src/webenginewidgets/webenginewidgets.pro33
38 files changed, 725 insertions, 9449 deletions
diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
deleted file mode 100644
index 5949f3d6e..000000000
--- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qtwebenginewidgetsglobal.h"
-
-#include <QCoreApplication>
-#include <QOpenGLContext>
-
-namespace QtWebEngineCore
-{
- extern void initialize();
-}
-
-QT_BEGIN_NAMESPACE
-
-#if QT_CONFIG(opengl)
-Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
-#endif
-
-static void initialize()
-{
-#if QT_CONFIG(opengl)
- if (QCoreApplication::instance()) {
- //On window/ANGLE, calling QtWebEngine::initialize from DllMain will result in a crash.
- if (!qt_gl_global_share_context()) {
- qWarning("Qt WebEngine seems to be initialized from a plugin. Please "
- "set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute "
- "before constructing QGuiApplication.");
- }
- return;
- }
- //QCoreApplication is not yet instantiated, ensuring the call will be deferred
- qAddPreRoutine(QtWebEngineCore::initialize);
-#endif // QT_CONFIG(opengl)
-}
-
-Q_CONSTRUCTOR_FUNCTION(initialize)
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/webenginewidgets/api/qwebenginecertificateerror.cpp
deleted file mode 100644
index d86019af8..000000000
--- a/src/webenginewidgets/api/qwebenginecertificateerror.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qwebenginecertificateerror.h"
-
-#include "certificate_error_controller.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QWebEngineCertificateError
- \brief The QWebEngineCertificateError class provides information about a certificate error.
- \since 5.4
- \inmodule QtWebEngineWidgets
-
- Provides information about a certificate error. This class is used as a parameter of
- QWebEnginePage::certificateError().
-*/
-
-class QWebEngineCertificateErrorPrivate : public QSharedData {
-public:
- QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription);
-
- ~QWebEngineCertificateErrorPrivate() {
- if (deferred && !answered)
- rejectCertificate();
- }
-
- void resolveError(bool accept) {
- if (answered)
- return;
- answered = true;
- if (overridable) {
- if (auto ctl = controller.lock())
- ctl->accept(accept);
- }
- }
-
- void ignoreCertificateError() { resolveError(true); }
- void rejectCertificate() { resolveError(false); }
-
- QWebEngineCertificateError::Error error;
- QUrl url;
- bool overridable;
- QString errorDescription;
- QList<QSslCertificate> certificateChain;
-
- bool answered = false, deferred = false;
- QWeakPointer<CertificateErrorController> controller;
-
- Q_DISABLE_COPY(QWebEngineCertificateErrorPrivate)
-};
-
-QWebEngineCertificateErrorPrivate::QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription)
- : error(QWebEngineCertificateError::Error(error))
- , url(url)
- , overridable(overridable)
- , errorDescription(errorDescription)
-{ }
-
-/*! \internal
-*/
-QWebEngineCertificateError::QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription)
- : d(new QWebEngineCertificateErrorPrivate(error, url, overridable, errorDescription))
-{ }
-
-/*! \internal
-*/
-QWebEngineCertificateError::QWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller)
- : d(new QWebEngineCertificateErrorPrivate(controller->error(), controller->url(),
- controller->overridable(), controller->errorString()))
-{
- d->controller = controller;
- d->certificateChain = controller->certificateChain();
-}
-
-QWebEngineCertificateError::QWebEngineCertificateError(const QWebEngineCertificateError &) = default;
-
-QWebEngineCertificateError& QWebEngineCertificateError::operator=(const QWebEngineCertificateError &) = default;
-
-/*! \internal
-*/
-QWebEngineCertificateError::~QWebEngineCertificateError()
-{
-
-}
-
-/*!
- \enum QWebEngineCertificateError::Error
-
- This enum describes the type of certificate error encountered.
-
- The values of this enum type match the SSL errors Chromium provides.
- QSslError::SslError values are not used directly, because the Qt error
- categories cannot be mapped to the Chromium error categories.
-
- \value SslPinnedKeyNotInCertificateChain The certificate did not match the built-in public keys
- pinned for the host name.
- \value CertificateCommonNameInvalid The certificate's common name did not match the host name.
- \value CertificateDateInvalid The certificate is not valid at the current date and time.
- \value CertificateAuthorityInvalid The certificate is not signed by a trusted authority.
- \value CertificateContainsErrors The certificate contains errors.
- \value CertificateNoRevocationMechanism The certificate has no mechanism for determining if it has been revoked.
- \value CertificateUnableToCheckRevocation Revocation information for the certificate is not available.
- \value CertificateRevoked The certificate has been revoked.
- \value CertificateInvalid The certificate is invalid.
- \value CertificateWeakSignatureAlgorithm The certificate is signed using a weak signature algorithm.
- \value CertificateNonUniqueName The host name specified in the certificate is not unique.
- \value CertificateWeakKey The certificate contains a weak key.
- \value CertificateNameConstraintViolation The certificate claimed DNS names that are in violation of name constraints.
- \value CertificateValidityTooLong The certificate has a validity period that is too long. (Added in Qt 5.7)
- \value CertificateTransparencyRequired Certificate Transparency was required for this connection, but the server
- did not provide CT information that complied with the policy. (Added in Qt 5.8)
- \value CertificateKnownInterceptionBlocked The certificate is known to be
- used for interception by an entity other the device owner. (Added in
- 5.15)
-*/
-
-/*!
- Returns whether this error can be overridden and accepted.
-
- \sa error(), errorDescription()
-*/
-bool QWebEngineCertificateError::isOverridable() const
-{
- return d->overridable;
-}
-
-/*!
- Returns the URL that triggered the error.
-
- \sa error(), errorDescription()
-*/
-QUrl QWebEngineCertificateError::url() const
-{
- return d->url;
-}
-
-/*!
- Returns the type of the error.
-
- \sa errorDescription(), isOverridable()
-*/
-QWebEngineCertificateError::Error QWebEngineCertificateError::error() const
-{
- return d->error;
-}
-
-/*!
- Returns a short localized human-readable description of the error.
-
- \sa error(), url(), isOverridable()
-*/
-QString QWebEngineCertificateError::errorDescription() const
-{
- return d->errorDescription;
-}
-
-/*!
- \since 5.14
-
- Marks the certificate error for delayed handling.
-
- This function should be called when there is a need to postpone the decision whether to ignore a
- certificate error, for example, while waiting for user input. When called, the function pauses the
- URL request until ignoreCertificateError() or rejectCertificate() is called.
-
- \note It is only possible to defer overridable certificate errors.
-
- \sa isOverridable(), deferred()
-*/
-void QWebEngineCertificateError::defer()
-{
- if (isOverridable())
- d->deferred = true;
-}
-
-/*!
- \since 5.14
-
- Returns whether the decision for error handling was delayed and the URL load was halted.
-*/
-bool QWebEngineCertificateError::deferred() const
-{
- return d->deferred;
-}
-
-/*!
- \since 5.14
-
- Ignores the certificate error and continues the loading of the requested URL.
-*/
-void QWebEngineCertificateError::ignoreCertificateError()
-{
- d->ignoreCertificateError();
-}
-
-/*!
- \since 5.14
-
- Rejects the certificate and aborts the loading of the requested URL.
-*/
-void QWebEngineCertificateError::rejectCertificate()
-{
- d->rejectCertificate();
-}
-
-/*!
- \since 5.14
-
- Returns \c true if the error was explicitly rejected or ignored.
-*/
-bool QWebEngineCertificateError::answered() const
-{
- return d->answered;
-}
-
-/*!
- \since 5.14
-
- Returns the peer's chain of digital certificates.
-
- Chain starts with the peer's immediate certificate and ending with the CA's certificate.
-*/
-QList<QSslCertificate> QWebEngineCertificateError::certificateChain() const
-{
- return d->certificateChain;
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.h b/src/webenginewidgets/api/qwebenginecertificateerror.h
deleted file mode 100644
index a32f7ab8e..000000000
--- a/src/webenginewidgets/api/qwebenginecertificateerror.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINECERTIFICATEERROR_H
-#define QWEBENGINECERTIFICATEERROR_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-#include <QtCore/qsharedpointer.h>
-#include <QtCore/qurl.h>
-#include <QtNetwork/QSslCertificate>
-
-QT_BEGIN_NAMESPACE
-
-class CertificateErrorController;
-class QWebEngineCertificateErrorPrivate;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineCertificateError {
-public:
- QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription);
- ~QWebEngineCertificateError();
-
- // Keep this identical to CertificateErrorController::CertificateError, or add mapping layer.
- enum Error {
- SslPinnedKeyNotInCertificateChain = -150,
- CertificateCommonNameInvalid = -200,
- CertificateDateInvalid = -201,
- CertificateAuthorityInvalid = -202,
- CertificateContainsErrors = -203,
- CertificateNoRevocationMechanism = -204,
- CertificateUnableToCheckRevocation = -205,
- CertificateRevoked = -206,
- CertificateInvalid = -207,
- CertificateWeakSignatureAlgorithm = -208,
- CertificateNonUniqueName = -210,
- CertificateWeakKey = -211,
- CertificateNameConstraintViolation = -212,
- CertificateValidityTooLong = -213,
- CertificateTransparencyRequired = -214,
- CertificateKnownInterceptionBlocked = -217,
- };
-
- Error error() const;
- QUrl url() const;
- bool isOverridable() const;
- QString errorDescription() const;
-
- QWebEngineCertificateError(const QWebEngineCertificateError &other);
- QWebEngineCertificateError& operator=(const QWebEngineCertificateError &other);
-
- void defer();
- bool deferred() const;
-
- void rejectCertificate();
- void ignoreCertificateError();
- bool answered() const;
-
- QList<QSslCertificate> certificateChain() const;
-
-private:
- friend class QWebEnginePagePrivate;
- QWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller);
- QExplicitlySharedDataPointer<QWebEngineCertificateErrorPrivate> d;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINECERTIFICATEERROR_H
diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp b/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
deleted file mode 100644
index 9eca01bbe..000000000
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** 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 !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
-#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
-
- When a web site requests an SSL client certificate, and one or more certificates
- are found in the system's client certificate store, this class provides access to
- the certificates to choose from, as well as 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.
-
- \sa QWebEnginePage::selectClientCertificate()
-*/
-
-/*! \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 // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.h b/src/webenginewidgets/api/qwebengineclientcertificateselection.h
deleted file mode 100644
index d451d09ae..000000000
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** 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 !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
-#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 // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
-#endif // QWEBENGINECLIENTCERTSELECTION_H
diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp b/src/webenginewidgets/api/qwebenginecontextmenudata.cpp
deleted file mode 100644
index 377ffe1b5..000000000
--- a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qwebenginecontextmenudata.h"
-
-#include "web_contents_adapter_client.h"
-
-QT_BEGIN_NAMESPACE
-
-// Match MediaType enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeNone, QWebEngineContextMenuData::MediaTypeNone)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeImage, QWebEngineContextMenuData::MediaTypeImage)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeAudio, QWebEngineContextMenuData::MediaTypeAudio)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeVideo, QWebEngineContextMenuData::MediaTypeVideo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeCanvas, QWebEngineContextMenuData::MediaTypeCanvas)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeFile, QWebEngineContextMenuData::MediaTypeFile)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypePlugin, QWebEngineContextMenuData::MediaTypePlugin)
-
-// Match MediaFlag enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaInError, QWebEngineContextMenuData::MediaInError)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaPaused, QWebEngineContextMenuData::MediaPaused)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaMuted, QWebEngineContextMenuData::MediaMuted)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaLoop, QWebEngineContextMenuData::MediaLoop)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanSave, QWebEngineContextMenuData::MediaCanSave)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaHasAudio, QWebEngineContextMenuData::MediaHasAudio)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanToggleControls, QWebEngineContextMenuData::MediaCanToggleControls)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaControls, QWebEngineContextMenuData::MediaControls)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanPrint, QWebEngineContextMenuData::MediaCanPrint)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanRotate, QWebEngineContextMenuData::MediaCanRotate)
-
-// Match EditFlag enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanUndo, QWebEngineContextMenuData::CanUndo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanRedo, QWebEngineContextMenuData::CanRedo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCut, QWebEngineContextMenuData::CanCut)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCopy, QWebEngineContextMenuData::CanCopy)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanPaste, QWebEngineContextMenuData::CanPaste)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanDelete, QWebEngineContextMenuData::CanDelete)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanSelectAll, QWebEngineContextMenuData::CanSelectAll)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanTranslate, QWebEngineContextMenuData::CanTranslate)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanEditRichly, QWebEngineContextMenuData::CanEditRichly)
-
-/*!
- \class QWebEngineContextMenuData
- \since 5.7
- \brief The QWebEngineContextMenuData class provides context data for populating or extending a context menu with actions.
-
- \inmodule QtWebEngineWidgets
-
- QWebEngineContextMenuData is returned by QWebEnginePage::contextMenuData() after a context menu event,
- and contains information about where the context menu event took place. This is also in the context
- in which any context specific QWebEnginePage::WebAction will be performed.
-*/
-
-/*!
- \enum QWebEngineContextMenuData::MediaType
-
- This enum describes the media type of the context if any.
-
- \value MediaTypeNone The context is not a media type.
- \value MediaTypeImage The context is an image element.
- \value MediaTypeVideo The context is a video element.
- \value MediaTypeAudio The context is an audio element.
- \value MediaTypeCanvas The context is a canvas element.
- \value MediaTypeFile The context is a file.
- \value MediaTypePlugin The context is a plugin element.
-*/
-
-/*!
- \enum QWebEngineContextMenuData::EditFlag
- \readonly
- \since 5.11
-
- The available edit operations in the current context.
-
- \value CanUndo Undo is available.
- \value CanRedo Redo is available.
- \value CanCut Cut is available.
- \value CanCopy Copy is available.
- \value CanPaste Paste is available.
- \value CanDelete Delete is available.
- \value CanSelectAll Select All is available.
- \value CanTranslate Translate is available.
- \value CanEditRichly Context is richly editable.
-*/
-
-/*!
- \enum QWebEngineContextMenuData::MediaFlag
- \readonly
- \since 5.11
-
- The current media element's status and its available operations.
- \c MediaNone if the selected web page content is not a media element.
-
- \value MediaInError An error occurred.
- \value MediaPaused Media is paused.
- \value MediaMuted Media is muted.
- \value MediaLoop Media can be looped.
- \value MediaCanSave Media can be saved.
- \value MediaHasAudio Media has audio.
- \value MediaCanToggleControls Media can show controls.
- \value MediaControls Media controls are shown.
- \value MediaCanPrint Media is printable.
- \value MediaCanRotate Media is rotatable.
-*/
-
-/*!
- Constructs null context menu data.
-*/
-QWebEngineContextMenuData::QWebEngineContextMenuData() : d(nullptr)
-{
-}
-
-/*!
- Constructs context menu data from \a other.
-*/
-QWebEngineContextMenuData::QWebEngineContextMenuData(const QWebEngineContextMenuData &other)
-{
- d = new QtWebEngineCore::WebEngineContextMenuData(*other.d);
-}
-
-/*!
- Assigns the \a other context menu data to this.
-*/
-QWebEngineContextMenuData &QWebEngineContextMenuData::operator=(const QWebEngineContextMenuData &other)
-{
- delete d;
- d = new QtWebEngineCore::WebEngineContextMenuData(*other.d);
- return *this;
-}
-
-/*!
- Destroys the context menu data.
-*/
-QWebEngineContextMenuData::~QWebEngineContextMenuData()
-{
- delete d;
-}
-
-/*!
- Returns \c true if the context data is valid; otherwise returns \c false.
-*/
-bool QWebEngineContextMenuData::isValid() const
-{
- return d;
-}
-
-/*!
- Resets the context data, making it invalid.
- \internal
-
- \sa isValid()
-*/
-void QWebEngineContextMenuData::reset()
-{
- delete d;
- d = nullptr;
-}
-
-/*!
- Returns the position of the context, usually the mouse position where the context menu event was triggered.
-*/
-QPoint QWebEngineContextMenuData::position() const
-{
- return d ? d->position() : QPoint();
-}
-
-/*!
- Returns the text of a link if the context is a link.
-*/
-QString QWebEngineContextMenuData::linkText() const
-{
- return d ? d->linkText() : QString();
-}
-
-/*!
- Returns the URL of a link if the context is a link.
- It is not guaranteed to be a valid URL.
-*/
-QUrl QWebEngineContextMenuData::linkUrl() const
-{
- return d ? d->unfilteredLinkUrl() : QUrl();
-}
-
-/*!
- Returns the selected text of the context.
-*/
-QString QWebEngineContextMenuData::selectedText() const
-{
- return d ? d->selectedText() : QString();
-}
-
-/*!
- If the context is a media element, returns the URL of that media.
-*/
-QUrl QWebEngineContextMenuData::mediaUrl() const
-{
- return d ? d->mediaUrl() : QUrl();
-}
-
-/*!
- Returns the type of the media element or \c MediaTypeNone if the context is not a media element.
-*/
-QWebEngineContextMenuData::MediaType QWebEngineContextMenuData::mediaType() const
-{
- return d ? static_cast<QWebEngineContextMenuData::MediaType>(d->mediaType()) : MediaTypeNone;
-}
-
-/*!
- Returns \c true if the content is editable by the user; otherwise returns \c false.
-*/
-bool QWebEngineContextMenuData::isContentEditable() const
-{
- return d ? d->isEditable() : false;
-}
-
-/*!
- If the context is a word considered misspelled by the spell-checker, returns the misspelled word.
-
- For possible replacements of the word, see spellCheckerSuggestions().
-
- \since 5.8
-*/
-QString QWebEngineContextMenuData::misspelledWord() const
-{
- if (d)
- return d->misspelledWord();
- return QString();
-}
-
-/*!
- If the context is a word considered misspelled by the spell-checker, returns a list of suggested replacements
- for misspelledWord().
-
- \since 5.8
-*/
-QStringList QWebEngineContextMenuData::spellCheckerSuggestions() const
-{
- if (d)
- return d->spellCheckerSuggestions();
- return QStringList();
-}
-
-/*!
- \internal
-*/
-QWebEngineContextMenuData &QWebEngineContextMenuData::operator=(const QWebEngineContextDataPrivate &priv)
-{
- delete d;
- d = new QtWebEngineCore::WebEngineContextMenuData(priv);
- return *this;
-}
-
-/*!
- Returns the current media element's status and its available operations.
- \c MediaNone if the selected web page content is not a media element.
-*/
-QWebEngineContextMenuData::MediaFlags QWebEngineContextMenuData::mediaFlags() const
-{
- return static_cast<QWebEngineContextMenuData::MediaFlags>(d->mediaFlags());
-}
-
-/*!
- Returns the available edit operations in the current context or \c CanDoNone if no actions are available.
-*/
-QWebEngineContextMenuData::EditFlags QWebEngineContextMenuData::editFlags() const
-{
- return static_cast<QWebEngineContextMenuData::EditFlags>(d->editFlags());
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.h b/src/webenginewidgets/api/qwebenginecontextmenudata.h
deleted file mode 100644
index 5834df31a..000000000
--- a/src/webenginewidgets/api/qwebenginecontextmenudata.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINECONTEXTDATA_H
-#define QWEBENGINECONTEXTDATA_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qurl.h>
-
-namespace QtWebEngineCore {
-class WebEngineContextMenuData;
-}
-
-QT_BEGIN_NAMESPACE
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineContextMenuData {
- Q_GADGET
-
-public:
- QWebEngineContextMenuData();
- QWebEngineContextMenuData(const QWebEngineContextMenuData &other);
- QWebEngineContextMenuData &operator=(const QWebEngineContextMenuData &other);
- ~QWebEngineContextMenuData();
-
- enum MediaType {
- MediaTypeNone,
- MediaTypeImage,
- MediaTypeVideo,
- MediaTypeAudio,
- MediaTypeCanvas,
- MediaTypeFile,
- MediaTypePlugin
- };
-
- // Must match QWebEngineCore::WebEngineContextMenuData::MediaFlags:
- enum MediaFlag {
- MediaInError = 0x1,
- MediaPaused = 0x2,
- MediaMuted = 0x4,
- MediaLoop = 0x8,
- MediaCanSave = 0x10,
- MediaHasAudio = 0x20,
- MediaCanToggleControls = 0x40,
- MediaControls = 0x80,
- MediaCanPrint = 0x100,
- MediaCanRotate = 0x200,
- };
- Q_DECLARE_FLAGS(MediaFlags, MediaFlag)
- Q_FLAG(MediaFlags)
-
- // Must match QWebEngineCore::WebEngineContextMenuData::EditFlags:
- enum EditFlag {
- CanUndo = 0x1,
- CanRedo = 0x2,
- CanCut = 0x4,
- CanCopy = 0x8,
- CanPaste = 0x10,
- CanDelete = 0x20,
- CanSelectAll = 0x40,
- CanTranslate = 0x80,
- CanEditRichly = 0x100,
- };
- Q_DECLARE_FLAGS(EditFlags, EditFlag)
- Q_FLAG(EditFlags)
-
- bool isValid() const;
-
- QPoint position() const;
- QString selectedText() const;
- QString linkText() const;
- QUrl linkUrl() const;
- QUrl mediaUrl() const;
- MediaType mediaType() const;
- bool isContentEditable() const;
- QString misspelledWord() const;
- QStringList spellCheckerSuggestions() const;
- MediaFlags mediaFlags() const;
- EditFlags editFlags() const;
-
-private:
- void reset();
- typedef QtWebEngineCore::WebEngineContextMenuData QWebEngineContextDataPrivate;
- QWebEngineContextMenuData &operator=(const QWebEngineContextDataPrivate &priv);
- const QWebEngineContextDataPrivate *d;
-
- friend class QWebEnginePagePrivate;
- friend class QWebEnginePage;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEngineContextMenuData::MediaFlags)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEngineContextMenuData::EditFlags)
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINECONTEXTDATA_H
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
deleted file mode 100644
index 7366dbf59..000000000
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ /dev/null
@@ -1,786 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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 "qwebenginedownloaditem.h"
-#include "qwebenginedownloaditem_p.h"
-
-#include "profile_adapter.h"
-#include "qwebengineprofile_p.h"
-
-#include <QDir>
-#include "QFileInfo"
-
-QT_BEGIN_NAMESPACE
-
-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 ProfileAdapterClient::DownloadInProgress:
- return QWebEngineDownloadItem::DownloadInProgress;
- case ProfileAdapterClient::DownloadCompleted:
- return QWebEngineDownloadItem::DownloadCompleted;
- case ProfileAdapterClient::DownloadCancelled:
- return QWebEngineDownloadItem::DownloadCancelled;
- case ProfileAdapterClient::DownloadInterrupted:
- return QWebEngineDownloadItem::DownloadInterrupted;
- default:
- Q_UNREACHABLE();
- return QWebEngineDownloadItem::DownloadCancelled;
- }
-}
-
-static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterruptReason(int reason)
-{
- return static_cast<QWebEngineDownloadItem::DownloadInterruptReason>(reason);
-}
-
-/*!
- \class QWebEngineDownloadItem
- \brief The QWebEngineDownloadItem class provides information about a download.
-
- \since 5.5
-
- \inmodule QtWebEngineWidgets
-
- QWebEngineDownloadItem models a download throughout its life cycle, starting
- with a pending download request and finishing with a completed download. It
- can be used, for example, to get information about new downloads, to monitor
- progress, and to pause, resume, and cancel downloads.
-
- Downloads are usually triggered by user interaction on a web page. It is the
- QWebEngineProfile's responsibility to notify the application of new download
- requests, which it does by emitting the
- \l{QWebEngineProfile::downloadRequested}{downloadRequested} signal together
- with a newly created QWebEngineDownloadItem. The application can then
- examine this item and decide whether to accept it or not. A signal handler
- must explicitly call accept() on the item for \QWE to actually start
- downloading and writing data to disk. If no signal handler calls accept(),
- then the download request will be automatically rejected and nothing will be
- written to disk.
-
- \note Some properties, such as setting the path and file name where the file
- will be saved (see \l downloadDirectory() and \l downloadFileName()), can
- only be changed before calling accept().
-
- \section2 Object Life Cycle
-
- All items are guaranteed to be valid during the emission of the
- \l{QWebEngineProfile::downloadRequested}{downloadRequested} signal. If
- accept() is \e not called by any signal handler, then the item will be
- deleted \e immediately after signal emission. This means that the
- application \b{must not} keep references to rejected download items. It also
- means the application should not use a queued connection to this signal.
-
- If accept() \e is called by a signal handler, then the QWebEngineProfile
- will take ownership of the item. However, it is safe for the application to
- delete the item at any time, except during the handling of the
- \l{QWebEngineProfile::downloadRequested}{downloadRequested} signal. The
- QWebEngineProfile being a long-lived object, it is in fact recommended that
- the application delete any items it is no longer interested in.
-
- \note Deleting an item will also automatically cancel a download since 5.12.2,
- but it is recommended to cancel manually before deleting for portability.
-
- \section2 Web Page Downloads
-
- In addition to normal file downloads, which consist simply of retrieving
- some raw bytes from the network and writing them to disk, \QWE also
- supports saving complete web pages, which involves parsing the page's HTML,
- downloading any dependent resources, and potentially packaging everything
- into a special file format (\l savePageFormat). To check if a download is
- for a file or a web page, use \l isSavePageDownload.
-
- \sa QWebEngineProfile, QWebEngineProfile::downloadRequested,
- QWebEnginePage::download, QWebEnginePage::save
-*/
-
-QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePrivate *p, const QUrl &url)
- : profile(p)
- , downloadFinished(false)
- , downloadId(-1)
- , downloadState(QWebEngineDownloadItem::DownloadCancelled)
- , savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat)
- , type(QWebEngineDownloadItem::Attachment)
- , interruptReason(QWebEngineDownloadItem::NoReason)
- , downloadUrl(url)
- , downloadPaused(false)
- , isCustomFileName(false)
- , totalBytes(-1)
- , receivedBytes(0)
- , page(0)
-{
-}
-
-QWebEngineDownloadItemPrivate::~QWebEngineDownloadItemPrivate()
-{
-}
-
-void QWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadItemInfo &info)
-{
- Q_Q(QWebEngineDownloadItem);
-
- Q_ASSERT(downloadState != QWebEngineDownloadItem::DownloadRequested);
-
- if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason)
- interruptReason = toDownloadInterruptReason(info.downloadInterruptReason);
-
- if (toDownloadState(info.state) != downloadState) {
- downloadState = toDownloadState(info.state);
- Q_EMIT q->stateChanged(downloadState);
- }
-
- if (info.receivedBytes != receivedBytes || info.totalBytes != totalBytes) {
- receivedBytes = info.receivedBytes;
- totalBytes = info.totalBytes;
- Q_EMIT q->downloadProgress(receivedBytes, totalBytes);
- }
-
- if (info.done)
- setFinished();
-
- if (downloadPaused != info.paused) {
- downloadPaused = info.paused;
- Q_EMIT q->isPausedChanged(downloadPaused);
- }
-}
-
-void QWebEngineDownloadItemPrivate::setFinished()
-{
- if (downloadFinished)
- return;
-
- downloadFinished = true;
- Q_EMIT q_ptr->finished();
-}
-
-/*!
- Accepts the current download request, which will start the download.
-
- If the item is in the \l DownloadRequested state, then it will transition
- into the \l DownloadInProgress state and the downloading will begin. If the
- item is in any other state, then nothing will happen.
-
- \sa finished(), stateChanged()
-*/
-
-void QWebEngineDownloadItem::accept()
-{
- Q_D(QWebEngineDownloadItem);
-
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested)
- return;
-
- d->downloadState = QWebEngineDownloadItem::DownloadInProgress;
- Q_EMIT stateChanged(d->downloadState);
-}
-
-/*!
- Cancels the current download.
-
- If the item is in the \l DownloadInProgress state, then it will transition
- into the \l DownloadCancelled state, the downloading will stop, and partially
- downloaded files will be deleted from disk.
-
- If the item is in the \l DownloadCompleted state, then nothing will happen.
- If the item is in any other state, then it will transition into the \l
- DownloadCancelled state without further effect.
-
- \sa finished(), stateChanged()
-*/
-
-void QWebEngineDownloadItem::cancel()
-{
- Q_D(QWebEngineDownloadItem);
-
- QWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (state == QWebEngineDownloadItem::DownloadCompleted
- || state == QWebEngineDownloadItem::DownloadCancelled)
- return;
-
- // 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 profileAdapter = d->profile->profileAdapter())
- profileAdapter->cancelDownload(d->downloadId);
- } else {
- d->downloadState = QWebEngineDownloadItem::DownloadCancelled;
- Q_EMIT stateChanged(d->downloadState);
- d->setFinished();
- }
-}
-
-/*!
- \since 5.10
- Pauses the download.
-
- Has no effect if the state is not \l DownloadInProgress. Does not change the
- state.
-
- \sa resume(), isPaused()
-*/
-
-void QWebEngineDownloadItem::pause()
-{
- Q_D(QWebEngineDownloadItem);
-
- QWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (state != QWebEngineDownloadItem::DownloadInProgress)
- return;
-
- d->profile->profileAdapter()->pauseDownload(d->downloadId);
-}
-
-/*!
- \since 5.10
- Resumes the current download if it was paused or interrupted.
-
- Has no effect if the state is not \l DownloadInProgress or \l
- DownloadInterrupted. Does not change the state.
-
- \sa pause(), isPaused(), state()
-*/
-void QWebEngineDownloadItem::resume()
-{
- Q_D(QWebEngineDownloadItem);
-
- QWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (d->downloadFinished || (state != QWebEngineDownloadItem::DownloadInProgress && state != QWebEngineDownloadItem::DownloadInterrupted))
- return;
- d->profile->profileAdapter()->resumeDownload(d->downloadId);
-}
-
-/*!
- Returns the download item's ID.
-*/
-
-quint32 QWebEngineDownloadItem::id() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadId;
-}
-
-/*!
- \fn void QWebEngineDownloadItem::finished()
-
- This signal is emitted when the download finishes.
-
- \sa state(), isFinished()
-*/
-
-/*!
- \fn void QWebEngineDownloadItem::isPausedChanged(bool isPaused)
- \since 5.10
-
- This signal is emitted whenever \a isPaused changes.
-
- \sa pause(), isPaused()
-*/
-
-/*!
- \fn void QWebEngineDownloadItem::stateChanged(DownloadState state)
-
- This signal is emitted whenever the download's \a state changes.
-
- \sa state(), DownloadState
-*/
-
-/*!
- \fn void QWebEngineDownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
-
- This signal is emitted to indicate the progress of the download request.
-
- The \a bytesReceived parameter indicates the number of bytes received, while
- \a bytesTotal indicates the total number of bytes expected to be downloaded.
- If the size of the file to be downloaded is not known, \c bytesTotal will be
- 0.
-
- \sa totalBytes(), receivedBytes()
-*/
-
-/*!
- \enum QWebEngineDownloadItem::DownloadState
-
- This enum describes the state of the download:
-
- \value DownloadRequested Download has been requested, but has not been accepted yet.
- \value DownloadInProgress Download is in progress.
- \value DownloadCompleted Download completed successfully.
- \value DownloadCancelled Download has been cancelled.
- \value DownloadInterrupted Download has been interrupted (by the server or because of lost
- connectivity).
-*/
-
-/*!
- \enum QWebEngineDownloadItem::SavePageFormat
- \since 5.7
-
- This enum describes the format that is used to save a web page.
-
- \value UnknownSaveFormat This is not a request for downloading a complete web page.
- \value SingleHtmlSaveFormat The page is saved as a single HTML page. Resources such as images
- are not saved.
- \value CompleteHtmlSaveFormat The page is saved as a complete HTML page, for example a directory
- containing the single HTML page and the resources.
- \value MimeHtmlSaveFormat The page is saved as a complete web page in the MIME HTML format.
-*/
-
-/*!
- \enum QWebEngineDownloadItem::DownloadType
- \since 5.8
- \obsolete
-
- Describes the requested download's type.
-
- \value Attachment The web server's response includes a
- \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition
- is present in the reply, the web server is indicating that the client should prompt the
- user to save the content regardless of the content type.
- See \l {RFC 2616 section 19.5.1} for details.
- \value DownloadAttribute The user clicked a link with the \c download
- attribute.
- \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
- \since 5.9
-
- Describes the reason why a download was interrupted:
-
- \value NoReason Unknown reason or not interrupted.
- \value FileFailed General file operation failure.
- \value FileAccessDenied The file cannot be written locally, due to access restrictions.
- \value FileNoSpace Insufficient space on the target drive.
- \value FileNameTooLong The directory or file name is too long.
- \value FileTooLarge The file size exceeds the file system limitation.
- \value FileVirusInfected The file is infected with a virus.
- \value FileTransientError Temporary problem (for example the file is in use,
- out of memory, or too many files are opened at once).
- \value FileBlocked The file was blocked due to local policy.
- \value FileSecurityCheckFailed An attempt to check the safety of the download
- failed due to unexpected reasons.
- \value FileTooShort An attempt was made to seek past the end of a file when
- opening a file (as part of resuming a previously interrupted download).
- \value FileHashMismatch The partial file did not match the expected hash.
-
- \value NetworkFailed General network failure.
- \value NetworkTimeout The network operation has timed out.
- \value NetworkDisconnected The network connection has been terminated.
- \value NetworkServerDown The server has gone down.
- \value NetworkInvalidRequest The network request was invalid (for example, the
- original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy).
-
- \value ServerFailed General server failure.
- \value ServerBadContent The server does not have the requested data.
- \value ServerUnauthorized The server did not authorize access to the resource.
- \value ServerCertProblem A problem with the server certificate occurred.
- \value ServerForbidden Access forbidden by the server.
- \value ServerUnreachable Unexpected server response (might indicate that
- the responding server may not be the intended server).
- \value UserCanceled The user canceled the download.
-*/
-
-/*!
- Returns the download item's current state.
-
- \sa DownloadState
-*/
-
-QWebEngineDownloadItem::DownloadState QWebEngineDownloadItem::state() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadState;
-}
-
-/*!
- Returns the the total amount of data to download in bytes.
-
- \c -1 means the size is unknown.
-*/
-
-qint64 QWebEngineDownloadItem::totalBytes() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->totalBytes;
-}
-
-/*!
- Returns the amount of data in bytes that has been downloaded so far.
-
- \c -1 means the size is unknown.
-*/
-
-qint64 QWebEngineDownloadItem::receivedBytes() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->receivedBytes;
-}
-
-/*!
- Returns the download's origin URL.
-*/
-
-QUrl QWebEngineDownloadItem::url() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadUrl;
-}
-
-/*!
- \since 5.6
-
- Returns the MIME type of the download.
-*/
-
-QString QWebEngineDownloadItem::mimeType() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->mimeType;
-}
-
-/*!
- \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;
- }
-
- if (QFileInfo(path).fileName() == path) {
- d->downloadDirectory = QStringLiteral("");
- d->downloadFileName = path;
- } else {
- d->downloadDirectory = QFileInfo(path).path();
- d->downloadFileName = QFileInfo(path).fileName();
- }
- }
-}
-
-/*!
- \since 5.14
-
- Returns the download directory path.
-*/
-
-QString QWebEngineDownloadItem::downloadDirectory() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadDirectory;
-}
-
-/*!
- \since 5.14
-
- Sets \a directory as the directory path to download the file to.
-
- The download directory 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::setDownloadDirectory(const QString &directory)
-{
- Q_D(QWebEngineDownloadItem);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download directory is not allowed after the download has been accepted.");
- return;
- }
-
- if (!directory.isEmpty() && d->downloadDirectory != directory)
- d->downloadDirectory = directory;
-
- if (!d->isCustomFileName)
- d->downloadFileName = QFileInfo(d->profile->profileAdapter()->determineDownloadPath(d->downloadDirectory,
- d->suggestedFileName,
- d->startTime)).fileName();
-}
-
-/*!
- \since 5.14
-
- Returns the file name to download the file to.
-*/
-
-QString QWebEngineDownloadItem::downloadFileName() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadFileName;
-}
-
-/*!
- \since 5.14
-
- Sets \a fileName as the file name to download the file to.
-
- The download file name 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::setDownloadFileName(const QString &fileName)
-{
- Q_D(QWebEngineDownloadItem);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download file name is not allowed after the download has been accepted.");
- return;
- }
-
- if (!fileName.isEmpty()) {
- d->downloadFileName = fileName;
- d->isCustomFileName = true;
- }
-}
-
-/*!
- \since 5.14
-
- Returns the suggested file name.
-*/
-
-QString QWebEngineDownloadItem::suggestedFileName() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->suggestedFileName;
-}
-
-/*!
- Returns whether this download is finished (completed, cancelled, or non-resumable interrupted state).
-
- \sa finished(), state(),
-*/
-
-bool QWebEngineDownloadItem::isFinished() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadFinished;
-}
-
-/*!
- Returns whether this download is paused.
-
- \sa pause(), resume()
-*/
-
-bool QWebEngineDownloadItem::isPaused() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadPaused;
-}
-
-/*!
- Returns the format the web page will be saved in if this is a download request for a web page.
- \since 5.7
-
- \sa setSavePageFormat(), isSavePageDownload()
-*/
-QWebEngineDownloadItem::SavePageFormat QWebEngineDownloadItem::savePageFormat() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->savePageFormat;
-}
-
-/*!
- Sets the \a format the web page will be saved in if this is a download request for a web page.
- \since 5.7
-
- \sa savePageFormat(), isSavePageDownload()
-*/
-void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageFormat format)
-{
- Q_D(QWebEngineDownloadItem);
- d->savePageFormat = format;
-}
-
-/*!
- Returns the requested download's type.
- \since 5.8
- \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.
- \since 5.11
-
- \sa savePageFormat(), setSavePageFormat()
- */
-bool QWebEngineDownloadItem::isSavePageDownload() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->type == QWebEngineDownloadItem::SavePage;
-}
-
-/*!
- Returns the reason why the download was interrupted.
- \since 5.9
-
- \sa interruptReasonString()
-*/
-
-QWebEngineDownloadItem::DownloadInterruptReason QWebEngineDownloadItem::interruptReason() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->interruptReason;
-}
-
-/*!
- Returns a human-readable description of the reason for interrupting the download.
- \since 5.9
-
- \sa interruptReason()
-*/
-
-QString QWebEngineDownloadItem::interruptReasonString() const
-{
- 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)
- : QObject(parent)
- , d_ptr(p)
-{
- p->q_ptr = this;
-}
-
-/*! \internal
-*/
-QWebEngineDownloadItem::~QWebEngineDownloadItem()
-{
- // MEMO Items are owned by profile by default and will be destroyed on profile's destruction
- // It's not safe to access profile in that case, so we rely on profile to clean up items
- if (!isFinished())
- cancel();
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
deleted file mode 100644
index 094054079..000000000
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEDOWNLOADITEM_H
-#define QWEBENGINEDOWNLOADITEM_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWebEnginePage;
-class QWebEngineDownloadItemPrivate;
-class QWebEngineProfilePrivate;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineDownloadItem : public QObject
-{
- Q_OBJECT
-public:
- ~QWebEngineDownloadItem();
-
- enum DownloadState {
- DownloadRequested,
- DownloadInProgress,
- DownloadCompleted,
- DownloadCancelled,
- DownloadInterrupted
- };
- Q_ENUM(DownloadState)
-
- enum SavePageFormat {
- UnknownSaveFormat = -1,
- SingleHtmlSaveFormat,
- CompleteHtmlSaveFormat,
- MimeHtmlSaveFormat
- };
- Q_ENUM(SavePageFormat)
-
- enum DownloadInterruptReason {
- NoReason = 0,
- FileFailed = 1,
- FileAccessDenied = 2,
- FileNoSpace = 3,
- FileNameTooLong = 5,
- FileTooLarge = 6,
- FileVirusInfected = 7,
- FileTransientError = 10,
- FileBlocked = 11,
- FileSecurityCheckFailed = 12,
- FileTooShort = 13,
- FileHashMismatch = 14,
- NetworkFailed = 20,
- NetworkTimeout = 21,
- NetworkDisconnected = 22,
- NetworkServerDown = 23,
- NetworkInvalidRequest = 24,
- ServerFailed = 30,
- //ServerNoRange = 31,
- ServerBadContent = 33,
- ServerUnauthorized = 34,
- ServerCertProblem = 35,
- ServerForbidden = 36,
- ServerUnreachable = 37,
- UserCanceled = 40,
- //UserShutdown = 41,
- //Crash = 50
- };
- 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;
- QString suggestedFileName() const;
- QString downloadDirectory() const;
- void setDownloadDirectory(const QString &directory);
- QString downloadFileName() const;
- void setDownloadFileName(const QString &fileName);
-
- QWebEnginePage *page() const;
-
-public Q_SLOTS:
- void accept();
- void cancel();
- void pause();
- void resume();
-
-Q_SIGNALS:
- void finished();
- void stateChanged(QWebEngineDownloadItem::DownloadState state);
- void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
- void isPausedChanged(bool isPaused);
-
-private:
- Q_DISABLE_COPY(QWebEngineDownloadItem)
- Q_DECLARE_PRIVATE(QWebEngineDownloadItem)
-
- friend class QWebEngineProfilePrivate;
-
- QWebEngineDownloadItem(QWebEngineDownloadItemPrivate*, QObject *parent = Q_NULLPTR);
- QScopedPointer<QWebEngineDownloadItemPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEDOWNLOADITEM_H
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
deleted file mode 100644
index 04c6fadcc..000000000
--- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEDOWNLOADITEM_P_H
-#define QWEBENGINEDOWNLOADITEM_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qtwebenginewidgetsglobal.h"
-
-#include "qwebenginedownloaditem.h"
-#include "qwebengineprofile_p.h"
-#include <QString>
-
-QT_BEGIN_NAMESPACE
-
-class QWebEngineDownloadItemPrivate {
- QWebEngineDownloadItem *q_ptr;
- QWebEngineProfilePrivate* profile;
- friend class QWebEngineProfilePrivate;
-public:
- Q_DECLARE_PUBLIC(QWebEngineDownloadItem)
- QWebEngineDownloadItemPrivate(QWebEngineProfilePrivate *p, const QUrl &url);
- ~QWebEngineDownloadItemPrivate();
-
- bool downloadFinished;
- quint32 downloadId;
- qint64 startTime;
- QWebEngineDownloadItem::DownloadState downloadState;
- QWebEngineDownloadItem::SavePageFormat savePageFormat;
- QWebEngineDownloadItem::DownloadType type;
- QWebEngineDownloadItem::DownloadInterruptReason interruptReason;
- QString downloadPath;
- const QUrl downloadUrl;
- QString mimeType;
- bool downloadPaused;
- QString suggestedFileName;
- QString downloadDirectory;
- QString downloadFileName;
- bool isCustomFileName;
-
- qint64 totalBytes;
- qint64 receivedBytes;
- QWebEnginePage *page;
-
- void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
-
- void setFinished();
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEDOWNLOADITEM_P_H
-
diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp b/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp
deleted file mode 100644
index bcf2d5d22..000000000
--- a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qwebenginefullscreenrequest.h"
-#include "qwebenginepage_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QWebEngineFullScreenRequest
- \brief The QWebEngineFullScreenRequest class enables accepting or rejecting
- requests for entering and exiting the fullscreen mode.
-
- \since 5.6
-
- \inmodule QtWebEngineWidgets
-
- To allow elements such as videos to be shown in the fullscreen mode,
- applications must set QWebEngineSettings::FullScreenSupportEnabled and
- connect to QWebEnginePage::fullScreenRequested, which takes a
- QWebEngineFullScreenRequest instance as an argument.
-
- If an element of a web page requests to be shown in the fullscreen mode,
- QWebEnginePage::fullScreenRequested will be emitted with an
- QWebEngineFullScreenRequest instance as an argument where toggleOn() returns
- \c true. The signal handler needs to then either call accept() or reject().
-
- If the request to enter the fullscreen mode is accepted, the element
- requesting fullscreen mode will fill the viewport, but it is up to the
- application to make the view fullscreen or to move the page to a view that
- is in the fullscreen mode.
-
- Likewise, a QWebEnginePage::fullScreenRequested will be emitted when
- the user wants to leave the full screen mode (that is, through the
- QWebEnginePage::ExitFullScreen context menu action). In this case,
- toggleOn() will return \c false, and the signal handler again needs to
- accept() or reject() the request. If it is accepted, the applicaton needs to
- make sure that the global window state is restored.
-*/
-
-/*!
- \property QWebEngineFullScreenRequest::toggleOn
- \brief Whether the web page has issued a request to enter fullscreen mode.
-*/
-
-/*!
- \property QWebEngineFullScreenRequest::origin
- \brief The URL to be opened in the fullscreen mode.
-*/
-
-/*!
- \fn QWebEngineFullScreenRequest::toggleOn() const
- Returns \c true if the web page has issued a request to enter the fullscreen
- mode, otherwise returns \c false.
-*/
-
-/*!
- \fn QWebEngineFullScreenRequest::origin() const
- Returns the URL to be opened in the fullscreen mode.
-*/
-
-/*!
- Creates a request for opening the \a page from the URL specified by
- \a origin in the fullscreen mode if \a fullscreen is \c true.
-*/
-
-QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEnginePage *page, const QUrl &origin, bool fullscreen)
- : m_page(page)
- , m_origin(origin)
- , m_toggleOn(fullscreen)
-{
-}
-
-/*!
- Rejects a request to enter or exit the fullscreen mode.
-*/
-void QWebEngineFullScreenRequest::reject()
-{
- if (!m_page) {
- qWarning("Cannot reject QWebEngineFullScreenRequest: Originating page is already deleted");
- return;
- }
-
- m_page->d_func()->setFullScreenMode(!m_toggleOn);
-}
-
-/*!
- Accepts the request to enter or exit the fullscreen mode.
-*/
-void QWebEngineFullScreenRequest::accept()
-{
- if (!m_page) {
- qWarning("Cannot accept QWebEngineFullScreenRequest: Originating page is already deleted");
- return;
- }
-
- m_page->d_func()->setFullScreenMode(m_toggleOn);
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.h b/src/webenginewidgets/api/qwebenginefullscreenrequest.h
deleted file mode 100644
index 08505a410..000000000
--- a/src/webenginewidgets/api/qwebenginefullscreenrequest.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEFULLSCREENREQUEST_H
-#define QWEBENGINEFULLSCREENREQUEST_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qpointer.h>
-
-QT_BEGIN_NAMESPACE
-class QWebEnginePage;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineFullScreenRequest {
- Q_GADGET
- Q_PROPERTY(bool toggleOn READ toggleOn CONSTANT)
- Q_PROPERTY(QUrl origin READ origin CONSTANT)
-public:
- Q_INVOKABLE void reject();
- Q_INVOKABLE void accept();
- bool toggleOn() const { return m_toggleOn; }
- const QUrl &origin() const { return m_origin; }
-
-private:
- QWebEngineFullScreenRequest(QWebEnginePage *page, const QUrl &origin, bool toggleOn);
- QPointer<QWebEnginePage> m_page;
- const QUrl m_origin;
- const bool m_toggleOn;
- friend class QWebEnginePagePrivate;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/webenginewidgets/api/qwebenginehistory.cpp b/src/webenginewidgets/api/qwebenginehistory.cpp
deleted file mode 100644
index 6a85b984e..000000000
--- a/src/webenginewidgets/api/qwebenginehistory.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qwebenginehistory.h"
-#include "qwebenginehistory_p.h"
-
-#include "qwebenginepage_p.h"
-#include "web_contents_adapter.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \fn QWebEngineHistoryItem::swap(QWebEngineHistoryItem &other)
- Swaps the history item with the \a other item.
-*/
-
-QWebEngineHistoryItemPrivate::QWebEngineHistoryItemPrivate(QWebEnginePagePrivate *page, int index)
- : page(page)
- , index(index)
-{
-}
-
-QWebEngineHistoryItem::QWebEngineHistoryItem(QWebEngineHistoryItemPrivate *d)
- : d(d)
-{
-}
-
-QWebEngineHistoryItem::QWebEngineHistoryItem(const QWebEngineHistoryItem &other)
- : d(other.d)
-{
-}
-
-QWebEngineHistoryItem &QWebEngineHistoryItem::operator=(const QWebEngineHistoryItem &other)
-{
- d = other.d;
- return *this;
-}
-
-QWebEngineHistoryItem::~QWebEngineHistoryItem()
-{
-}
-
-QUrl QWebEngineHistoryItem::originalUrl() const
-{
- Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryOriginalUrl(d->index) : QUrl();
-}
-
-QUrl QWebEngineHistoryItem::url() const
-{
- Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryUrl(d->index) : QUrl();
-}
-
-QString QWebEngineHistoryItem::title() const
-{
- Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryTitle(d->index) : QString();
-}
-
-QDateTime QWebEngineHistoryItem::lastVisited() const
-{
- Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryTimestamp(d->index) : QDateTime();
-}
-
-/*!
- Returns the URL of the icon associated with the history item.
-
- \sa url(), originalUrl(), title()
-*/
-QUrl QWebEngineHistoryItem::iconUrl() const
-{
- Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryIconUrl(d->index) : QUrl();
-}
-
-bool QWebEngineHistoryItem::isValid() const
-{
- Q_D(const QWebEngineHistoryItem);
- if (!d->page)
- return false;
- return d->index >= 0 && d->index < d->page->webContents()->navigationEntryCount();
-}
-
-QWebEngineHistoryPrivate::QWebEngineHistoryPrivate(QWebEnginePagePrivate *page)
- : page(page)
-{
-}
-
-QWebEngineHistoryPrivate::~QWebEngineHistoryPrivate()
-{
- // Invalidate shared item references possibly still out there.
- QList<QWebEngineHistoryItem>::iterator it, end;
- for (it = items.begin(), end = items.end(); it != end; ++it)
- it->d->page = 0;
-}
-
-void QWebEngineHistoryPrivate::updateItems() const
-{
- // Keep track of items we return to be able to invalidate them
- // and avoid dangling references to our page.
- int entryCount = page->webContents()->navigationEntryCount();
- while (items.size() > entryCount) {
- items.last().d->page = 0;
- items.removeLast();
- }
- while (items.size() < entryCount) {
- int nextIndex = items.size();
- items.append(QWebEngineHistoryItem(new QWebEngineHistoryItemPrivate(page, nextIndex)));
- }
-}
-
-QWebEngineHistory::QWebEngineHistory(QWebEngineHistoryPrivate *d)
- : d_ptr(d)
-{
-}
-
-QWebEngineHistory::~QWebEngineHistory()
-{
-}
-
-void QWebEngineHistory::clear()
-{
- Q_D(const QWebEngineHistory);
- d->page->webContents()->clearNavigationHistory();
- d->page->updateNavigationActions();
-}
-
-QList<QWebEngineHistoryItem> QWebEngineHistory::items() const
-{
- Q_D(const QWebEngineHistory);
- d->updateItems();
- return d->items;
-}
-
-QList<QWebEngineHistoryItem> QWebEngineHistory::backItems(int maxItems) const
-{
- Q_D(const QWebEngineHistory);
- d->updateItems();
- const int end = currentItemIndex();
- const int start = std::max(0, end - maxItems);
- return d->items.mid(start, end - start);
-}
-
-QList<QWebEngineHistoryItem> QWebEngineHistory::forwardItems(int maxItems) const
-{
- Q_D(const QWebEngineHistory);
- d->updateItems();
- const int start = currentItemIndex() + 1;
- const int end = std::min(count(), start + maxItems);
- return d->items.mid(start, end - start);
-}
-
-bool QWebEngineHistory::canGoBack() const
-{
- Q_D(const QWebEngineHistory);
- return d->page->webContents()->canGoToOffset(-1);
-}
-
-bool QWebEngineHistory::canGoForward() const
-{
- Q_D(const QWebEngineHistory);
- return d->page->webContents()->canGoToOffset(1);
-}
-
-void QWebEngineHistory::back()
-{
- Q_D(const QWebEngineHistory);
- d->page->webContents()->navigateToOffset(-1);
-}
-
-void QWebEngineHistory::forward()
-{
- Q_D(const QWebEngineHistory);
- d->page->webContents()->navigateToOffset(1);
-}
-
-void QWebEngineHistory::goToItem(const QWebEngineHistoryItem &item)
-{
- Q_D(const QWebEngineHistory);
- Q_ASSERT(item.d->page == d->page);
- d->page->webContents()->navigateToIndex(item.d->index);
-}
-
-QWebEngineHistoryItem QWebEngineHistory::backItem() const
-{
- return itemAt(currentItemIndex() - 1);
-}
-
-QWebEngineHistoryItem QWebEngineHistory::currentItem() const
-{
- return itemAt(currentItemIndex());
-}
-
-QWebEngineHistoryItem QWebEngineHistory::forwardItem() const
-{
- return itemAt(currentItemIndex() + 1);
-}
-
-QWebEngineHistoryItem QWebEngineHistory::itemAt(int i) const
-{
- Q_D(const QWebEngineHistory);
- if (i >= 0 && i < count()) {
- d->updateItems();
- return d->items[i];
- } else {
- // Return an invalid item right away.
- QWebEngineHistoryItem item(new QWebEngineHistoryItemPrivate(0, i));
- Q_ASSERT(!item.isValid());
- return item;
- }
-}
-
-int QWebEngineHistory::currentItemIndex() const
-{
- Q_D(const QWebEngineHistory);
- return d->page->webContents()->currentNavigationEntryIndex();
-}
-
-int QWebEngineHistory::count() const
-{
- Q_D(const QWebEngineHistory);
- if (!d->page->webContents()->isInitialized())
- return 0;
- return d->page->webContents()->navigationEntryCount();
-}
-
-QDataStream& operator<<(QDataStream& stream, const QWebEngineHistory& history)
-{
- QtWebEngineCore::WebContentsAdapter *adapter = history.d_func()->page->webContents();
- if (!adapter->isInitialized())
- adapter->loadDefault();
- adapter->serializeNavigationHistory(stream);
- return stream;
-}
-
-QDataStream& operator>>(QDataStream& stream, QWebEngineHistory& history)
-{
- history.d_func()->page->recreateFromSerializedHistory(stream);
- return stream;
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginehistory.h b/src/webenginewidgets/api/qwebenginehistory.h
deleted file mode 100644
index 33d91d523..000000000
--- a/src/webenginewidgets/api/qwebenginehistory.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEHISTORY_H
-#define QWEBENGINEHISTORY_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qdatetime.h>
-#include <QtCore/qshareddata.h>
-#include <QtGui/qicon.h>
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWebEngineHistory;
-class QWebEngineHistoryItemPrivate;
-class QWebEnginePage;
-class QWebEnginePagePrivate;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineHistoryItem {
-public:
- QWebEngineHistoryItem(const QWebEngineHistoryItem &other);
- QWebEngineHistoryItem &operator=(const QWebEngineHistoryItem &other);
- ~QWebEngineHistoryItem();
-
- QUrl originalUrl() const;
- QUrl url() const;
-
- QString title() const;
- QDateTime lastVisited() const;
- QUrl iconUrl() const;
-
- bool isValid() const;
-
- void swap(QWebEngineHistoryItem &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
-
-private:
- QWebEngineHistoryItem(QWebEngineHistoryItemPrivate *priv);
- Q_DECLARE_PRIVATE_D(d.data(), QWebEngineHistoryItem)
- QExplicitlySharedDataPointer<QWebEngineHistoryItemPrivate> d;
- friend class QWebEngineHistory;
- friend class QWebEngineHistoryPrivate;
-};
-
-Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QWebEngineHistoryItem)
-
-class QWebEngineHistoryPrivate;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineHistory {
-public:
- void clear();
-
- QList<QWebEngineHistoryItem> items() const;
- QList<QWebEngineHistoryItem> backItems(int maxItems) const;
- QList<QWebEngineHistoryItem> forwardItems(int maxItems) const;
-
- bool canGoBack() const;
- bool canGoForward() const;
-
- void back();
- void forward();
- void goToItem(const QWebEngineHistoryItem &item);
-
- QWebEngineHistoryItem backItem() const;
- QWebEngineHistoryItem currentItem() const;
- QWebEngineHistoryItem forwardItem() const;
- QWebEngineHistoryItem itemAt(int i) const;
-
- int currentItemIndex() const;
-
- int count() const;
-
-private:
- QWebEngineHistory(QWebEngineHistoryPrivate *d);
- ~QWebEngineHistory();
-
- Q_DISABLE_COPY(QWebEngineHistory)
- Q_DECLARE_PRIVATE(QWebEngineHistory)
- QScopedPointer<QWebEngineHistoryPrivate> d_ptr;
-
- friend QWEBENGINEWIDGETS_EXPORT QDataStream& operator>>(QDataStream&, QWebEngineHistory&);
- friend QWEBENGINEWIDGETS_EXPORT QDataStream& operator<<(QDataStream&, const QWebEngineHistory&);
- friend class QWebEnginePage;
- friend class QWebEnginePagePrivate;
-};
-
-QWEBENGINEWIDGETS_EXPORT QDataStream& operator<<(QDataStream& stream, const QWebEngineHistory& history);
-QWEBENGINEWIDGETS_EXPORT QDataStream& operator>>(QDataStream& stream, QWebEngineHistory& history);
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEHISTORY_H
diff --git a/src/webenginewidgets/api/qwebenginehistory_p.h b/src/webenginewidgets/api/qwebenginehistory_p.h
deleted file mode 100644
index 8f7001967..000000000
--- a/src/webenginewidgets/api/qwebenginehistory_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEHISTORY_P_H
-#define QWEBENGINEHISTORY_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qshareddata.h>
-
-QT_BEGIN_NAMESPACE
-class QWebEnginePagePrivate;
-
-class QWebEngineHistoryItemPrivate : public QSharedData
-{
-public:
- QWebEngineHistoryItemPrivate(QWebEnginePagePrivate *page = 0, int index = 0);
-
- QWebEnginePagePrivate *page;
- int index;
-};
-
-class QWebEngineHistoryPrivate
-{
-public:
- QWebEngineHistoryPrivate(QWebEnginePagePrivate *page);
- ~QWebEngineHistoryPrivate();
- void updateItems() const;
-
- QWebEnginePagePrivate *page;
- mutable QList<QWebEngineHistoryItem> items;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEHISTORY_P_H
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
deleted file mode 100644
index 57aa413b9..000000000
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ /dev/null
@@ -1,2849 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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 "qwebenginepage.h"
-#include "qwebenginepage_p.h"
-
-#include "authentication_dialog_controller.h"
-#include "profile_adapter.h"
-#include "certificate_error_controller.h"
-#include "color_chooser_controller.h"
-#include "favicon_manager.h"
-#include "find_text_helper.h"
-#include "file_picker_controller.h"
-#include "javascript_dialog_controller.h"
-#if QT_CONFIG(webengine_printing_and_pdf)
-#include "printer_worker.h"
-#endif
-#include "qwebenginecertificateerror.h"
-#include "qwebenginefindtextresult.h"
-#include "qwebenginefullscreenrequest.h"
-#include "qwebenginehistory.h"
-#include "qwebenginehistory_p.h"
-#include "qwebenginenotification.h"
-#include "qwebengineprofile.h"
-#include "qwebengineprofile_p.h"
-#include "qwebenginequotarequest.h"
-#include "qwebengineregisterprotocolhandlerrequest.h"
-#include "qwebenginescriptcollection_p.h"
-#include "qwebenginesettings.h"
-#include "qwebengineview.h"
-#include "qwebengineview_p.h"
-#include "user_notification_controller.h"
-#include "render_widget_host_view_qt_delegate_widget.h"
-#include "web_contents_adapter.h"
-#include "web_engine_settings.h"
-#include "qwebenginescript.h"
-
-#include <QAction>
-#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>
-#if QT_CONFIG(webengine_printing_and_pdf)
-#include <QPrinter>
-#include <QThread>
-#endif
-#include <QStandardPaths>
-#include <QStyle>
-#include <QTimer>
-#include <QUrl>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QtWebEngineCore;
-
-static const int MaxTooltipLength = 1024;
-
-static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::WindowOpenDisposition disposition)
-{
- switch (disposition) {
- case WebContentsAdapterClient::NewForegroundTabDisposition:
- return QWebEnginePage::WebBrowserTab;
- case WebContentsAdapterClient::NewBackgroundTabDisposition:
- return QWebEnginePage::WebBrowserBackgroundTab;
- case WebContentsAdapterClient::NewPopupDisposition:
- return QWebEnginePage::WebDialog;
- case WebContentsAdapterClient::NewWindowDisposition:
- return QWebEnginePage::WebBrowserWindow;
- default:
- Q_UNREACHABLE();
- }
-}
-
-QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
- : adapter(QSharedPointer<WebContentsAdapter>::create())
- , history(new QWebEngineHistory(new QWebEngineHistoryPrivate(this)))
- , profile(_profile ? _profile : QWebEngineProfile::defaultProfile())
- , settings(new QWebEngineSettings(profile->settings()))
- , view(0)
- , isLoading(false)
- , scriptCollection(new QWebEngineScriptCollectionPrivate(profileAdapter()->userResourceController(), adapter))
- , m_isBeingAdopted(false)
- , m_backgroundColor(Qt::white)
- , fullscreenMode(false)
- , webChannel(nullptr)
- , webChannelWorldId(QWebEngineScript::MainWorld)
- , defaultAudioMuted(false)
- , defaultZoomFactor(1.0)
-#if QT_CONFIG(webengine_printing_and_pdf)
- , currentPrinter(nullptr)
-#endif
-{
- memset(actions, 0, sizeof(actions));
-
- qRegisterMetaType<QWebEngineQuotaRequest>();
- qRegisterMetaType<QWebEngineRegisterProtocolHandlerRequest>();
- qRegisterMetaType<QWebEngineFindTextResult>();
-
- // See setVisible().
- wasShownTimer.setSingleShot(true);
- QObject::connect(&wasShownTimer, &QTimer::timeout, [this](){
- ensureInitialized();
- });
-
- profile->d_ptr->addWebContentsAdapterClient(this);
-}
-
-QWebEnginePagePrivate::~QWebEnginePagePrivate()
-{
- delete history;
- delete settings;
- profile->d_ptr->removeWebContentsAdapterClient(this);
-}
-
-RenderWidgetHostViewQtDelegate *QWebEnginePagePrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client)
-{
- // Set the QWebEngineView as the parent for a popup delegate, so that the new popup window
- // responds properly to clicks in case the QWebEngineView is inside a modal QDialog. Setting the
- // parent essentially notifies the OS that the popup window is part of the modal session, and
- // should allow interaction.
- // The new delegate will not be deleted by the parent view though, because we unset the parent
- // when the parent is destroyed. The delegate will be destroyed by Chromium when the popup is
- // dismissed.
- return new RenderWidgetHostViewQtDelegateWidget(client, this->view);
-}
-
-void QWebEnginePagePrivate::initializationFinished()
-{
- if (m_backgroundColor != Qt::white)
- 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))
- adapter->setZoomFactor(defaultZoomFactor);
- if (view)
- adapter->setVisible(view->isVisible());
-
- scriptCollection.d->initializationFinished(adapter);
-
- m_isBeingAdopted = false;
-}
-
-void QWebEnginePagePrivate::titleChanged(const QString &title)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->titleChanged(title);
-}
-
-void QWebEnginePagePrivate::urlChanged()
-{
- Q_Q(QWebEnginePage);
- QUrl qurl = adapter->activeUrl();
- if (url != qurl) {
- url = qurl;
- Q_EMIT q->urlChanged(qurl);
- }
-}
-
-void QWebEnginePagePrivate::iconChanged(const QUrl &url)
-{
- Q_Q(QWebEnginePage);
- if (iconUrl == url)
- return;
- iconUrl = url;
- Q_EMIT q->iconUrlChanged(iconUrl);
- Q_EMIT q->iconChanged(adapter->faviconManager()->getIcon());
-}
-
-void QWebEnginePagePrivate::loadProgressChanged(int progress)
-{
- Q_Q(QWebEnginePage);
- QTimer::singleShot(0, q, [q, progress] () { Q_EMIT q->loadProgress(progress); });
-}
-
-void QWebEnginePagePrivate::didUpdateTargetURL(const QUrl &hoveredUrl)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->linkHovered(hoveredUrl.toString());
-}
-
-void QWebEnginePagePrivate::selectionChanged()
-{
- Q_Q(QWebEnginePage);
- QTimer::singleShot(0, q, [this, q]() {
- updateEditActions();
- Q_EMIT q->selectionChanged();
- });
-}
-
-void QWebEnginePagePrivate::recentlyAudibleChanged(bool recentlyAudible)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->recentlyAudibleChanged(recentlyAudible);
-}
-
-void QWebEnginePagePrivate::renderProcessPidChanged(qint64 pid)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->renderProcessPidChanged(pid);
-}
-
-QRectF QWebEnginePagePrivate::viewportRect() const
-{
- return view ? view->rect() : QRectF();
-}
-
-QColor QWebEnginePagePrivate::backgroundColor() const
-{
- return m_backgroundColor;
-}
-
-void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isErrorPage)
-{
- Q_UNUSED(provisionalUrl);
- Q_Q(QWebEnginePage);
-
- if (isErrorPage)
- return;
-
- isLoading = true;
- m_certificateErrorControllers.clear();
- QTimer::singleShot(0, q, &QWebEnginePage::loadStarted);
-}
-
-void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode,
- const QString &errorDescription, bool triggersErrorPage)
-{
- Q_Q(QWebEnginePage);
- Q_UNUSED(url);
- Q_UNUSED(errorCode);
- Q_UNUSED(errorDescription);
-
- if (isErrorPage) {
- QTimer::singleShot(0, q, [q](){
- emit q->loadFinished(false);
- });
- return;
- }
-
- isLoading = false;
- Q_ASSERT((success && !triggersErrorPage) || !success);
- if (!triggersErrorPage) {
- QTimer::singleShot(0, q, [q, success](){
- emit q->loadFinished(success);
- });
- }
-}
-
-void QWebEnginePagePrivate::didPrintPageToPdf(const QString &filePath, bool success)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->pdfPrintingFinished(filePath, success);
-}
-
-void QWebEnginePagePrivate::focusContainer()
-{
- if (view) {
- view->activateWindow();
- view->setFocus();
- }
-}
-
-void QWebEnginePagePrivate::unhandledKeyEvent(QKeyEvent *event)
-{
- if (view && view->parentWidget())
- QGuiApplication::sendEvent(view->parentWidget(), event);
-}
-
-QSharedPointer<WebContentsAdapter>
-QWebEnginePagePrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents,
- WindowOpenDisposition disposition, bool userGesture,
- const QRect &initialGeometry, const QUrl &targetUrl)
-{
- Q_Q(QWebEnginePage);
- Q_UNUSED(userGesture);
- Q_UNUSED(targetUrl);
-
- QWebEnginePage *newPage = q->createWindow(toWindowType(disposition));
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- if (!newPage)
- return nullptr;
-#else
- if (!newPage)
- return adapter;
-#endif
-
- if (!newWebContents->webContents())
- return newPage->d_func()->adapter; // Reuse existing adapter
-
- // Mark the new page as being in the process of being adopted, so that a second mouse move event
- // sent by newWebContents->initialize() gets filtered in RenderWidgetHostViewQt::forwardEvent.
- // The first mouse move event is being sent by q->createWindow(). This is necessary because
- // Chromium does not get a mouse move acknowledgment message between the two events, and
- // InputRouterImpl::ProcessMouseAck is not executed, thus all subsequent mouse move events
- // get coalesced together, and don't get processed at all.
- // The mouse move events are actually sent as a result of show() being called on
- // RenderWidgetHostViewQtDelegateWidget, both when creating the window and when initialize is
- // called.
- newPage->d_func()->m_isBeingAdopted = true;
-
- // Overwrite the new page's WebContents with ours.
- newPage->d_func()->adapter = newWebContents;
- newWebContents->setClient(newPage->d_func());
-
- if (!initialGeometry.isEmpty())
- emit newPage->geometryChangeRequested(initialGeometry);
-
- return newWebContents;
-}
-
-bool QWebEnginePagePrivate::isBeingAdopted()
-{
- return m_isBeingAdopted;
-}
-
-void QWebEnginePagePrivate::close()
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->windowCloseRequested();
-}
-
-void QWebEnginePagePrivate::windowCloseRejected()
-{
- // Do nothing for now.
-}
-
-void QWebEnginePagePrivate::didRunJavaScript(quint64 requestId, const QVariant& result)
-{
- m_callbacks.invoke(requestId, result);
-}
-
-void QWebEnginePagePrivate::didFetchDocumentMarkup(quint64 requestId, const QString& result)
-{
- m_callbacks.invoke(requestId, result);
-}
-
-void QWebEnginePagePrivate::didFetchDocumentInnerText(quint64 requestId, const QString& result)
-{
- m_callbacks.invoke(requestId, result);
-}
-
-void QWebEnginePagePrivate::didPrintPage(quint64 requestId, QSharedPointer<QByteArray> result)
-{
-#if QT_CONFIG(webengine_printing_and_pdf)
- Q_Q(QWebEnginePage);
-
- // If no currentPrinter is set that means that were printing to PDF only.
- if (!currentPrinter) {
- if (!result.data())
- return;
- m_callbacks.invoke(requestId, *(result.data()));
- return;
- }
-
- QThread *printerThread = new QThread;
- QObject::connect(printerThread, &QThread::finished, printerThread, &QThread::deleteLater);
- printerThread->start();
-
- PrinterWorker *printerWorker = new PrinterWorker(result, currentPrinter);
- QObject::connect(printerWorker, &PrinterWorker::resultReady, q, [requestId, this](bool success) {
- currentPrinter = nullptr;
- m_callbacks.invoke(requestId, success);
- });
-
- QObject::connect(printerWorker, &PrinterWorker::resultReady, printerThread, &QThread::quit);
- QObject::connect(printerThread, &QThread::finished, printerWorker, &PrinterWorker::deleteLater);
-
- printerWorker->moveToThread(printerThread);
- QMetaObject::invokeMethod(printerWorker, "print");
-
-#else
- // we should never enter this branch, but just for safe-keeping...
- Q_UNUSED(result);
- m_callbacks.invoke(requestId, QByteArray());
-#endif
-}
-
-bool QWebEnginePagePrivate::passOnFocus(bool reverse)
-{
- if (view)
- return view->focusNextPrevChild(!reverse);
- return false;
-}
-
-void QWebEnginePagePrivate::authenticationRequired(QSharedPointer<AuthenticationDialogController> controller)
-{
- Q_Q(QWebEnginePage);
- QAuthenticator networkAuth;
- networkAuth.setRealm(controller->realm());
-
- if (controller->isProxy())
- Q_EMIT q->proxyAuthenticationRequired(controller->url(), &networkAuth, controller->host());
- else
- Q_EMIT q->authenticationRequired(controller->url(), &networkAuth);
-
- // Authentication has been cancelled
- if (networkAuth.isNull()) {
- controller->reject();
- return;
- }
-
- controller->accept(networkAuth.user(), networkAuth.password());
-}
-
-void QWebEnginePagePrivate::releaseProfile()
-{
- qWarning("Release of profile requested but WebEnginePage still not deleted. Expect troubles !");
- // this is not the way to go, but might avoid the crash if user code does not make any calls to page.
- delete q_ptr->d_ptr.take();
-}
-
-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)));
- QColorDialog::connect(dialog, SIGNAL(rejected()), controller.data(), SLOT(reject()));
-
- // Delete when done
- QColorDialog::connect(dialog, SIGNAL(colorSelected(QColor)), dialog, SLOT(deleteLater()));
- QColorDialog::connect(dialog, SIGNAL(rejected()), dialog, SLOT(deleteLater()));
-
- dialog->open();
-#else
- Q_UNUSED(controller);
-#endif
-}
-
-void QWebEnginePagePrivate::runMediaAccessPermissionRequest(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags requestFlags)
-{
- Q_Q(QWebEnginePage);
- QWebEnginePage::Feature feature;
- if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture) &&
- requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture))
- feature = QWebEnginePage::MediaAudioVideoCapture;
- else if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture))
- feature = QWebEnginePage::MediaAudioCapture;
- else if (requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture))
- feature = QWebEnginePage::MediaVideoCapture;
- else if (requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopAudioCapture) &&
- requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture))
- feature = QWebEnginePage::DesktopAudioVideoCapture;
- else // if (requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture))
- feature = QWebEnginePage::DesktopVideoCapture;
- Q_EMIT q->featurePermissionRequested(securityOrigin, feature);
-}
-
-static QWebEnginePage::Feature toFeature(QtWebEngineCore::ProfileAdapter::PermissionType type)
-{
- switch (type) {
- case QtWebEngineCore::ProfileAdapter::NotificationPermission:
- return QWebEnginePage::Notifications;
- case QtWebEngineCore::ProfileAdapter::GeolocationPermission:
- return QWebEnginePage::Geolocation;
- default:
- break;
- }
- Q_UNREACHABLE();
- return QWebEnginePage::Feature(-1);
-}
-
-void QWebEnginePagePrivate::runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->featurePermissionRequested(securityOrigin, toFeature(permission));
-}
-
-void QWebEnginePagePrivate::runMouseLockPermissionRequest(const QUrl &securityOrigin)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->featurePermissionRequested(securityOrigin, QWebEnginePage::MouseLock);
-}
-
-void QWebEnginePagePrivate::runQuotaRequest(QWebEngineQuotaRequest request)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->quotaRequested(request);
-}
-
-void QWebEnginePagePrivate::runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest request)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->registerProtocolHandlerRequested(request);
-}
-
-QObject *QWebEnginePagePrivate::accessibilityParentObject()
-{
- return view;
-}
-
-void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
-{
-#ifdef QT_NO_ACTION
- Q_UNUSED(action)
-#else
- QAction *a = actions[action];
- if (!a)
- return;
-
- bool enabled = true;
-
- switch (action) {
- case QWebEnginePage::Back:
- enabled = adapter->canGoToOffset(-1);
- break;
- case QWebEnginePage::Forward:
- enabled = adapter->canGoToOffset(1);
- break;
- case QWebEnginePage::Stop:
- enabled = isLoading;
- break;
- case QWebEnginePage::Reload:
- case QWebEnginePage::ReloadAndBypassCache:
- enabled = !isLoading;
- break;
- case QWebEnginePage::ViewSource:
- enabled = adapter->canViewSource();
- break;
- case QWebEnginePage::Cut:
- case QWebEnginePage::Copy:
- case QWebEnginePage::Unselect:
- enabled = adapter->hasFocusedFrame() && !adapter->selectedText().isEmpty();
- break;
- case QWebEnginePage::Paste:
- case QWebEnginePage::Undo:
- case QWebEnginePage::Redo:
- case QWebEnginePage::SelectAll:
- case QWebEnginePage::PasteAndMatchStyle:
- enabled = adapter->hasFocusedFrame();
- break;
- default:
- break;
- }
-
- a->setEnabled(enabled);
-#endif // QT_NO_ACTION
-}
-
-void QWebEnginePagePrivate::updateNavigationActions()
-{
- updateAction(QWebEnginePage::Back);
- updateAction(QWebEnginePage::Forward);
- updateAction(QWebEnginePage::Stop);
- updateAction(QWebEnginePage::Reload);
- updateAction(QWebEnginePage::ReloadAndBypassCache);
- updateAction(QWebEnginePage::ViewSource);
-}
-
-void QWebEnginePagePrivate::updateEditActions()
-{
- updateAction(QWebEnginePage::Cut);
- updateAction(QWebEnginePage::Copy);
- updateAction(QWebEnginePage::Paste);
- updateAction(QWebEnginePage::Undo);
- updateAction(QWebEnginePage::Redo);
- updateAction(QWebEnginePage::SelectAll);
- updateAction(QWebEnginePage::PasteAndMatchStyle);
- updateAction(QWebEnginePage::Unselect);
-}
-
-#ifndef QT_NO_ACTION
-void QWebEnginePagePrivate::_q_webActionTriggered(bool checked)
-{
- Q_Q(QWebEnginePage);
- QAction *a = qobject_cast<QAction *>(q->sender());
- if (!a)
- return;
- QWebEnginePage::WebAction action = static_cast<QWebEnginePage::WebAction>(a->data().toInt());
- q->triggerAction(action, checked);
-}
-#endif // QT_NO_ACTION
-
-void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input)
-{
- QSharedPointer<WebContentsAdapter> newWebContents = WebContentsAdapter::createFromSerializedNavigationHistory(input, this);
- if (newWebContents) {
- adapter = std::move(newWebContents);
- adapter->setClient(this);
- adapter->loadDefault();
- }
-}
-
-void QWebEnginePagePrivate::updateScrollPosition(const QPointF &position)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->scrollPositionChanged(position);
-}
-
-void QWebEnginePagePrivate::updateContentsSize(const QSizeF &size)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->contentsSizeChanged(size);
-}
-
-void QWebEnginePagePrivate::setFullScreenMode(bool fullscreen)
-{
- if (fullscreenMode != fullscreen) {
- fullscreenMode = fullscreen;
- adapter->changedFullScreen();
- }
-}
-
-ProfileAdapter* QWebEnginePagePrivate::profileAdapter()
-{
- return profile->d_ptr->profileAdapter();
-}
-
-WebContentsAdapter *QWebEnginePagePrivate::webContentsAdapter()
-{
- ensureInitialized();
- return adapter.data();
-}
-
-const QObject *QWebEnginePagePrivate::holdingQObject() const
-{
- Q_Q(const QWebEnginePage);
- return q;
-}
-
-void QWebEnginePagePrivate::widgetChanged(RenderWidgetHostViewQtDelegate *newWidgetBase)
-{
- Q_Q(QWebEnginePage);
- bindPageAndWidget(q, static_cast<RenderWidgetHostViewQtDelegateWidget *>(newWidgetBase));
-}
-
-void QWebEnginePagePrivate::findTextFinished(const QWebEngineFindTextResult &result)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->findTextFinished(result);
-}
-
-void QWebEnginePagePrivate::ensureInitialized() const
-{
- if (!adapter->isInitialized())
- adapter->loadDefault();
-}
-
-void QWebEnginePagePrivate::bindPageAndView(QWebEnginePage *page, QWebEngineView *view)
-{
- auto oldView = page ? page->d_func()->view : nullptr;
- auto oldPage = view ? view->d_func()->page : nullptr;
-
- bool ownNewPage = false;
- bool deleteOldPage = false;
-
- // Change pointers first.
-
- if (page && oldView != view) {
- if (oldView) {
- ownNewPage = oldView->d_func()->m_ownsPage;
- oldView->d_func()->page = nullptr;
- oldView->d_func()->m_ownsPage = false;
- }
- page->d_func()->view = view;
- }
-
- if (view && oldPage != page) {
- if (oldPage) {
- if (oldPage->d_func())
- oldPage->d_func()->view = nullptr;
- deleteOldPage = view->d_func()->m_ownsPage;
- }
- view->d_func()->m_ownsPage = ownNewPage;
- view->d_func()->page = page;
- }
-
- // Then notify.
-
- auto widget = page ? page->d_func()->widget : nullptr;
- auto oldWidget = (oldPage && oldPage->d_func()) ? oldPage->d_func()->widget : nullptr;
-
- if (page && oldView != view && oldView) {
- oldView->d_func()->pageChanged(page, nullptr);
- if (widget)
- oldView->d_func()->widgetChanged(widget, nullptr);
- }
-
- if (view && oldPage != page) {
- if (oldPage && oldPage->d_func())
- view->d_func()->pageChanged(oldPage, page);
- else
- view->d_func()->pageChanged(nullptr, page);
- if (oldWidget != widget)
- view->d_func()->widgetChanged(oldWidget, widget);
- }
- if (deleteOldPage)
- delete oldPage;
-}
-
-void QWebEnginePagePrivate::bindPageAndWidget(QWebEnginePage *page, RenderWidgetHostViewQtDelegateWidget *widget)
-{
- auto oldPage = widget ? widget->m_page : nullptr;
- auto oldWidget = page ? page->d_func()->widget : nullptr;
-
- // Change pointers first.
-
- if (widget && oldPage != page) {
- if (oldPage && oldPage->d_func())
- oldPage->d_func()->widget = nullptr;
- widget->m_page = page;
- }
-
- if (page && oldWidget != widget) {
- if (oldWidget)
- oldWidget->m_page = nullptr;
- page->d_func()->widget = widget;
- }
-
- // Then notify.
-
- if (widget && oldPage != page && oldPage && oldPage->d_func()) {
- if (auto oldView = oldPage->d_func()->view)
- oldView->d_func()->widgetChanged(widget, nullptr);
- }
-
- if (page && oldWidget != widget) {
- if (auto view = page->d_func()->view)
- view->d_func()->widgetChanged(oldWidget, widget);
- }
-}
-
-QWebEnginePage::QWebEnginePage(QObject* parent)
- : QObject(parent)
- , d_ptr(new QWebEnginePagePrivate())
-{
- Q_D(QWebEnginePage);
- d->q_ptr = this;
- d->adapter->setClient(d);
-}
-
-/*!
- \fn void QWebEnginePage::findTextFinished(const QWebEngineFindTextResult &result)
- \since 5.14
-
- This signal is emitted when a search string search on a page is completed. \a result is
- the result of the string search.
-
- \sa findText()
-*/
-
-/*!
- \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
-
- This enum describes the status with which the render process terminated:
-
- \value NormalTerminationStatus
- The render process terminated normally.
- \value AbnormalTerminationStatus
- The render process terminated with with a non-zero exit status.
- \value CrashedTerminationStatus
- The render process crashed, for example because of a segmentation fault.
- \value KilledTerminationStatus
- The render process was killed, for example by \c SIGKILL or task manager kill.
-*/
-
-/*!
- \fn QWebEnginePage::renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode)
- \since 5.6
-
- This signal is emitted when the render process is terminated with a non-zero exit status.
- \a terminationStatus is the termination status of the process and \a exitCode is the status code
- with which the process terminated.
-*/
-
-/*!
- \fn QWebEnginePage::fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest)
-
- This signal is emitted when the web page issues the request to enter fullscreen mode for
- a web-element, usually a video element.
-
- The request object \a fullScreenRequest can be used to accept or reject the request.
-
- If the request is accepted the element requesting fullscreen will fill the viewport,
- but it is up to the application to make the view fullscreen or move the page to a view
- that is fullscreen.
-
- \sa QWebEngineSettings::FullScreenSupportEnabled
-*/
-
-/*!
- \fn QWebEnginePage::quotaRequested(QWebEngineQuotaRequest quotaRequest)
- \since 5.11
-
- This signal is emitted when the web page requests larger persistent storage
- than the application's current allocation in File System API. The default quota
- is 0 bytes.
-
- The request object \a quotaRequest can be used to accept or reject the request.
-*/
-
-/*!
- \fn QWebEnginePage::registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request)
- \since 5.11
-
- This signal is emitted when the web page tries to register a custom protocol
- using the \l registerProtocolHandler API.
-
- The request object \a request can be used to accept or reject the request:
-
- \snippet webenginewidgets/simplebrowser/webpage.cpp registerProtocolHandlerRequested
-*/
-
-/*!
- \fn void QWebEnginePage::pdfPrintingFinished(const QString &filePath, bool success)
- \since 5.9
-
- This signal is emitted when printing the web page into a PDF file has
- finished.
- \a filePath will contain the path the file was requested to be created
- at, and \a success will be \c true if the file was successfully created and
- \c false otherwise.
-
- \sa printToPdf()
-*/
-
-/*!
- \property QWebEnginePage::scrollPosition
- \since 5.7
-
- \brief The scroll position of the page contents.
-*/
-
-/*!
- \property QWebEnginePage::contentsSize
- \since 5.7
-
- \brief The size of the page contents.
-*/
-
-/*!
- \fn void QWebEnginePage::audioMutedChanged(bool muted)
- \since 5.7
-
- This signal is emitted when the page's \a muted state changes.
- \note Not to be confused with a specific HTML5 audio or video element being muted.
-*/
-
-/*!
- \fn void QWebEnginePage::recentlyAudibleChanged(bool recentlyAudible);
- \since 5.7
-
- This signal is emitted when the page's audible state, \a recentlyAudible, changes, because
- the audio is played or stopped.
-
- \note The signal is also emitted when calling the setAudioMuted() method.
- Also, if the audio is paused, this signal is emitted with an approximate \b{two-second
- delay}, from the moment the audio is paused.
-*/
-
-/*!
- \fn void QWebEnginePage::renderProcessPidChanged(qint64 pid);
- \since 5.15
-
- This signal is emitted when the underlying render process PID, \a renderProcessPid, changes.
-*/
-
-/*!
- \fn void QWebEnginePage::iconUrlChanged(const QUrl &url)
-
- This signal is emitted when the URL of the icon ("favicon") associated with the
- page is changed. The new URL is specified by \a url.
-
- \sa iconUrl(), icon(), iconChanged()
-*/
-
-/*!
- \fn void QWebEnginePage::iconChanged(const QIcon &icon)
- \since 5.7
-
- This signal is emitted when the icon ("favicon") associated with the
- page is changed. The new icon is specified by \a icon.
-
- \sa icon(), iconUrl(), iconUrlChanged()
-*/
-
-/*!
- Constructs an empty web engine page in the web engine profile \a profile with the parent
- \a parent.
-
- If the profile is not the default profile, the caller must ensure that the profile stays alive
- for as long as the page does.
-
- \since 5.5
-*/
-QWebEnginePage::QWebEnginePage(QWebEngineProfile *profile, QObject* parent)
- : QObject(parent)
- , d_ptr(new QWebEnginePagePrivate(profile))
-{
- Q_D(QWebEnginePage);
- d->q_ptr = this;
- d->adapter->setClient(d);
-}
-
-QWebEnginePage::~QWebEnginePage()
-{
- if (d_ptr) {
- // d_ptr might be exceptionally null if profile adapter got deleted first
- setDevToolsPage(nullptr);
- QWebEnginePagePrivate::bindPageAndView(this, nullptr);
- QWebEnginePagePrivate::bindPageAndWidget(this, nullptr);
- }
-}
-
-QWebEngineHistory *QWebEnginePage::history() const
-{
- Q_D(const QWebEnginePage);
- return d->history;
-}
-
-QWebEngineSettings *QWebEnginePage::settings() const
-{
- Q_D(const QWebEnginePage);
- return d->settings;
-}
-
-/*!
- * Returns a pointer to the web channel instance used by this page or a null pointer if none was set.
- * This channel automatically uses the internal web engine transport mechanism over Chromium IPC
- * that is exposed in the JavaScript context of this page as \c qt.webChannelTransport.
- *
- * \since 5.5
- * \sa setWebChannel()
- */
-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;
-}
-
-/*!
- * \overload
- *
- * Sets the web channel instance to be used by this page to \a channel and installs
- * it in the main JavaScript world.
- *
- * With this method the web channel can be accessed by web page content. If the content
- * is not under your control and might be hostile, this could be a security issue and
- * you should consider installing it in a private JavaScript world.
- *
- * \since 5.5
- * \sa QWebEngineScript::MainWorld
- */
-
-void QWebEnginePage::setWebChannel(QWebChannel *channel)
-{
- setWebChannel(channel, QWebEngineScript::MainWorld);
-}
-
-/*!
- * Sets the web channel instance to be used by this page to \a channel and connects it to
- * web engine's transport using Chromium IPC messages. The transport is exposed in the JavaScript
- * world \a worldId as
- * \c qt.webChannelTransport, which should be used when using the \l{Qt WebChannel JavaScript API}.
- *
- * \note The page does not take ownership of the channel object.
- * \note Only one web channel can be installed per page, setting one even in another JavaScript
- * world uninstalls any already installed web channel.
- *
- * \since 5.7
- * \sa QWebEngineScript::ScriptWorldId
- */
-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
-}
-
-/*!
- \property QWebEnginePage::backgroundColor
- \brief The page's background color behind the document's body.
- \since 5.6
-
- You can set the background color to Qt::transparent or to a translucent
- color to see through the document, or you can set it to match your
- web content in a hybrid application to prevent the white flashes that may appear
- during loading.
-
- The default value is white.
-*/
-QColor QWebEnginePage::backgroundColor() const
-{
- Q_D(const QWebEnginePage);
- return d->m_backgroundColor;
-}
-
-void QWebEnginePage::setBackgroundColor(const QColor &color)
-{
- Q_D(QWebEnginePage);
- if (d->m_backgroundColor == color)
- return;
- d->m_backgroundColor = color;
- d->adapter->setBackgroundColor(color);
-}
-
-/*!
- * Save the currently loaded web page to disk.
- *
- * The web page is saved to \a filePath in the specified \a{format}.
- *
- * This is a short cut for the following actions:
- * \list
- * \li Trigger the Save web action.
- * \li Accept the next download item and set the specified file path and save format.
- * \endlist
- *
- * This function issues an asynchronous download request for the web page and returns immediately.
- *
- * \sa QWebEngineDownloadItem::SavePageFormat
- * \since 5.8
- */
-void QWebEnginePage::save(const QString &filePath,
- QWebEngineDownloadItem::SavePageFormat format) const
-{
- Q_D(const QWebEnginePage);
- d->ensureInitialized();
- d->adapter->save(filePath, format);
-}
-
-/*!
- \property QWebEnginePage::audioMuted
- \brief Whether the current page audio is muted.
- \since 5.7
-
- The default value is \c false.
- \sa recentlyAudible
-*/
-bool QWebEnginePage::isAudioMuted() const {
- Q_D(const QWebEnginePage);
- if (d->adapter->isInitialized())
- return d->adapter->isAudioMuted();
- return d->defaultAudioMuted;
-}
-
-void QWebEnginePage::setAudioMuted(bool muted) {
- Q_D(QWebEnginePage);
- bool wasAudioMuted = isAudioMuted();
- d->defaultAudioMuted = muted;
- d->adapter->setAudioMuted(muted);
- if (wasAudioMuted != isAudioMuted())
- Q_EMIT audioMutedChanged(muted);
-}
-
-/*!
- \property QWebEnginePage::recentlyAudible
- \brief The current page's \e {audible state}, that is, whether audio was recently played
- or not.
- \since 5.7
-
- The default value is \c false.
- \sa audioMuted
-*/
-bool QWebEnginePage::recentlyAudible() const
-{
- Q_D(const QWebEnginePage);
- return d->adapter->isInitialized() && d->adapter->recentlyAudible();
-}
-
-/*!
- \property QWebEnginePage::renderProcessPid
- \brief The process ID (PID) of the render process assigned to the current
- page's main frame.
- \since 5.15
-
- If no render process is available yet, \c 0 is returned.
-*/
-qint64 QWebEnginePage::renderProcessPid() const
-{
- Q_D(const QWebEnginePage);
- return d->adapter->renderProcessPid();
-}
-
-void QWebEnginePage::setView(QWidget *newViewBase)
-{
- QWebEnginePagePrivate::bindPageAndView(this, qobject_cast<QWebEngineView *>(newViewBase));
-}
-
-QWidget *QWebEnginePage::view() const
-{
- Q_D(const QWebEnginePage);
- return d->view;
-}
-
-/*!
- Returns the web engine profile the page belongs to.
- \since 5.5
-*/
-QWebEngineProfile *QWebEnginePage::profile() const
-{
- Q_D(const QWebEnginePage);
- return d->profile;
-}
-
-bool QWebEnginePage::hasSelection() const
-{
- return !selectedText().isEmpty();
-}
-
-QString QWebEnginePage::selectedText() const
-{
- Q_D(const QWebEnginePage);
- return d->adapter->selectedText();
-}
-
-#ifndef QT_NO_ACTION
-QAction *QWebEnginePage::action(WebAction action) const
-{
- Q_D(const QWebEnginePage);
- if (action == QWebEnginePage::NoWebAction)
- return 0;
- if (d->actions[action])
- return d->actions[action];
-
- QString text;
- QIcon icon;
- QStyle *style = d->view ? d->view->style() : qApp->style();
-
- switch (action) {
- case Back:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Back);
- icon = style->standardIcon(QStyle::SP_ArrowBack);
- break;
- case Forward:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Forward);
- icon = style->standardIcon(QStyle::SP_ArrowForward);
- break;
- case Stop:
- text = tr("Stop");
- icon = style->standardIcon(QStyle::SP_BrowserStop);
- break;
- case Reload:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Reload);
- icon = style->standardIcon(QStyle::SP_BrowserReload);
- break;
- case ReloadAndBypassCache:
- text = tr("Reload and Bypass Cache");
- icon = style->standardIcon(QStyle::SP_BrowserReload);
- break;
- case Cut:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Cut);
- break;
- case Copy:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Copy);
- break;
- case Paste:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Paste);
- break;
- case Undo:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Undo);
- break;
- case Redo:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Redo);
- break;
- case SelectAll:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::SelectAll);
- break;
- case PasteAndMatchStyle:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::PasteAndMatchStyle);
- break;
- case OpenLinkInThisWindow:
- text = tr("Open link in this window");
- break;
- case OpenLinkInNewWindow:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::OpenLinkInNewWindow);
- break;
- case OpenLinkInNewTab:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::OpenLinkInNewTab);
- break;
- case OpenLinkInNewBackgroundTab:
- text = tr("Open link in new background tab");
- break;
- case CopyLinkToClipboard:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::CopyLinkToClipboard);
- break;
- case DownloadLinkToDisk:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::DownloadLinkToDisk);
- break;
- case CopyImageToClipboard:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::CopyImageToClipboard);
- break;
- case CopyImageUrlToClipboard:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::CopyImageUrlToClipboard);
- break;
- case DownloadImageToDisk:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::DownloadImageToDisk);
- break;
- case CopyMediaUrlToClipboard:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::CopyMediaUrlToClipboard);
- break;
- case ToggleMediaControls:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::ToggleMediaControls);
- break;
- case ToggleMediaLoop:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::ToggleMediaLoop);
- break;
- case ToggleMediaPlayPause:
- text = tr("Toggle Play/Pause");
- break;
- case ToggleMediaMute:
- text = tr("Toggle Mute");
- break;
- case DownloadMediaToDisk:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::DownloadMediaToDisk);
- break;
- case InspectElement:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::InspectElement);
- break;
- case ExitFullScreen:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::ExitFullScreen);
- break;
- case RequestClose:
- text = tr("Close Page");
- break;
- case Unselect:
- text = tr("Unselect");
- break;
- case SavePage:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::SavePage);
- break;
- case ViewSource:
- text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::ViewSource);
- break;
- case ToggleBold:
- text = tr("&Bold");
- break;
- case ToggleItalic:
- text = tr("&Italic");
- break;
- case ToggleUnderline:
- text = tr("&Underline");
- break;
- case ToggleStrikethrough:
- text = tr("&Strikethrough");
- break;
- case AlignLeft:
- text = tr("Align &Left");
- break;
- case AlignCenter:
- text = tr("Align &Center");
- break;
- case AlignRight:
- text = tr("Align &Right");
- break;
- case AlignJustified:
- text = tr("Align &Justified");
- break;
- case Indent:
- text = tr("&Indent");
- break;
- case Outdent:
- text = tr("&Outdent");
- break;
- case InsertOrderedList:
- text = tr("Insert &Ordered List");
- break;
- case InsertUnorderedList:
- text = tr("Insert &Unordered List");
- break;
- case NoWebAction:
- case WebActionCount:
- Q_UNREACHABLE();
- break;
- }
-
- QAction *a = new QAction(const_cast<QWebEnginePage*>(this));
- a->setText(text);
- a->setData(action);
- a->setIcon(icon);
-
- connect(a, SIGNAL(triggered(bool)), this, SLOT(_q_webActionTriggered(bool)));
-
- d->actions[action] = a;
- d->updateAction(action);
- return a;
-}
-#endif // QT_NO_ACTION
-
-void QWebEnginePage::triggerAction(WebAction action, bool)
-{
- Q_D(QWebEnginePage);
- d->ensureInitialized();
- const QtWebEngineCore::WebEngineContextMenuData *menuData = d->contextData.d;
- switch (action) {
- case Back:
- d->adapter->navigateBack();
- break;
- case Forward:
- d->adapter->navigateForward();
- break;
- case Stop:
- d->adapter->stop();
- break;
- case Reload:
- d->adapter->reload();
- break;
- case ReloadAndBypassCache:
- d->adapter->reloadAndBypassCache();
- break;
- case Cut:
- d->adapter->cut();
- break;
- case Copy:
- d->adapter->copy();
- break;
- case Paste:
- d->adapter->paste();
- break;
- case Undo:
- d->adapter->undo();
- break;
- case Redo:
- d->adapter->redo();
- break;
- case SelectAll:
- d->adapter->selectAll();
- break;
- case PasteAndMatchStyle:
- d->adapter->pasteAndMatchStyle();
- break;
- case Unselect:
- d->adapter->unselect();
- break;
- case OpenLinkInThisWindow:
- if (menuData && menuData->linkUrl().isValid())
- setUrl(menuData->linkUrl());
- break;
- case OpenLinkInNewWindow:
- if (menuData && menuData->linkUrl().isValid()) {
- QWebEnginePage *newPage = createWindow(WebBrowserWindow);
- if (newPage)
- newPage->setUrl(menuData->linkUrl());
- }
- break;
- case OpenLinkInNewTab:
- if (menuData && menuData->linkUrl().isValid()) {
- QWebEnginePage *newPage = createWindow(WebBrowserTab);
- if (newPage)
- newPage->setUrl(menuData->linkUrl());
- }
- break;
- case OpenLinkInNewBackgroundTab:
- if (menuData && menuData->linkUrl().isValid()) {
- QWebEnginePage *newPage = createWindow(WebBrowserBackgroundTab);
- if (newPage)
- newPage->setUrl(menuData->linkUrl());
- }
- break;
- case CopyLinkToClipboard:
- if (menuData && !menuData->unfilteredLinkUrl().isEmpty()) {
- QString urlString = menuData->unfilteredLinkUrl().toString(QUrl::FullyEncoded);
- QString linkText = menuData->linkText().toHtmlEscaped();
- QString title = menuData->titleText();
- if (!title.isEmpty())
- title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
- QMimeData *data = new QMimeData();
- data->setText(urlString);
- QString html = QStringLiteral("<a href=\"") + urlString + QStringLiteral("\"") + title + QStringLiteral(">")
- + linkText + QStringLiteral("</a>");
- data->setHtml(html);
- data->setUrls(QList<QUrl>() << menuData->unfilteredLinkUrl());
- qApp->clipboard()->setMimeData(data);
- }
- break;
- case DownloadLinkToDisk:
- if (menuData && menuData->linkUrl().isValid())
- d->adapter->download(menuData->linkUrl(), menuData->suggestedFileName(),
- menuData->referrerUrl(), menuData->referrerPolicy());
-
- break;
- case CopyImageToClipboard:
- if (menuData && menuData->hasImageContent() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeImage ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeCanvas))
- {
- d->adapter->copyImageAt(menuData->position());
- }
- break;
- case CopyImageUrlToClipboard:
- if (menuData && menuData->mediaUrl().isValid() && menuData->mediaType() == WebEngineContextMenuData::MediaTypeImage) {
- QString urlString = menuData->mediaUrl().toString(QUrl::FullyEncoded);
- QString alt = menuData->altText();
- if (!alt.isEmpty())
- alt = QStringLiteral(" alt=\"%1\"").arg(alt.toHtmlEscaped());
- QString title = menuData->titleText();
- if (!title.isEmpty())
- title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
- QMimeData *data = new QMimeData();
- data->setText(urlString);
- QString html = QStringLiteral("<img src=\"") + urlString + QStringLiteral("\"") + title + alt + QStringLiteral("></img>");
- data->setHtml(html);
- data->setUrls(QList<QUrl>() << menuData->mediaUrl());
- qApp->clipboard()->setMimeData(data);
- }
- break;
- case DownloadImageToDisk:
- case DownloadMediaToDisk:
- if (menuData && menuData->mediaUrl().isValid())
- d->adapter->download(menuData->mediaUrl(), menuData->suggestedFileName(),
- menuData->referrerUrl(), menuData->referrerPolicy());
- break;
- case CopyMediaUrlToClipboard:
- if (menuData && menuData->mediaUrl().isValid() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- QString urlString = menuData->mediaUrl().toString(QUrl::FullyEncoded);
- QString title = menuData->titleText();
- if (!title.isEmpty())
- title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
- QMimeData *data = new QMimeData();
- data->setText(urlString);
- if (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio)
- data->setHtml(QStringLiteral("<audio src=\"") + urlString + QStringLiteral("\"") + title +
- QStringLiteral("></audio>"));
- else
- data->setHtml(QStringLiteral("<video src=\"") + urlString + QStringLiteral("\"") + title +
- QStringLiteral("></video>"));
- data->setUrls(QList<QUrl>() << menuData->mediaUrl());
- qApp->clipboard()->setMimeData(data);
- }
- break;
- case ToggleMediaControls:
- if (menuData && menuData->mediaUrl().isValid() && menuData->mediaFlags() & WebEngineContextMenuData::MediaCanToggleControls) {
- bool enable = !(menuData->mediaFlags() & WebEngineContextMenuData::MediaControls);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerControls, enable);
- }
- break;
- case ToggleMediaLoop:
- if (menuData && menuData->mediaUrl().isValid() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- bool enable = !(menuData->mediaFlags() & WebEngineContextMenuData::MediaLoop);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerLoop, enable);
- }
- break;
- case ToggleMediaPlayPause:
- if (menuData && menuData->mediaUrl().isValid() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- bool enable = (menuData->mediaFlags() & WebEngineContextMenuData::MediaPaused);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerPlay, enable);
- }
- break;
- case ToggleMediaMute:
- if (menuData && menuData->mediaUrl().isValid() && menuData->mediaFlags() & WebEngineContextMenuData::MediaHasAudio) {
- // Make sure to negate the value, so that toggling actually works.
- bool enable = !(menuData->mediaFlags() & WebEngineContextMenuData::MediaMuted);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerMute, enable);
- }
- break;
- case InspectElement:
- if (menuData)
- d->adapter->inspectElementAt(menuData->position());
- break;
- case ExitFullScreen:
- // See under ViewSource, anything that can trigger a delete of the current view is dangerous to call directly here.
- QTimer::singleShot(0, this, [d](){ d->adapter->exitFullScreen(); });
- break;
- case RequestClose:
- d->adapter->requestClose();
- break;
- case SavePage:
- d->adapter->save();
- break;
- case ViewSource:
- // This is a workaround to make the ViewSource action working in a context menu.
- // The WebContentsAdapter::viewSource() method deletes a
- // RenderWidgetHostViewQtDelegateWidget instance which passes the control to the event
- // loop. If the QMenu::aboutToHide() signal is connected to the QObject::deleteLater()
- // slot the QMenu is deleted by the event handler while the ViewSource action is still not
- // completed. This may lead to a crash. To avoid this the WebContentsAdapter::viewSource()
- // method is called indirectly via the QTimer::singleShot() function which schedules the
- // the viewSource() call after the QMenu's destruction.
- QTimer::singleShot(0, this, [d](){ d->adapter->viewSource(); });
- break;
- case ToggleBold:
- runJavaScript(QStringLiteral("document.execCommand('bold');"), QWebEngineScript::ApplicationWorld);
- break;
- case ToggleItalic:
- runJavaScript(QStringLiteral("document.execCommand('italic');"), QWebEngineScript::ApplicationWorld);
- break;
- case ToggleUnderline:
- runJavaScript(QStringLiteral("document.execCommand('underline');"), QWebEngineScript::ApplicationWorld);
- break;
- case ToggleStrikethrough:
- runJavaScript(QStringLiteral("document.execCommand('strikethrough');"), QWebEngineScript::ApplicationWorld);
- break;
- case AlignLeft:
- runJavaScript(QStringLiteral("document.execCommand('justifyLeft');"), QWebEngineScript::ApplicationWorld);
- break;
- case AlignCenter:
- runJavaScript(QStringLiteral("document.execCommand('justifyCenter');"), QWebEngineScript::ApplicationWorld);
- break;
- case AlignRight:
- runJavaScript(QStringLiteral("document.execCommand('justifyRight');"), QWebEngineScript::ApplicationWorld);
- break;
- case AlignJustified:
- runJavaScript(QStringLiteral("document.execCommand('justifyFull');"), QWebEngineScript::ApplicationWorld);
- break;
- case Indent:
- runJavaScript(QStringLiteral("document.execCommand('indent');"), QWebEngineScript::ApplicationWorld);
- break;
- case Outdent:
- runJavaScript(QStringLiteral("document.execCommand('outdent');"), QWebEngineScript::ApplicationWorld);
- break;
- case InsertOrderedList:
- runJavaScript(QStringLiteral("document.execCommand('insertOrderedList');"), QWebEngineScript::ApplicationWorld);
- break;
- case InsertUnorderedList:
- runJavaScript(QStringLiteral("document.execCommand('insertUnorderedList');"), QWebEngineScript::ApplicationWorld);
- break;
- case NoWebAction:
- break;
- case WebActionCount:
- Q_UNREACHABLE();
- break;
- }
-}
-
-/*!
- * \since 5.8
- * Replace the current misspelled word with \a replacement.
- *
- * The current misspelled word can be found in QWebEngineContextMenuData::misspelledWord(),
- * and suggested replacements in QWebEngineContextMenuData::spellCheckerSuggestions().
- *
- * \sa contextMenuData(),
- */
-
-void QWebEnginePage::replaceMisspelledWord(const QString &replacement)
-{
- Q_D(QWebEnginePage);
- d->adapter->replaceMisspelling(replacement);
-}
-
-void QWebEnginePage::findText(const QString &subString, FindFlags options, const QWebEngineCallback<bool> &resultCallback)
-{
- Q_D(QWebEnginePage);
- if (!d->adapter->isInitialized()) {
- QtWebEngineCore::CallbackDirectory().invokeEmpty(resultCallback);
- return;
- }
-
- d->adapter->findTextHelper()->startFinding(subString, options & FindCaseSensitively, options & FindBackward, resultCallback);
-}
-
-/*!
- * \reimp
- */
-bool QWebEnginePage::event(QEvent *e)
-{
- return QObject::event(e);
-}
-
-void QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData &data)
-{
-#if QT_CONFIG(action)
- if (!view)
- return;
-
- contextData.reset();
- switch (view->contextMenuPolicy()) {
- case Qt::DefaultContextMenu:
- {
- contextData = data;
- QContextMenuEvent event(QContextMenuEvent::Mouse, data.position(), view->mapToGlobal(data.position()));
- view->contextMenuEvent(&event);
- return;
- }
- case Qt::CustomContextMenu:
- contextData = data;
- Q_EMIT view->customContextMenuRequested(data.position());
- return;
- case Qt::ActionsContextMenu:
- if (view->actions().count()) {
- QContextMenuEvent event(QContextMenuEvent::Mouse, data.position(), view->mapToGlobal(data.position()));
- QMenu::exec(view->actions(), event.globalPos(), 0, view);
- }
- return;
- case Qt::PreventContextMenu:
- case Qt::NoContextMenu:
- return;
- }
-
- Q_UNREACHABLE();
-#else
- Q_UNUSED(data);
-#endif // QT_CONFIG(action)
-}
-
-void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame)
-{
- Q_Q(QWebEnginePage);
- bool accepted = q->acceptNavigationRequest(url, static_cast<QWebEnginePage::NavigationType>(navigationType), isMainFrame);
- if (accepted && adapter->findTextHelper()->isFindTextInProgress())
- adapter->findTextHelper()->stopFinding();
- navigationRequestAction = accepted ? WebContentsAdapterClient::AcceptRequest : WebContentsAdapterClient::IgnoreRequest;
-}
-
-void QWebEnginePagePrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen)
-{
- Q_Q(QWebEnginePage);
- QWebEngineFullScreenRequest request(q, origin, fullscreen);
- Q_EMIT q->fullScreenRequested(request);
-}
-
-bool QWebEnginePagePrivate::isFullScreenMode() const
-{
- return fullscreenMode;
-}
-
-void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> controller)
-{
- Q_Q(QWebEnginePage);
- bool accepted = false;
- QString promptResult;
- switch (controller->type()) {
- case AlertDialog:
- q->javaScriptAlert(controller->securityOrigin(), controller->message());
- accepted = true;
- break;
- case ConfirmDialog:
- accepted = q->javaScriptConfirm(controller->securityOrigin(), controller->message());
- break;
- case PromptDialog:
- accepted = q->javaScriptPrompt(controller->securityOrigin(), controller->message(), controller->defaultPrompt(), &promptResult);
- if (accepted)
- controller->textProvided(promptResult);
- break;
- case UnloadDialog:
- 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)
- controller->accept();
- else
- controller->reject();
-}
-
-void QWebEnginePagePrivate::allowCertificateError(const QSharedPointer<CertificateErrorController> &controller)
-{
- Q_Q(QWebEnginePage);
- bool accepted = false;
-
- QWebEngineCertificateError error(controller);
- accepted = q->certificateError(error);
- if (error.deferred() && !error.answered())
- m_certificateErrorControllers.append(controller);
- else if (!error.answered())
- controller->accept(error.isOverridable() && accepted);
-}
-
-void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller)
-{
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
- Q_Q(QWebEnginePage);
- QWebEngineClientCertificateSelection certSelection(controller);
-
- Q_EMIT q->selectClientCertificate(certSelection);
-#else
- Q_UNUSED(controller);
-#endif
-}
-
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-/*!
- \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);
- q->javaScriptConsoleMessage(static_cast<QWebEnginePage::JavaScriptConsoleMessageLevel>(level), message, lineNumber, sourceID);
-}
-
-void QWebEnginePagePrivate::renderProcessTerminated(RenderProcessTerminationStatus terminationStatus,
- int exitCode)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->renderProcessTerminated(static_cast<QWebEnginePage::RenderProcessTerminationStatus>(
- terminationStatus), exitCode);
-}
-
-void QWebEnginePagePrivate::requestGeometryChange(const QRect &geometry, const QRect &frameGeometry)
-{
- Q_UNUSED(geometry);
- Q_Q(QWebEnginePage);
- Q_EMIT q->geometryChangeRequested(frameGeometry);
-}
-
-void QWebEnginePagePrivate::startDragging(const content::DropData &dropData,
- Qt::DropActions allowedActions, const QPixmap &pixmap,
- const QPoint &offset)
-{
-#if !QT_CONFIG(draganddrop)
- Q_UNUSED(dropData);
- Q_UNUSED(allowedActions);
- Q_UNUSED(pixmap);
- Q_UNUSED(offset);
-#else
- adapter->startDragging(view, dropData, allowedActions, pixmap, offset);
-#endif // QT_CONFIG(draganddrop)
-}
-
-bool QWebEnginePagePrivate::supportsDragging() const
-{
- return true;
-}
-
-bool QWebEnginePagePrivate::isEnabled() const
-{
- const Q_Q(QWebEnginePage);
- const QWidget *view = q->view();
- if (view)
- return view->isEnabled();
- return true;
-}
-
-void QWebEnginePagePrivate::setToolTip(const QString &toolTipText)
-{
- if (!view)
- return;
-
- // Hide tooltip if shown.
- if (toolTipText.isEmpty()) {
- if (!view->toolTip().isEmpty())
- view->setToolTip(QString());
-
- return;
- }
-
- // Update tooltip if text was changed.
- QString wrappedTip = QLatin1String("<p style=\"white-space:pre-wrap\">")
- % toolTipText.toHtmlEscaped().left(MaxTooltipLength)
- % QLatin1String("</p>");
- if (view->toolTip() != wrappedTip)
- view->setToolTip(wrappedTip);
-}
-
-void QWebEnginePagePrivate::printRequested()
-{
- Q_Q(QWebEnginePage);
- QTimer::singleShot(0, q, [q](){
- Q_EMIT q->printRequested();
- });
-}
-
-void QWebEnginePagePrivate::lifecycleStateChanged(LifecycleState state)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->lifecycleStateChanged(static_cast<QWebEnginePage::LifecycleState>(state));
-}
-
-void QWebEnginePagePrivate::recommendedStateChanged(LifecycleState state)
-{
- Q_Q(QWebEnginePage);
- QTimer::singleShot(0, q, [q, state]() {
- Q_EMIT q->recommendedStateChanged(static_cast<QWebEnginePage::LifecycleState>(state));
- });
-}
-
-void QWebEnginePagePrivate::visibleChanged(bool visible)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->visibleChanged(visible);
-}
-
-/*!
- \since 5.13
-
- Registers the request interceptor \a interceptor to intercept URL requests.
-
- The page does not take ownership of the pointer. This interceptor is called
- after any interceptors on the profile, and unlike profile interceptors, only
- URL requests from this page are intercepted.
-
- To unset the request interceptor, set a \c nullptr.
-
- \sa QWebEngineUrlRequestInfo, QWebEngineProfile::setUrlRequestInterceptor()
-*/
-
-void QWebEnginePage::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
-{
- Q_D(QWebEnginePage);
- d->adapter->setRequestInterceptor(interceptor);
-}
-
-#if QT_CONFIG(menu)
-QMenu *QWebEnginePage::createStandardContextMenu()
-{
- Q_D(QWebEnginePage);
- if (!d->contextData.d)
- return nullptr;
- d->ensureInitialized();
-
- QMenu *menu = new QMenu(d->view);
- const WebEngineContextMenuData &contextMenuData = *d->contextData.d;
-
- QContextMenuBuilder contextMenuBuilder(contextMenuData, this, menu);
-
- contextMenuBuilder.initMenu();
-
- menu->setAttribute(Qt::WA_DeleteOnClose, true);
-
- return menu;
-}
-#endif // QT_CONFIG(menu)
-
-void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEnginePage::Feature feature, QWebEnginePage::PermissionPolicy policy)
-{
- Q_D(QWebEnginePage);
- if (policy == PermissionUnknown) {
- switch (feature) {
- case MediaAudioVideoCapture:
- case MediaAudioCapture:
- case MediaVideoCapture:
- case DesktopAudioVideoCapture:
- case DesktopVideoCapture:
- case MouseLock:
- break;
- case Geolocation:
- d->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::GeolocationPermission, ProfileAdapter::AskPermission);
- break;
- case Notifications:
- d->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::NotificationPermission, ProfileAdapter::AskPermission);
- break;
- }
- return;
- }
-
- const WebContentsAdapterClient::MediaRequestFlags audioVideoCaptureFlags(
- WebContentsAdapterClient::MediaVideoCapture |
- WebContentsAdapterClient::MediaAudioCapture);
- const WebContentsAdapterClient::MediaRequestFlags desktopAudioVideoCaptureFlags(
- WebContentsAdapterClient::MediaDesktopVideoCapture |
- WebContentsAdapterClient::MediaDesktopAudioCapture);
-
- if (policy == PermissionGrantedByUser) {
- switch (feature) {
- case MediaAudioVideoCapture:
- d->adapter->grantMediaAccessPermission(securityOrigin, audioVideoCaptureFlags);
- break;
- case MediaAudioCapture:
- d->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaAudioCapture);
- break;
- case MediaVideoCapture:
- d->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaVideoCapture);
- break;
- case DesktopAudioVideoCapture:
- d->adapter->grantMediaAccessPermission(securityOrigin, desktopAudioVideoCaptureFlags);
- break;
- case DesktopVideoCapture:
- d->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaDesktopVideoCapture);
- break;
- case MouseLock:
- d->adapter->grantMouseLockPermission(securityOrigin, true);
- break;
- case Geolocation:
- d->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::GeolocationPermission, ProfileAdapter::AllowedPermission);
- break;
- case Notifications:
- d->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::NotificationPermission, ProfileAdapter::AllowedPermission);
- break;
- }
- } else { // if (policy == PermissionDeniedByUser)
- switch (feature) {
- case MediaAudioVideoCapture:
- case MediaAudioCapture:
- case MediaVideoCapture:
- case DesktopAudioVideoCapture:
- case DesktopVideoCapture:
- d->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaNone);
- break;
- case Geolocation:
- d->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::GeolocationPermission, ProfileAdapter::DeniedPermission);
- break;
- case MouseLock:
- d->adapter->grantMouseLockPermission(securityOrigin, false);
- break;
- case Notifications:
- d->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::NotificationPermission, ProfileAdapter::DeniedPermission);
- break;
- }
- }
-}
-
-static inline QWebEnginePage::FileSelectionMode toPublic(FilePickerController::FileChooserMode mode)
-{
- // Should the underlying values change, we'll need a switch here.
- return static_cast<QWebEnginePage::FileSelectionMode>(mode);
-}
-
-void QWebEnginePagePrivate::runFileChooser(QSharedPointer<FilePickerController> controller)
-{
- Q_Q(QWebEnginePage);
-
- QStringList selectedFileNames = q->chooseFiles(toPublic(controller->mode()), (QStringList() << controller->defaultFileName()), controller->acceptedMimeTypes());
-
- if (!selectedFileNames.empty())
- controller->accepted(selectedFileNames);
- else
- controller->rejected();
-}
-
-WebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const
-{
- return settings->d_func();
-}
-
-/*!
- \since 5.10
- Downloads the resource from the location given by \a url to a local file.
-
- If \a filename is given, it is used as the suggested file name.
- If it is relative, the file is saved in the standard download location with
- the given name.
- If it is a null or empty QString, the default file name is used.
-
- This will emit QWebEngineProfile::downloadRequested() after the download
- has started.
-*/
-
-void QWebEnginePage::download(const QUrl& url, const QString& filename)
-{
- Q_D(QWebEnginePage);
- d->ensureInitialized();
- d->adapter->download(url, filename);
-}
-
-void QWebEnginePage::load(const QUrl& url)
-{
- Q_D(QWebEnginePage);
- d->adapter->load(url);
-}
-
-/*!
- \since 5.9
- Issues the specified \a request and loads the response.
-
- \sa load(), setUrl(), url(), urlChanged(), QUrl::fromUserInput()
-*/
-void QWebEnginePage::load(const QWebEngineHttpRequest& request)
-{
- Q_D(QWebEnginePage);
- d->adapter->load(request);
-}
-
-void QWebEnginePage::toHtml(const QWebEngineCallback<const QString &> &resultCallback) const
-{
- Q_D(const QWebEnginePage);
- d->ensureInitialized();
- quint64 requestId = d->adapter->fetchDocumentMarkup();
- d->m_callbacks.registerCallback(requestId, resultCallback);
-}
-
-void QWebEnginePage::toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const
-{
- Q_D(const QWebEnginePage);
- d->ensureInitialized();
- quint64 requestId = d->adapter->fetchDocumentInnerText();
- d->m_callbacks.registerCallback(requestId, resultCallback);
-}
-
-void QWebEnginePage::setHtml(const QString &html, const QUrl &baseUrl)
-{
- setContent(html.toUtf8(), QStringLiteral("text/html;charset=UTF-8"), baseUrl);
-}
-
-void QWebEnginePage::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
-{
- Q_D(QWebEnginePage);
- d->adapter->setContent(data, mimeType, baseUrl);
-}
-
-QString QWebEnginePage::title() const
-{
- Q_D(const QWebEnginePage);
- return d->adapter->pageTitle();
-}
-
-void QWebEnginePage::setUrl(const QUrl &url)
-{
- Q_D(QWebEnginePage);
- if (d->url != url) {
- d->url = url;
- emit urlChanged(url);
- }
- load(url);
-}
-
-QUrl QWebEnginePage::url() const
-{
- Q_D(const QWebEnginePage);
- return d->url;
-}
-
-QUrl QWebEnginePage::requestedUrl() const
-{
- Q_D(const QWebEnginePage);
- return d->adapter->requestedUrl();
-}
-
-/*!
- \property QWebEnginePage::iconUrl
- \brief The URL of the icon associated with the page currently viewed.
-
- By default, this property contains an empty URL.
-
- \sa iconUrlChanged(), icon(), iconChanged()
-*/
-QUrl QWebEnginePage::iconUrl() const
-{
- Q_D(const QWebEnginePage);
- return d->iconUrl;
-}
-
-/*!
- \property QWebEnginePage::icon
- \brief The icon associated with the page currently viewed.
- \since 5.7
-
- By default, this property contains a null icon. If the web page specifies more than one icon,
- the \c{icon} property encapsulates the available candidate icons in a single,
- scalable \c{QIcon}.
-
- \sa iconChanged(), iconUrl(), iconUrlChanged()
-*/
-QIcon QWebEnginePage::icon() const
-{
- Q_D(const QWebEnginePage);
-
- if (d->iconUrl.isEmpty() || !d->adapter->isInitialized())
- return QIcon();
-
- return d->adapter->faviconManager()->getIcon();
-}
-
-qreal QWebEnginePage::zoomFactor() const
-{
- Q_D(const QWebEnginePage);
- if (d->adapter->isInitialized())
- return d->adapter->currentZoomFactor();
- return d->defaultZoomFactor;
-}
-
-void QWebEnginePage::setZoomFactor(qreal factor)
-{
- Q_D(QWebEnginePage);
- d->defaultZoomFactor = factor;
- if (d->adapter->isInitialized())
- d->adapter->setZoomFactor(factor);
-}
-
-void QWebEnginePage::runJavaScript(const QString &scriptSource)
-{
- Q_D(QWebEnginePage);
- d->ensureInitialized();
- if (d->adapter->lifecycleState() == WebContentsAdapter::LifecycleState::Discarded) {
- qWarning("runJavaScript: disabled in Discarded state");
- return;
- }
- d->adapter->runJavaScript(scriptSource, QWebEngineScript::MainWorld);
-}
-
-void QWebEnginePage::runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)
-{
- Q_D(QWebEnginePage);
- d->ensureInitialized();
- if (d->adapter->lifecycleState() == WebContentsAdapter::LifecycleState::Discarded) {
- qWarning("runJavaScript: disabled in Discarded state");
- d->m_callbacks.invokeEmpty(resultCallback);
- return;
- }
- quint64 requestId = d->adapter->runJavaScriptCallbackResult(scriptSource, QWebEngineScript::MainWorld);
- d->m_callbacks.registerCallback(requestId, resultCallback);
-}
-
-void QWebEnginePage::runJavaScript(const QString &scriptSource, quint32 worldId)
-{
- Q_D(QWebEnginePage);
- d->ensureInitialized();
- d->adapter->runJavaScript(scriptSource, worldId);
-}
-
-void QWebEnginePage::runJavaScript(const QString& scriptSource, quint32 worldId, const QWebEngineCallback<const QVariant &> &resultCallback)
-{
- Q_D(QWebEnginePage);
- d->ensureInitialized();
- quint64 requestId = d->adapter->runJavaScriptCallbackResult(scriptSource, worldId);
- d->m_callbacks.registerCallback(requestId, resultCallback);
-}
-
-/*!
- Returns the collection of scripts that are injected into the page.
-
- In addition, a page might also execute scripts
- added through QWebEngineProfile::scripts().
-
- \sa QWebEngineScriptCollection, QWebEngineScript, {Script Injection}
-*/
-
-QWebEngineScriptCollection &QWebEnginePage::scripts()
-{
- Q_D(QWebEnginePage);
- return d->scriptCollection;
-}
-
-QWebEnginePage *QWebEnginePage::createWindow(WebWindowType type)
-{
- Q_D(QWebEnginePage);
- if (d->view) {
- QWebEngineView *newView = d->view->createWindow(type);
- if (newView)
- return newView->page();
- }
- return nullptr;
-}
-
-/*!
- \since 5.11
- Returns the page this page is inspecting, if any.
-
- Returns \c nullptr if this page is not a developer tools page.
-
- \sa setInspectedPage(), devToolsPage()
-*/
-
-QWebEnginePage *QWebEnginePage::inspectedPage() const
-{
- Q_D(const QWebEnginePage);
- return d->inspectedPage;
-}
-
-/*!
- \since 5.11
- Navigates this page to an internal URL that is the developer
- tools of \a page.
-
- This is the same as calling setDevToolsPage() on \a page
- with \c this as argument.
-
- \sa inspectedPage(), setDevToolsPage()
-*/
-
-void QWebEnginePage::setInspectedPage(QWebEnginePage *page)
-{
- Q_D(QWebEnginePage);
- if (d->inspectedPage == page)
- return;
- QWebEnginePage *oldPage = d->inspectedPage;
- d->inspectedPage = nullptr;
- if (oldPage)
- oldPage->setDevToolsPage(nullptr);
- d->inspectedPage = page;
- if (page)
- page->setDevToolsPage(this);
-}
-
-/*!
- \since 5.11
- Returns the page that is hosting the developer tools
- of this page, if any.
-
- Returns \c nullptr if no developer tools page is set.
-
- \sa setDevToolsPage(), inspectedPage()
-*/
-
-QWebEnginePage *QWebEnginePage::devToolsPage() const
-{
- Q_D(const QWebEnginePage);
- return d->devToolsPage;
-}
-
-/*!
- \since 5.11
- Binds \a devToolsPage to be the developer tools of this page.
- Triggers \a devToolsPage to navigate to an internal URL
- with the developer tools.
-
- This is the same as calling setInspectedPage() on \a devToolsPage
- with \c this as argument.
-
- \sa devToolsPage(), setInspectedPage()
-*/
-
-void QWebEnginePage::setDevToolsPage(QWebEnginePage *devToolsPage)
-{
- Q_D(QWebEnginePage);
- if (d->devToolsPage == devToolsPage)
- return;
- d->ensureInitialized();
- QWebEnginePage *oldDevTools = d->devToolsPage;
- d->devToolsPage = nullptr;
- if (oldDevTools)
- oldDevTools->setInspectedPage(nullptr);
- d->devToolsPage = devToolsPage;
- if (devToolsPage)
- devToolsPage->setInspectedPage(this);
- if (d->adapter) {
- if (devToolsPage)
- d->adapter->openDevToolsFrontend(devToolsPage->d_ptr->adapter);
- else
- d->adapter->closeDevToolsFrontend();
- }
-}
-
-ASSERT_ENUMS_MATCH(FilePickerController::Open, QWebEnginePage::FileSelectOpen)
-ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, QWebEnginePage::FileSelectOpenMultiple)
-
-QStringList QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)
-{
-#if QT_CONFIG(filedialog)
- const QStringList &filter = FilePickerController::nameFilters(acceptedMimeTypes);
- QStringList ret;
- QString str;
- switch (static_cast<FilePickerController::FileChooserMode>(mode)) {
- case FilePickerController::OpenMultiple:
- ret = QFileDialog::getOpenFileNames(view(), QString(), QString(), filter.join(QStringLiteral(";;")), nullptr, QFileDialog::HideNameFilterDetails);
- break;
- // Chromium extension, not exposed as part of the public API for now.
- case FilePickerController::UploadFolder:
- str = QFileDialog::getExistingDirectory(view(), tr("Select folder to upload"));
- if (!str.isNull())
- ret << str;
- break;
- case FilePickerController::Save:
- str = QFileDialog::getSaveFileName(view(), QString(), (QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + oldFiles.first()));
- if (!str.isNull())
- ret << str;
- break;
- case FilePickerController::Open:
- str = QFileDialog::getOpenFileName(view(), QString(), oldFiles.first(), filter.join(QStringLiteral(";;")), nullptr, QFileDialog::HideNameFilterDetails);
- if (!str.isNull())
- ret << str;
- 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.toHtmlEscaped());
-#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.toHtmlEscaped(),
- 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.toHtmlEscaped(),
- QLineEdit::Normal,
- defaultValue.toHtmlEscaped(),
- &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)
-{
- static QLoggingCategory loggingCategory("js", QtWarningMsg);
- static QByteArray file = sourceID.toUtf8();
- QMessageLogger logger(file.constData(), lineNumber, nullptr, loggingCategory.categoryName());
-
- switch (level) {
- case JavaScriptConsoleMessageLevel::InfoMessageLevel:
- if (loggingCategory.isInfoEnabled())
- logger.info().noquote() << message;
- break;
- case JavaScriptConsoleMessageLevel::WarningMessageLevel:
- if (loggingCategory.isWarningEnabled())
- logger.warning().noquote() << message;
- break;
- case JavaScriptConsoleMessageLevel::ErrorMessageLevel:
- if (loggingCategory.isCriticalEnabled())
- logger.critical().noquote() << message;
- break;
- }
-}
-
-bool QWebEnginePage::certificateError(const QWebEngineCertificateError &)
-{
- return false;
-}
-
-bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
-{
- Q_UNUSED(url);
- Q_UNUSED(type);
- Q_UNUSED(isMainFrame);
- return true;
-}
-
-QPointF QWebEnginePage::scrollPosition() const
-{
- Q_D(const QWebEnginePage);
- return d->adapter->lastScrollOffset();
-}
-
-QSizeF QWebEnginePage::contentsSize() const
-{
- Q_D(const QWebEnginePage);
- return d->adapter->lastContentsSize();
-}
-
-/*!
- Renders the current content of the page into a PDF document and saves it
- in the location specified in \a filePath.
- The page size and orientation of the produced PDF document are taken from
- the values specified in \a pageLayout.
-
- This method issues an asynchronous request for printing the web page into
- a PDF and returns immediately.
- To be informed about the result of the request, connect to the signal
- pdfPrintingFinished().
-
- If a file already exists at the provided file path, it will be overwritten.
- \since 5.7
- \sa pdfPrintingFinished()
-*/
-void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &pageLayout)
-{
-#if QT_CONFIG(webengine_printing_and_pdf)
- Q_D(const QWebEnginePage);
- if (d->currentPrinter) {
- qWarning("Cannot print to PDF while at the same time printing on printer %ls", qUtf16Printable(d->currentPrinter->printerName()));
- return;
- }
- d->ensureInitialized();
- d->adapter->printToPDF(pageLayout, filePath);
-#else
- Q_UNUSED(filePath);
- Q_UNUSED(pageLayout);
-#endif
-}
-
-
-/*!
- Renders the current content of the page into a PDF document and returns a byte array containing the PDF data
- as parameter to \a resultCallback.
- The page size and orientation of the produced PDF document are taken from the values specified in \a pageLayout.
-
- The \a resultCallback must take a const reference to a QByteArray as parameter. If printing was successful, this byte array
- will contain the PDF data, otherwise, the byte array will be empty.
-
- \warning We guarantee that the callback (\a resultCallback) is always called, but it might be done
- during page destruction. When QWebEnginePage is deleted, the callback is triggered with an invalid
- value and it is not safe to use the corresponding QWebEnginePage or QWebEngineView instance inside it.
-
- \since 5.7
-*/
-void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &resultCallback, const QPageLayout &pageLayout)
-{
- Q_D(QWebEnginePage);
-#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;
- }
- d->ensureInitialized();
- quint64 requestId = d->adapter->printToPDFCallbackResult(pageLayout);
- d->m_callbacks.registerCallback(requestId, resultCallback);
-#else
- Q_UNUSED(pageLayout);
- d->m_callbacks.invokeEmpty(resultCallback);
-#endif
-}
-
-/*!
- Renders the current content of the page into a temporary PDF document, then prints it using \a printer.
-
- The settings for creating and printing the PDF document will be retrieved from the \a printer
- object.
- It is the users responsibility to ensure the \a printer remains valid until \a resultCallback
- has been called.
-
- \note Printing runs on the browser process, which is by default not sandboxed.
-
- The \a resultCallback must take a boolean as parameter. If printing was successful, this
- boolean will have the value \c true, otherwise, its value will be \c false.
-
- \warning We guarantee that the callback (\a resultCallback) is always called, but it might be done
- during page destruction. When QWebEnginePage is deleted, the callback is triggered with an invalid
- value and it is not safe to use the corresponding QWebEnginePage or QWebEngineView instance inside it.
-
- \since 5.8
-*/
-void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback)
-{
- Q_D(QWebEnginePage);
-#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;
- d->ensureInitialized();
- quint64 requestId = d->adapter->printToPDFCallbackResult(printer->pageLayout(),
- printer->colorMode() == QPrinter::Color,
- false);
- d->m_callbacks.registerCallback(requestId, resultCallback);
-#else
- Q_UNUSED(printer);
- d->m_callbacks.invokeDirectly(resultCallback, false);
-#endif
-}
-
-/*!
- \since 5.7
-
- Returns additional data about the current context menu. It is only guaranteed to be valid during the call to the QWebEngineView::contextMenuEvent()
- handler of the associated QWebEngineView.
-
- \sa createStandardContextMenu()
-*/
-const QWebEngineContextMenuData &QWebEnginePage::contextMenuData() const
-{
- Q_D(const QWebEnginePage);
- return d->contextData;
-}
-
-/*!
- \enum QWebEnginePage::LifecycleState
- \since 5.14
-
- This enum describes the lifecycle state of the page:
-
- \value Active
- Normal state.
- \value Frozen
- Low CPU usage state where most HTML task sources are suspended.
- \value Discarded
- Very low resource usage state where the entire browsing context is discarded.
-
- \sa lifecycleState, {Page Lifecycle API}, {WebEngine Lifecycle Example}
-*/
-
-/*!
- \property QWebEnginePage::lifecycleState
- \since 5.14
-
- \brief The current lifecycle state of the page.
-
- The following restrictions are enforced by the setter:
-
- \list
- \li A \l{visible} page must remain in the \c{Active} state.
- \li If the page is being inspected by a \l{devToolsPage} then both pages must
- remain in the \c{Active} states.
- \li A page in the \c{Discarded} state can only transition to the \c{Active}
- state. This will cause a reload of the page.
- \endlist
-
- These are the only hard limits on the lifecycle state, but see also
- \l{recommendedState} for the recommended soft limits.
-
- \sa recommendedState, {Page Lifecycle API}, {WebEngine Lifecycle Example}
-*/
-
-QWebEnginePage::LifecycleState QWebEnginePage::lifecycleState() const
-{
- Q_D(const QWebEnginePage);
- return static_cast<LifecycleState>(d->adapter->lifecycleState());
-}
-
-void QWebEnginePage::setLifecycleState(LifecycleState state)
-{
- Q_D(QWebEnginePage);
- d->adapter->setLifecycleState(static_cast<WebContentsAdapterClient::LifecycleState>(state));
-}
-
-/*!
- \property QWebEnginePage::recommendedState
- \since 5.14
-
- \brief The recommended limit for the lifecycle state of the page.
-
- Setting the lifecycle state to a lower resource usage state than the
- recommended state may cause side-effects such as stopping background audio
- playback or loss of HTML form input. Setting the lifecycle state to a higher
- resource state is however completely safe.
-
- \sa lifecycleState, {Page Lifecycle API}, {WebEngine Lifecycle Example}
-*/
-
-QWebEnginePage::LifecycleState QWebEnginePage::recommendedState() const
-{
- Q_D(const QWebEnginePage);
- return static_cast<LifecycleState>(d->adapter->recommendedState());
-}
-
-/*!
- \property QWebEnginePage::visible
- \since 5.14
-
- \brief Whether the page is considered visible in the Page Visibility API.
-
- Setting this property changes the \c{Document.hidden} and the
- \c{Document.visibilityState} properties in JavaScript which web sites can use
- to voluntarily reduce their resource usage if they are not visible to the
- user.
-
- If the page is connected to a \l{view} then this property will be managed
- automatically by the view according to it's own visibility.
-
- \sa lifecycleState
-*/
-
-bool QWebEnginePage::isVisible() const
-{
- Q_D(const QWebEnginePage);
- return d->adapter->isVisible();
-}
-
-void QWebEnginePage::setVisible(bool visible)
-{
- Q_D(QWebEnginePage);
-
- if (!d->adapter->isInitialized()) {
- // On the one hand, it is too early to initialize here. The application
- // may call show() before load(), or it may call show() from
- // createWindow(), and then we would create an unnecessary blank
- // WebContents here. On the other hand, if the application calls show()
- // then it expects something to be shown, so we have to initialize.
- // Therefore we have to delay the initialization via the event loop.
- if (visible)
- d->wasShownTimer.start();
- else
- d->wasShownTimer.stop();
- return;
- }
-
- d->adapter->setVisible(visible);
-}
-
-#if QT_CONFIG(action)
-QContextMenuBuilder::QContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data,
- QWebEnginePage *page,
- QMenu *menu)
- : QtWebEngineCore::RenderViewContextMenuQt(data)
- , m_page(page)
- , m_menu(menu)
-{
-}
-
-bool QContextMenuBuilder::hasInspector()
-{
- return m_page->d_ptr->adapter->hasInspector();
-}
-
-bool QContextMenuBuilder::isFullScreenMode()
-{
- return m_page->d_ptr->isFullScreenMode();
-}
-
-void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem)
-{
- QPointer<QWebEnginePage> thisRef(m_page);
- QAction *action = 0;
-
- switch (menuItem) {
- case ContextMenuItem::Back:
- action = thisRef->action(QWebEnginePage::Back);
- break;
- case ContextMenuItem::Forward:
- action = thisRef->action(QWebEnginePage::Forward);
- break;
- case ContextMenuItem::Reload:
- action = thisRef->action(QWebEnginePage::Reload);
- break;
- case ContextMenuItem::Cut:
- action = thisRef->action(QWebEnginePage::Cut);
- break;
- case ContextMenuItem::Copy:
- action = thisRef->action(QWebEnginePage::Copy);
- break;
- case ContextMenuItem::Paste:
- action = thisRef->action(QWebEnginePage::Paste);
- break;
- case ContextMenuItem::Undo:
- action = thisRef->action(QWebEnginePage::Undo);
- break;
- case ContextMenuItem::Redo:
- action = thisRef->action(QWebEnginePage::Redo);
- break;
- case ContextMenuItem::SelectAll:
- action = thisRef->action(QWebEnginePage::SelectAll);
- break;
- case ContextMenuItem::PasteAndMatchStyle:
- action = thisRef->action(QWebEnginePage::PasteAndMatchStyle);
- break;
- case ContextMenuItem::OpenLinkInNewWindow:
- action = thisRef->action(QWebEnginePage::OpenLinkInNewWindow);
- break;
- case ContextMenuItem::OpenLinkInNewTab:
- action = thisRef->action(QWebEnginePage::OpenLinkInNewTab);
- break;
- case ContextMenuItem::CopyLinkToClipboard:
- action = thisRef->action(QWebEnginePage::CopyLinkToClipboard);
- break;
- case ContextMenuItem::DownloadLinkToDisk:
- action = thisRef->action(QWebEnginePage::DownloadLinkToDisk);
- break;
- case ContextMenuItem::CopyImageToClipboard:
- action = thisRef->action(QWebEnginePage::CopyImageToClipboard);
- break;
- case ContextMenuItem::CopyImageUrlToClipboard:
- action = thisRef->action(QWebEnginePage::CopyImageUrlToClipboard);
- break;
- case ContextMenuItem::DownloadImageToDisk:
- action = thisRef->action(QWebEnginePage::DownloadImageToDisk);
- break;
- case ContextMenuItem::CopyMediaUrlToClipboard:
- action = thisRef->action(QWebEnginePage::CopyMediaUrlToClipboard);
- break;
- case ContextMenuItem::ToggleMediaControls:
- action = thisRef->action(QWebEnginePage::ToggleMediaControls);
- break;
- case ContextMenuItem::ToggleMediaLoop:
- action = thisRef->action(QWebEnginePage::ToggleMediaLoop);
- break;
- case ContextMenuItem::DownloadMediaToDisk:
- action = thisRef->action(QWebEnginePage::DownloadMediaToDisk);
- break;
- case ContextMenuItem::InspectElement:
- action = thisRef->action(QWebEnginePage::InspectElement);
- break;
- case ContextMenuItem::ExitFullScreen:
- action = thisRef->action(QWebEnginePage::ExitFullScreen);
- break;
- case ContextMenuItem::SavePage:
- action = thisRef->action(QWebEnginePage::SavePage);
- break;
- case ContextMenuItem::ViewSource:
- action = thisRef->action(QWebEnginePage::ViewSource);
- break;
- case ContextMenuItem::SpellingSuggestions:
- for (int i=0; i < m_contextData.spellCheckerSuggestions().count() && i < 4; i++) {
- action = new QAction(m_menu);
- QString replacement = m_contextData.spellCheckerSuggestions().at(i);
- QObject::connect(action, &QAction::triggered, [thisRef, replacement] { if (thisRef) thisRef->replaceMisspelledWord(replacement); });
- action->setText(replacement);
- m_menu->addAction(action);
- }
- return;
- case ContextMenuItem::Separator:
- if (!m_menu->isEmpty())
- m_menu->addSeparator();
- return;
- }
- action->setEnabled(isMenuItemEnabled(menuItem));
- m_menu->addAction(action);
-}
-
-bool QContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem)
-{
- switch (menuItem) {
- case ContextMenuItem::Back:
- return m_page->d_ptr->adapter->canGoBack();
- case ContextMenuItem::Forward:
- return m_page->d_ptr->adapter->canGoForward();
- case ContextMenuItem::Reload:
- return true;
- case ContextMenuItem::Cut:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanCut;
- case ContextMenuItem::Copy:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanCopy;
- case ContextMenuItem::Paste:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanPaste;
- case ContextMenuItem::Undo:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanUndo;
- case ContextMenuItem::Redo:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanRedo;
- case ContextMenuItem::SelectAll:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanSelectAll;
- case ContextMenuItem::PasteAndMatchStyle:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanPaste;
- case ContextMenuItem::OpenLinkInNewWindow:
- case ContextMenuItem::OpenLinkInNewTab:
- case ContextMenuItem::CopyLinkToClipboard:
- case ContextMenuItem::DownloadLinkToDisk:
- case ContextMenuItem::CopyImageToClipboard:
- case ContextMenuItem::CopyImageUrlToClipboard:
- case ContextMenuItem::DownloadImageToDisk:
- case ContextMenuItem::CopyMediaUrlToClipboard:
- case ContextMenuItem::ToggleMediaControls:
- case ContextMenuItem::ToggleMediaLoop:
- case ContextMenuItem::DownloadMediaToDisk:
- case ContextMenuItem::InspectElement:
- case ContextMenuItem::ExitFullScreen:
- case ContextMenuItem::SavePage:
- return true;
- case ContextMenuItem::ViewSource:
- return m_page->d_ptr->adapter->canViewSource();
- case ContextMenuItem::SpellingSuggestions:
- case ContextMenuItem::Separator:
- return true;
- }
- Q_UNREACHABLE();
-}
-#endif // QT_CONFIG(action)
-
-QT_END_NAMESPACE
-
-#include "moc_qwebenginepage.cpp"
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
deleted file mode 100644
index 3bf79526d..000000000
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ /dev/null
@@ -1,409 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEPAGE_H
-#define QWEBENGINEPAGE_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtWebEngineWidgets/qwebengineclientcertificateselection.h>
-#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
-#include <QtWebEngineCore/qwebenginecallback.h>
-#include <QtWebEngineCore/qwebenginehttprequest.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qvariant.h>
-#include <QtGui/qpagelayout.h>
-#include <QtNetwork/qnetworkaccessmanager.h>
-#include <QtWidgets/qwidget.h>
-
-QT_BEGIN_NAMESPACE
-class QMenu;
-class QPrinter;
-
-class QContextMenuBuilder;
-class QWebChannel;
-class QWebEngineCertificateError;
-class QWebEngineClientCertificateSelection;
-class QWebEngineContextMenuData;
-class QWebEngineFindTextResult;
-class QWebEngineFullScreenRequest;
-class QWebEngineHistory;
-class QWebEnginePage;
-class QWebEnginePagePrivate;
-class QWebEngineProfile;
-class QWebEngineQuotaRequest;
-class QWebEngineRegisterProtocolHandlerRequest;
-class QWebEngineScriptCollection;
-class QWebEngineSettings;
-class QWebEngineUrlRequestInterceptor;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject {
- Q_OBJECT
- Q_PROPERTY(QString selectedText READ selectedText)
- Q_PROPERTY(bool hasSelection READ hasSelection)
- Q_PROPERTY(QUrl requestedUrl READ requestedUrl)
- Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
- Q_PROPERTY(QString title READ title)
- Q_PROPERTY(QUrl url READ url WRITE setUrl)
- Q_PROPERTY(QUrl iconUrl READ iconUrl NOTIFY iconUrlChanged)
- Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
- Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
- Q_PROPERTY(QSizeF contentsSize READ contentsSize NOTIFY contentsSizeChanged)
- Q_PROPERTY(QPointF scrollPosition READ scrollPosition NOTIFY scrollPositionChanged)
- Q_PROPERTY(bool audioMuted READ isAudioMuted WRITE setAudioMuted NOTIFY audioMutedChanged)
- Q_PROPERTY(bool recentlyAudible READ recentlyAudible NOTIFY recentlyAudibleChanged)
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
- Q_PROPERTY(LifecycleState lifecycleState READ lifecycleState WRITE setLifecycleState NOTIFY lifecycleStateChanged)
- Q_PROPERTY(LifecycleState recommendedState READ recommendedState NOTIFY recommendedStateChanged)
- Q_PROPERTY(qint64 renderProcessPid READ renderProcessPid NOTIFY renderProcessPidChanged)
-
-public:
- enum WebAction {
- NoWebAction = - 1,
- Back,
- Forward,
- Stop,
- Reload,
-
- Cut,
- Copy,
- Paste,
-
- Undo,
- Redo,
- SelectAll,
- ReloadAndBypassCache,
-
- PasteAndMatchStyle,
-
- OpenLinkInThisWindow,
- OpenLinkInNewWindow,
- OpenLinkInNewTab,
- CopyLinkToClipboard,
- DownloadLinkToDisk,
-
- CopyImageToClipboard,
- CopyImageUrlToClipboard,
- DownloadImageToDisk,
-
- CopyMediaUrlToClipboard,
- ToggleMediaControls,
- ToggleMediaLoop,
- ToggleMediaPlayPause,
- ToggleMediaMute,
- DownloadMediaToDisk,
-
- InspectElement,
- ExitFullScreen,
- RequestClose,
- Unselect,
- SavePage,
- OpenLinkInNewBackgroundTab,
- ViewSource,
-
- ToggleBold,
- ToggleItalic,
- ToggleUnderline,
- ToggleStrikethrough,
-
- AlignLeft,
- AlignCenter,
- AlignRight,
- AlignJustified,
- Indent,
- Outdent,
-
- InsertOrderedList,
- InsertUnorderedList,
-
- WebActionCount
- };
- Q_ENUM(WebAction)
-
- enum FindFlag {
- FindBackward = 1,
- FindCaseSensitively = 2,
- };
- Q_DECLARE_FLAGS(FindFlags, FindFlag)
-
- enum WebWindowType {
- WebBrowserWindow,
- WebBrowserTab,
- WebDialog,
- WebBrowserBackgroundTab
- };
- Q_ENUM(WebWindowType)
-
- enum PermissionPolicy {
- PermissionUnknown,
- PermissionGrantedByUser,
- PermissionDeniedByUser
- };
- Q_ENUM(PermissionPolicy)
-
- // must match WebContentsAdapterClient::NavigationType
- enum NavigationType {
- NavigationTypeLinkClicked,
- NavigationTypeTyped,
- NavigationTypeFormSubmitted,
- NavigationTypeBackForward,
- NavigationTypeReload,
- NavigationTypeOther,
- NavigationTypeRedirect,
- };
- Q_ENUM(NavigationType)
-
- enum Feature {
- Notifications = 0,
- Geolocation = 1,
- MediaAudioCapture = 2,
- MediaVideoCapture,
- MediaAudioVideoCapture,
- MouseLock,
- DesktopVideoCapture,
- DesktopAudioVideoCapture
- };
- Q_ENUM(Feature)
-
- // Ex-QWebFrame enum
-
- enum FileSelectionMode {
- FileSelectOpen,
- FileSelectOpenMultiple,
- };
- Q_ENUM(FileSelectionMode)
-
- // must match WebContentsAdapterClient::JavaScriptConsoleMessageLevel
- enum JavaScriptConsoleMessageLevel {
- InfoMessageLevel = 0,
- WarningMessageLevel,
- ErrorMessageLevel
- };
- Q_ENUM(JavaScriptConsoleMessageLevel)
-
- // must match WebContentsAdapterClient::RenderProcessTerminationStatus
- enum RenderProcessTerminationStatus {
- NormalTerminationStatus = 0,
- AbnormalTerminationStatus,
- CrashedTerminationStatus,
- KilledTerminationStatus
- };
- Q_ENUM(RenderProcessTerminationStatus)
-
- // must match WebContentsAdapterClient::LifecycleState
- enum class LifecycleState {
- Active,
- Frozen,
- Discarded,
- };
- Q_ENUM(LifecycleState)
-
- explicit QWebEnginePage(QObject *parent = Q_NULLPTR);
- QWebEnginePage(QWebEngineProfile *profile, QObject *parent = Q_NULLPTR);
- ~QWebEnginePage();
- QWebEngineHistory *history() const;
-
- void setView(QWidget *view);
- QWidget *view() const;
-
- bool hasSelection() const;
- QString selectedText() const;
-
- QWebEngineProfile *profile() const;
-
-#ifndef QT_NO_ACTION
- QAction *action(WebAction action) const;
-#endif
- virtual void triggerAction(WebAction action, bool checked = false);
-
- void replaceMisspelledWord(const QString &replacement);
-
- bool event(QEvent*) override;
-
- 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);
-
- void load(const QUrl &url);
- void load(const QWebEngineHttpRequest &request);
- void download(const QUrl &url, const QString &filename = QString());
- void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
- void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
-
- void toHtml(const QWebEngineCallback<const QString &> &resultCallback) const;
- void toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const;
-
- QString title() const;
- void setUrl(const QUrl &url);
- QUrl url() const;
- QUrl requestedUrl() const;
- QUrl iconUrl() const;
- QIcon icon() const;
-
- qreal zoomFactor() const;
- void setZoomFactor(qreal factor);
-
- QPointF scrollPosition() const;
- QSizeF contentsSize() const;
-
- void runJavaScript(const QString& scriptSource);
- void runJavaScript(const QString& scriptSource, quint32 worldId);
- void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback);
- void runJavaScript(const QString& scriptSource, quint32 worldId, const QWebEngineCallback<const QVariant &> &resultCallback);
- QWebEngineScriptCollection &scripts();
- QWebEngineSettings *settings() const;
-
- QWebChannel *webChannel() const;
- void setWebChannel(QWebChannel *);
- void setWebChannel(QWebChannel *, uint worldId);
- QColor backgroundColor() const;
- void setBackgroundColor(const QColor &color);
-
- void save(const QString &filePath, QWebEngineDownloadItem::SavePageFormat format
- = QWebEngineDownloadItem::MimeHtmlSaveFormat) const;
-
- bool isAudioMuted() const;
- void setAudioMuted(bool muted);
- bool recentlyAudible() const;
- qint64 renderProcessPid() const;
-
- void printToPdf(const QString &filePath, const QPageLayout &layout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()));
- void printToPdf(const QWebEngineCallback<const QByteArray&> &resultCallback, const QPageLayout &layout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()));
- void print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback);
-
- void setInspectedPage(QWebEnginePage *page);
- QWebEnginePage *inspectedPage() const;
- void setDevToolsPage(QWebEnginePage *page);
- QWebEnginePage *devToolsPage() const;
-
- void setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
-
- const QWebEngineContextMenuData &contextMenuData() const;
-
- LifecycleState lifecycleState() const;
- void setLifecycleState(LifecycleState state);
-
- LifecycleState recommendedState() const;
-
- bool isVisible() const;
- void setVisible(bool visible);
-
-Q_SIGNALS:
- void loadStarted();
- void loadProgress(int progress);
- void loadFinished(bool ok);
-
- void linkHovered(const QString &url);
- void selectionChanged();
- void geometryChangeRequested(const QRect& geom);
- void windowCloseRequested();
-
- void featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature);
- void featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature);
- void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
- void quotaRequested(QWebEngineQuotaRequest quotaRequest);
- void registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request);
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
- void selectClientCertificate(QWebEngineClientCertificateSelection clientCertSelection);
-#endif
-
- void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator);
- void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost);
-
- void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode);
-
- // Ex-QWebFrame signals
- void titleChanged(const QString &title);
- void urlChanged(const QUrl &url);
- void iconUrlChanged(const QUrl &url);
- void iconChanged(const QIcon &icon);
-
- void scrollPositionChanged(const QPointF &position);
- void contentsSizeChanged(const QSizeF &size);
- void audioMutedChanged(bool muted);
- void recentlyAudibleChanged(bool recentlyAudible);
- void renderProcessPidChanged(qint64 pid);
-
- void pdfPrintingFinished(const QString &filePath, bool success);
- void printRequested();
-
- void visibleChanged(bool visible);
-
- void lifecycleStateChanged(LifecycleState state);
- void recommendedStateChanged(LifecycleState state);
-
- void findTextFinished(const QWebEngineFindTextResult &result);
-
-protected:
- virtual QWebEnginePage *createWindow(WebWindowType type);
- virtual QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes);
- virtual void javaScriptAlert(const QUrl &securityOrigin, const QString& msg);
- virtual bool javaScriptConfirm(const QUrl &securityOrigin, const QString& msg);
- virtual bool javaScriptPrompt(const QUrl &securityOrigin, const QString& msg, const QString& defaultValue, QString* result);
- virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID);
- virtual bool certificateError(const QWebEngineCertificateError &certificateError);
- virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
-
-private:
- Q_DISABLE_COPY(QWebEnginePage)
- Q_DECLARE_PRIVATE(QWebEnginePage)
- QScopedPointer<QWebEnginePagePrivate> d_ptr;
-#ifndef QT_NO_ACTION
- Q_PRIVATE_SLOT(d_func(), void _q_webActionTriggered(bool checked))
-#endif
-
- friend class QContextMenuBuilder;
- friend class QWebEngineFullScreenRequest;
- friend class QWebEngineView;
- friend class QWebEngineViewPrivate;
-#ifndef QT_NO_ACCESSIBILITY
- friend class QWebEngineViewAccessible;
-#endif // QT_NO_ACCESSIBILITY
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEnginePage::FindFlags)
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEPAGE_H
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
deleted file mode 100644
index 82ce99503..000000000
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEPAGE_P_H
-#define QWEBENGINEPAGE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qwebenginepage.h"
-
-#include "qwebenginecallback_p.h"
-#include "qwebenginecontextmenudata.h"
-#include "qwebenginescriptcollection.h"
-#include "render_view_context_menu_qt.h"
-#include "web_contents_adapter_client.h"
-
-#include <QtCore/qcompilerdetection.h>
-#include <QtCore/QPointer>
-#include <QtCore/QTimer>
-
-namespace QtWebEngineCore {
-class RenderWidgetHostViewQtDelegate;
-class RenderWidgetHostViewQtDelegateWidget;
-class TouchHandleDrawableClient;
-class TouchSelectionMenuController;
-class WebContentsAdapter;
-}
-
-QT_BEGIN_NAMESPACE
-class QWebEngineFindTextResult;
-class QWebEngineHistory;
-class QWebEnginePage;
-class QWebEngineProfile;
-class QWebEngineSettings;
-class QWebEngineView;
-
-class QWebEnginePagePrivate : public QtWebEngineCore::WebContentsAdapterClient
-{
-public:
- Q_DECLARE_PUBLIC(QWebEnginePage)
- QWebEnginePage *q_ptr;
-
- QWebEnginePagePrivate(QWebEngineProfile *profile = 0);
- ~QWebEnginePagePrivate();
-
- QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
- QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override { return CreateRenderWidgetHostViewQtDelegate(client); }
- void initializationFinished() override;
- void lifecycleStateChanged(LifecycleState state) override;
- void recommendedStateChanged(LifecycleState state) override;
- void visibleChanged(bool visible) override;
- void titleChanged(const QString&) override;
- void urlChanged() override;
- void iconChanged(const QUrl&) override;
- void loadProgressChanged(int progress) override;
- void didUpdateTargetURL(const QUrl&) override;
- void selectionChanged() override;
- void recentlyAudibleChanged(bool recentlyAudible) override;
- void renderProcessPidChanged(qint64 pid) override;
- QRectF viewportRect() const override;
- QColor backgroundColor() const override;
- void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override;
- void loadCommitted() override { }
- void loadVisuallyCommitted() override { }
- void loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode,
- const QString &errorDescription, bool triggersErrorPage) override;
- void focusContainer() override;
- void unhandledKeyEvent(QKeyEvent *event) override;
- QSharedPointer<QtWebEngineCore::WebContentsAdapter>
- adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents,
- WindowOpenDisposition disposition, bool userGesture,
- const QRect &initialGeometry, const QUrl &targetUrl) override;
- bool isBeingAdopted() override;
- void close() override;
- void windowCloseRejected() override;
- void contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) override;
- void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) override;
- void requestFullScreenMode(const QUrl &origin, bool fullscreen) override;
- bool isFullScreenMode() const override;
- void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) override;
- void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) override;
- void showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController>) override;
- void didRunJavaScript(quint64 requestId, const QVariant& result) override;
- void didFetchDocumentMarkup(quint64 requestId, const QString& result) override;
- void didFetchDocumentInnerText(quint64 requestId, const QString& result) override;
- void didPrintPage(quint64 requestId, QSharedPointer<QByteArray> result) override;
- void didPrintPageToPdf(const QString &filePath, bool success) override;
- bool passOnFocus(bool reverse) override;
- void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) override;
- void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) override;
- void releaseProfile() override;
- void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) override;
- void runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin) override;
- void runMouseLockPermissionRequest(const QUrl &securityOrigin) override;
- void runQuotaRequest(QWebEngineQuotaRequest) override;
- void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) override;
- 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;
- void updateContentsSize(const QSizeF &size) override;
- void updateNavigationActions() override;
- void updateEditActions() override;
- void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
- const QPixmap &pixmap, const QPoint &offset) override;
- bool supportsDragging() const override;
- bool isEnabled() const override;
- void setToolTip(const QString &toolTipText) override;
- void printRequested() override;
- QtWebEngineCore::TouchHandleDrawableClient *createTouchHandle(const QMap<int, QImage> &) override { return nullptr; }
- void showTouchSelectionMenu(QtWebEngineCore::TouchSelectionMenuController *, const QRect &, const QSize &) override { }
- void hideTouchSelectionMenu() override { }
- const QObject *holdingQObject() const override;
- ClientType clientType() override { return QtWebEngineCore::WebContentsAdapterClient::WidgetsClient; }
- void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidget) override;
- void findTextFinished(const QWebEngineFindTextResult &result) override;
-
- QtWebEngineCore::ProfileAdapter *profileAdapter() override;
- QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override;
-
- void updateAction(QWebEnginePage::WebAction) const;
- void _q_webActionTriggered(bool checked);
-
- QtWebEngineCore::WebContentsAdapter *webContents() { return adapter.data(); }
- void recreateFromSerializedHistory(QDataStream &input);
-
- void setFullScreenMode(bool);
- void ensureInitialized() const;
-
- static void bindPageAndView(QWebEnginePage *page, QWebEngineView *view);
- static void bindPageAndWidget(QWebEnginePage *page,
- QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget);
-
- QSharedPointer<QtWebEngineCore::WebContentsAdapter> adapter;
- QWebEngineHistory *history;
- QWebEngineProfile *profile;
- QWebEngineSettings *settings;
- QWebEngineView *view;
- QUrl url;
- QWebEngineContextMenuData contextData;
- bool isLoading;
- QWebEngineScriptCollection scriptCollection;
- bool m_isBeingAdopted;
- QColor m_backgroundColor;
- bool fullscreenMode;
- QWebChannel *webChannel;
- unsigned int webChannelWorldId;
- QUrl iconUrl;
- bool m_navigationActionTriggered;
- QPointer<QWebEnginePage> inspectedPage;
- QPointer<QWebEnginePage> devToolsPage;
- bool defaultAudioMuted;
- qreal defaultZoomFactor;
- QTimer wasShownTimer;
- QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget = nullptr;
-
- mutable QtWebEngineCore::CallbackDirectory m_callbacks;
- mutable QAction *actions[QWebEnginePage::WebActionCount];
-#if QT_CONFIG(webengine_printing_and_pdf)
- QPrinter *currentPrinter;
-#endif
-
- QList<QSharedPointer<CertificateErrorController>> m_certificateErrorControllers;
-};
-
-class QContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt
-{
-public:
- QContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data, QWebEnginePage *page, QMenu *menu);
-
-private:
- virtual bool hasInspector() override;
- virtual bool isFullScreenMode() override;
-
- virtual void addMenuItem(ContextMenuItem entry) override;
- virtual bool isMenuItemEnabled(ContextMenuItem entry) override;
-
- QWebEnginePage *m_page;
- QMenu *m_menu;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEPAGE_P_H
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
deleted file mode 100644
index 223d3b114..000000000
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ /dev/null
@@ -1,899 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qwebengineprofile.h"
-#include "qwebengineprofile_p.h"
-
-#include "qwebenginecookiestore.h"
-#include "qwebenginedownloaditem.h"
-#include "qwebenginedownloaditem_p.h"
-#include "qwebenginenotificationpresenter_p.h"
-#include "qwebenginepage.h"
-#include "qwebenginepage_p.h"
-#include "qwebenginesettings.h"
-#include "qwebenginescriptcollection_p.h"
-#include "qtwebenginecoreglobal.h"
-#include "profile_adapter.h"
-#include "visited_links_manager_qt.h"
-#include "web_engine_settings.h"
-
-#include <QDir>
-#include <QtWebEngineCore/qwebengineurlscheme.h>
-
-QT_BEGIN_NAMESPACE
-
-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::ProfileAdapter;
-
-/*!
- \class QWebEngineProfile
- \brief The QWebEngineProfile class provides a web engine profile shared by multiple pages.
- \since 5.5
-
- \inmodule QtWebEngineWidgets
-
- A web engine profile contains settings, scripts, persistent cookie policy, and the list of
- visited links shared by all web engine pages that belong to the profile.
-
- All pages that belong to the profile share a common QWebEngineSettings instance, which can
- be accessed with the settings() method. Likewise, the scripts() method provides access
- to a common QWebEngineScriptCollection instance.
-
- Information about visited links is stored together with persistent cookies and other persistent
- data in a storage returned by storageName(). Persistent data is stored in a subdirectory set by
- calling setPersistentStoragePath(), and the cache is located in a subdirectory set by calling
- setCachePath(). The cache type can be set to \e in-memory or \e on-disk by calling
- setHttpCacheType(). If only the storage name is set, the subdirectories are created and named
- automatically. If you set any of the values manually, you should do it before creating any
- pages that belong to the profile.
-
- The cache can be cleared of links by calling
- clearVisitedLinks() or clearAllVisitedLinks(). PersistentCookiesPolicy describes whether
- session and persistent cookies are saved to and restored from memory or disk.
-
- Profiles can be used to isolate pages from each other. A typical use case is a dedicated
- \e {off-the-record profile} for a \e {private browsing} mode. Using QWebEngineProfile() without
- defining a storage name constructs a new off-the-record profile that leaves no record on the
- local machine, and has no persistent data or cache. The isOffTheRecord() method can be used
- to check whether a profile is off-the-record.
-
- The default profile can be accessed by defaultProfile(). It is a built-in profile that all
- web pages not specifically created with another profile belong to.
-
- Implementing the QWebEngineUrlRequestInterceptor interface and registering the interceptor on a
- profile by setUrlRequestInterceptor() enables intercepting, blocking, and modifying URL
- requests (QWebEngineUrlRequestInfo) before they reach the networking stack of Chromium.
-
- A QWebEngineUrlSchemeHandler can be registered for a profile by installUrlSchemeHandler()
- to add support for custom URL schemes. Requests for the scheme are then issued to
- QWebEngineUrlSchemeHandler::requestStarted() as QWebEngineUrlRequestJob objects.
-
- Spellchecking HTML form fields can be enabled per profile by using the setSpellCheckEnabled()
- method and the current languages used for spellchecking can be set by using the
- setSpellCheckLanguages() method.
-
-*/
-
-/*!
- \enum QWebEngineProfile::HttpCacheType
-
- This enum describes the HTTP cache type:
-
- \value MemoryHttpCache Use an in-memory cache. This is the default if
- \c off-the-record is set.
- \value DiskHttpCache Use a disk cache. This is the default if the profile
- is not \c off-the-record. If set on an \c off-the-record profile will instead
- set \c MemoryHttpCache.
- \value NoCache Disable both in-memory and disk caching. (Added in Qt 5.7)
-*/
-
-/*!
- \enum QWebEngineProfile::PersistentCookiesPolicy
-
- This enum describes policy for cookie persistency:
-
- \value NoPersistentCookies
- Both session and persistent cookies are stored in memory. This is the only setting
- possible if \c off-the-record is set or no persistent data path is available.
- \value AllowPersistentCookies
- Cookies marked persistent are saved to and restored from disk, whereas session cookies
- are only stored to disk for crash recovery. This is the default setting.
- \value ForcePersistentCookies
- Both session and persistent cookies are saved to and restored from disk.
-*/
-
-void QWebEngineProfilePrivate::showNotification(QSharedPointer<QtWebEngineCore::UserNotificationController> &controller)
-{
- if (m_notificationPresenter) {
- std::unique_ptr<QWebEngineNotification> notification(new QWebEngineNotification(controller));
- m_notificationPresenter(std::move(notification));
- }
-}
-
-/*!
- \fn QWebEngineProfile::downloadRequested(QWebEngineDownloadItem *download)
-
- \since 5.5
-
- This signal is emitted whenever a download has been triggered.
- The \a download argument holds the state of the download.
- The download has to be explicitly accepted with QWebEngineDownloadItem::accept() or it will be
- cancelled by default.
- The download item is parented by the profile. If it is not accepted, it
- will be deleted immediately after the signal emission.
- This signal cannot be used with a queued connection.
-
- \sa QWebEngineDownloadItem, QWebEnginePage::download()
-*/
-
-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()
-{
- 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);
- }
-
- if (m_profileAdapter != QtWebEngineCore::ProfileAdapter::defaultProfileAdapter())
- delete m_profileAdapter;
-
- delete m_settings;
-}
-
-ProfileAdapter* QWebEngineProfilePrivate::profileAdapter() const
-{
- return m_profileAdapter;
-}
-
-void QWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId)
-{
- m_ongoingDownloads.remove(downloadId);
- if (m_profileAdapter)
- m_profileAdapter->removeDownload(downloadId);
-}
-
-void QWebEngineProfilePrivate::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 QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
-{
- Q_Q(QWebEngineProfile);
-
- Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QWebEngineDownloadItemPrivate *itemPrivate = new QWebEngineDownloadItemPrivate(this, info.url);
- itemPrivate->downloadId = info.id;
- itemPrivate->downloadState = info.accepted ? QWebEngineDownloadItem::DownloadInProgress
- : QWebEngineDownloadItem::DownloadRequested;
- itemPrivate->startTime = info.startTime;
- itemPrivate->downloadDirectory = QFileInfo(info.path).path();
- itemPrivate->downloadFileName = QFileInfo(info.path).fileName();
- itemPrivate->suggestedFileName = info.suggestedFileName;
- 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);
-
- m_ongoingDownloads.insert(info.id, download);
- QObject::connect(download, &QWebEngineDownloadItem::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); });
-
- Q_EMIT q->downloadRequested(download);
-
- QWebEngineDownloadItem::DownloadState state = download->state();
-
- info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName());
- info.savePageFormat = static_cast<QtWebEngineCore::ProfileAdapterClient::SavePageFormat>(
- download->savePageFormat());
- info.accepted = state != QWebEngineDownloadItem::DownloadCancelled;
-
- if (state == QWebEngineDownloadItem::DownloadRequested) {
- // Delete unaccepted downloads.
- info.accepted = false;
- delete download;
- }
-}
-
-void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info)
-{
- if (!m_ongoingDownloads.contains(info.id))
- return;
-
- QWebEngineDownloadItem* download = m_ongoingDownloads.value(info.id).data();
-
- if (!download) {
- downloadDestroyed(info.id);
- return;
- }
-
- download->d_func()->update(info);
-}
-
-void QWebEngineProfilePrivate::addWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter)
-{
- Q_ASSERT(m_profileAdapter);
- m_profileAdapter->addWebContentsAdapterClient(adapter);
-}
-
-void QWebEngineProfilePrivate::removeWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter)
-{
- Q_ASSERT(m_profileAdapter);
- m_profileAdapter->removeWebContentsAdapterClient(adapter);
-}
-
-/*!
- Constructs a new off-the-record profile with the parent \a parent.
-
- An off-the-record profile leaves no record on the local machine, and has no persistent data or cache.
- Thus, the HTTP cache can only be in memory and the cookies can only be non-persistent. Trying to change
- these settings will have no effect.
-
- \sa isOffTheRecord()
-*/
-QWebEngineProfile::QWebEngineProfile(QObject *parent)
- : QObject(parent)
- , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::ProfileAdapter()))
-{
- d_ptr->q_ptr = this;
-}
-
-/*!
- Constructs a new profile with the storage name \a storageName and parent \a parent.
-
- The storage name must be unique.
-
- A disk-based QWebEngineProfile should be destroyed on or before application exit, otherwise the cache
- and persistent data may not be fully flushed to disk.
-
- \sa storageName()
-*/
-QWebEngineProfile::QWebEngineProfile(const QString &storageName, QObject *parent)
- : QObject(parent)
- , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::ProfileAdapter(storageName)))
-{
- d_ptr->q_ptr = this;
-}
-
-/*! \internal
-*/
-QWebEngineProfile::QWebEngineProfile(QWebEngineProfilePrivate *privatePtr, QObject *parent)
- : QObject(parent)
- , d_ptr(privatePtr)
-{
- d_ptr->q_ptr = this;
-}
-
-/*! \internal
-*/
-QWebEngineProfile::~QWebEngineProfile()
-{
- d_ptr->cleanDownloads();
-}
-
-/*!
- Returns the storage name for the profile.
-
- The storage name is used to give each profile that uses the disk separate subdirectories for persistent data and cache.
-*/
-QString QWebEngineProfile::storageName() const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->storageName();
-}
-
-/*!
- Returns \c true if this is an off-the-record profile that leaves no record on the computer.
-
- This will force cookies and HTTP cache to be in memory, but also force all other normally
- persistent data to be stored in memory.
-*/
-bool QWebEngineProfile::isOffTheRecord() const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->isOffTheRecord();
-}
-
-/*!
- Returns the path used to store persistent data for the browser and web content.
-
- Persistent data includes persistent cookies, HTML5 local storage, and visited links.
-
- By default, this is below QStandardPaths::DataLocation in a QtWebengine/StorageName specific
- subdirectory.
-
- \note Use QStandardPaths::writableLocation(QStandardPaths::DataLocation)
- to obtain the QStandardPaths::DataLocation path.
-
- \sa setPersistentStoragePath(), storageName(), QStandardPaths::writableLocation()
-*/
-QString QWebEngineProfile::persistentStoragePath() const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->dataPath();
-}
-
-/*!
- Overrides the default path used to store persistent web engine data.
-
- If \a path is set to the null string, the default path is restored.
-
- \sa persistentStoragePath()
-*/
-void QWebEngineProfile::setPersistentStoragePath(const QString &path)
-{
- const Q_D(QWebEngineProfile);
- d->profileAdapter()->setDataPath(path);
-}
-
-/*!
- \since 5.13
-
- The path to the location where the downloaded files are stored.
-
- \note By default, the download path is QStandardPaths::DownloadLocation.
-
- \sa setDownloadPath(), QStandardPaths::writableLocation()
-*/
-QString QWebEngineProfile::downloadPath() const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->downloadPath();
-}
-
-/*!
- \since 5.13
-
- Overrides the default path used for download location, setting it to \a path.
-
- If set to the null string, the default path is restored.
-
- \sa downloadPath()
-*/
-void QWebEngineProfile::setDownloadPath(const QString &path)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setDownloadPath(path);
-}
-
-/*!
- Returns the path used for caches.
-
- By default, this is below StandardPaths::CacheLocation in a QtWebengine/StorageName specific
- subdirectory.
-
- \note Use QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
- to obtain the QStandardPaths::CacheLocation path.
-
- \sa setCachePath(), storageName(), QStandardPaths::writableLocation()
-*/
-QString QWebEngineProfile::cachePath() const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->cachePath();
-}
-
-/*!
- Overrides the default path used for disk caches, setting it to \a path.
-
- If set to the null string, the default path is restored.
-
- \sa cachePath()
-*/
-void QWebEngineProfile::setCachePath(const QString &path)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setCachePath(path);
-}
-
-/*!
- Returns the user-agent string sent with HTTP to identify the browser.
-
- \note On Windows 8.1 and newer, the default user agent will always report
- "Windows NT 6.2" (Windows 8), unless the application does contain a manifest
- that declares newer Windows versions as supported.
-
- \sa setHttpUserAgent()
-*/
-QString QWebEngineProfile::httpUserAgent() const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->httpUserAgent();
-}
-
-/*!
- Overrides the default user-agent string, setting it to \a userAgent.
-
- \sa httpUserAgent()
-*/
-void QWebEngineProfile::setHttpUserAgent(const QString &userAgent)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setHttpUserAgent(userAgent);
-}
-
-/*!
- Returns the type of HTTP cache used.
-
- If the profile is off-the-record, MemoryHttpCache is returned.
-
- \sa setHttpCacheType(), cachePath()
-*/
-QWebEngineProfile::HttpCacheType QWebEngineProfile::httpCacheType() const
-{
- const Q_D(QWebEngineProfile);
- return QWebEngineProfile::HttpCacheType(d->profileAdapter()->httpCacheType());
-}
-
-/*!
- Sets the HTTP cache type to \a httpCacheType.
-
- \sa httpCacheType(), setCachePath()
-*/
-void QWebEngineProfile::setHttpCacheType(QWebEngineProfile::HttpCacheType httpCacheType)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setHttpCacheType(ProfileAdapter::HttpCacheType(httpCacheType));
-}
-
-/*!
- Sets the value of the Accept-Language HTTP request-header field to \a httpAcceptLanguage.
-
- \since 5.6
- */
-void QWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setHttpAcceptLanguage(httpAcceptLanguage);
-}
-
-/*!
- Returns the value of the Accept-Language HTTP request-header field.
-
- \since 5.6
- */
-QString QWebEngineProfile::httpAcceptLanguage() const
-{
- Q_D(const QWebEngineProfile);
- return d->profileAdapter()->httpAcceptLanguage();
-}
-
-/*!
- Returns the current policy for persistent cookies.
-
- If the profile is off-the-record, NoPersistentCookies is returned.
-
- \sa setPersistentCookiesPolicy()
-*/
-QWebEngineProfile::PersistentCookiesPolicy QWebEngineProfile::persistentCookiesPolicy() const
-{
- const Q_D(QWebEngineProfile);
- return QWebEngineProfile::PersistentCookiesPolicy(d->profileAdapter()->persistentCookiesPolicy());
-}
-
-/*!
- Sets the policy for persistent cookies to \a newPersistentCookiesPolicy.
-
- \sa persistentCookiesPolicy()
-*/
-void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy newPersistentCookiesPolicy)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setPersistentCookiesPolicy(ProfileAdapter::PersistentCookiesPolicy(newPersistentCookiesPolicy));
-}
-
-/*!
- Returns the maximum size of the HTTP cache in bytes.
-
- Will return \c 0 if the size is automatically controlled by QtWebEngine.
-
- \sa setHttpCacheMaximumSize(), httpCacheType()
-*/
-int QWebEngineProfile::httpCacheMaximumSize() const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->httpCacheMaxSize();
-}
-
-/*!
- Sets the maximum size of the HTTP cache to \a maxSize bytes.
-
- Setting it to \c 0 means the size will be controlled automatically by QtWebEngine.
-
- \sa httpCacheMaximumSize(), setHttpCacheType()
-*/
-void QWebEngineProfile::setHttpCacheMaximumSize(int maxSize)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setHttpCacheMaxSize(maxSize);
-}
-
-/*!
- Returns the cookie store for this profile.
-
- \since 5.6
-*/
-
-QWebEngineCookieStore* QWebEngineProfile::cookieStore()
-{
- Q_D(QWebEngineProfile);
- return d->profileAdapter()->cookieStore();
-}
-
-#if QT_DEPRECATED_SINCE(5, 13)
-/*!
- Registers a request interceptor singleton \a interceptor to intercept URL requests.
-
- The profile does not take ownership of the pointer.
-
- \obsolete
-
- Interceptors installed with this method will call
- QWebEngineUrlRequestInterceptor::interceptRequest on the I/O thread. Therefore
- the user has to provide thread-safe interaction with the other user classes.
- For a duration of this call ui thread is blocked.
- Use setUrlRequestInterceptor instead.
-
- \since 5.6
- \sa QWebEngineUrlRequestInfo
-
-*/
-void QWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
-{
- Q_D(QWebEngineProfile);
- if (interceptor)
- interceptor->setProperty("deprecated", true);
- d->profileAdapter()->setRequestInterceptor(interceptor);
- if (interceptor)
- qDebug("Use of deprecated not thread-safe setter, use setUrlRequestInterceptor instead.");
-}
-#endif
-/*!
- Registers a request interceptor singleton \a interceptor to intercept URL requests.
-
- The profile does not take ownership of the pointer.
-
- \since 5.13
- \sa QWebEngineUrlRequestInfo QWebEngineUrlRequestInterceptor
-*/
-
-void QWebEngineProfile::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setRequestInterceptor(interceptor);
-}
-
-/*!
- Clears all links from the visited links database.
-
- \sa clearVisitedLinks()
-*/
-void QWebEngineProfile::clearAllVisitedLinks()
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->visitedLinksManager()->deleteAllVisitedLinkData();
-}
-
-/*!
- Clears the links in \a urls from the visited links database.
-
- \sa clearAllVisitedLinks()
-*/
-void QWebEngineProfile::clearVisitedLinks(const QList<QUrl> &urls)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->visitedLinksManager()->deleteVisitedLinkDataForUrls(urls);
-}
-
-/*!
- Returns \c true if \a url is considered a visited link by this profile.
-*/
-bool QWebEngineProfile::visitedLinksContainsUrl(const QUrl &url) const
-{
- Q_D(const QWebEngineProfile);
- return d->profileAdapter()->visitedLinksManager()->containsUrl(url);
-}
-
-/*!
- Returns the collection of scripts that are injected into all pages that share
- this profile.
-
- \sa QWebEngineScriptCollection, QWebEngineScript, QWebEnginePage::scripts(),
- {Script Injection}
-*/
-QWebEngineScriptCollection *QWebEngineProfile::scripts() const
-{
- Q_D(const QWebEngineProfile);
- return d->m_scriptCollection.data();
-}
-
-/*!
- Sets the function \a notificationPresenter as responsible for presenting sent notifications.
-
- \since 5.13
- \sa QWebEngineNotification
-*/
-void QWebEngineProfile::setNotificationPresenter(std::function<void(std::unique_ptr<QWebEngineNotification>)> notificationPresenter)
-{
- Q_D(QWebEngineProfile);
- d->m_notificationPresenter = std::move(notificationPresenter);
-}
-
-/*!
- Returns the default profile.
-
- The default profile uses the storage name "Default".
-
- \sa storageName()
-*/
-QWebEngineProfile *QWebEngineProfile::defaultProfile()
-{
- static QWebEngineProfile* profile = new QWebEngineProfile(
- new QWebEngineProfilePrivate(ProfileAdapter::createDefaultProfileAdapter()),
- ProfileAdapter::globalQObjectRoot());
- if (!profile->d_ptr->m_notificationPresenter)
- profile->setNotificationPresenter(&defaultNotificationPresenter);
- return profile;
-}
-
-/*!
- \since 5.8
-
- Sets the current list of \a languages for the spell checker.
- Each language should match the name of the \c .bdic dictionary.
- For example, the language \c en-US will load the \c en-US.bdic
- dictionary file.
-
- See the \l {Spellchecker}{Spellchecker feature documentation} for how
- dictionary files are searched.
-
- For more information about how to compile \c .bdic dictionaries, see the
- \l{WebEngine Widgets Spellchecker Example}{Spellchecker Example}.
-
-*/
-void QWebEngineProfile::setSpellCheckLanguages(const QStringList &languages)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setSpellCheckLanguages(languages);
-}
-
-/*!
- \since 5.8
-
- Returns the list of languages used by the spell checker.
-*/
-QStringList QWebEngineProfile::spellCheckLanguages() const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->spellCheckLanguages();
-}
-
-/*!
- \since 5.8
-
- Enables spell checker if \a enable is \c true, otherwise disables it.
- \sa isSpellCheckEnabled()
- */
-void QWebEngineProfile::setSpellCheckEnabled(bool enable)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setSpellCheckEnabled(enable);
-}
-/*!
- \since 5.8
-
- Returns \c true if the spell checker is enabled; otherwise returns \c false.
- \sa setSpellCheckEnabled()
- */
-bool QWebEngineProfile::isSpellCheckEnabled() const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->isSpellCheckEnabled();
-}
-
-/*!
- Returns the default settings for all pages in this profile.
-*/
-QWebEngineSettings *QWebEngineProfile::settings() const
-{
- const Q_D(QWebEngineProfile);
- return d->settings();
-}
-
-/*!
- \since 5.6
-
- Returns the custom URL scheme handler register for the URL scheme \a scheme.
-*/
-const QWebEngineUrlSchemeHandler *QWebEngineProfile::urlSchemeHandler(const QByteArray &scheme) const
-{
- const Q_D(QWebEngineProfile);
- return d->profileAdapter()->urlSchemeHandler(scheme);
-}
-
-/*!
- \since 5.6
-
- Registers a handler \a handler for custom URL scheme \a scheme in the profile.
-
- It is necessary to first register the scheme with \l
- QWebEngineUrlScheme::registerScheme at application startup.
-*/
-void QWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->installUrlSchemeHandler(scheme, handler);
-}
-
-/*!
- \since 5.6
-
- Removes the custom URL scheme handler \a handler from the profile.
-
- \sa removeUrlScheme()
-*/
-void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->removeUrlSchemeHandler(handler);
-}
-
-/*!
- \since 5.6
-
- Removes the custom URL scheme \a scheme from the profile.
-
- \sa removeUrlSchemeHandler()
-*/
-void QWebEngineProfile::removeUrlScheme(const QByteArray &scheme)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->removeUrlScheme(scheme);
-}
-
-/*!
- \since 5.6
-
- Removes all custom URL scheme handlers installed in the profile.
-*/
-void QWebEngineProfile::removeAllUrlSchemeHandlers()
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->removeAllUrlSchemeHandlers();
-}
-
-/*!
- \since 5.13
-
- \obsolete
-
- Sets if this profile is to be used for downloading and caching when needed
- during certificate verification, for instance for OCSP, CRLs, and AIA.
-
- Only one QWebEngineProfile can do this at a time, and it is recommended
- that the profile fullfilling this role has a disk HTTP cache to avoid
- needlessly re-downloading. If you set the option on a second profile,
- it will be disabled on the profile it is currently set.
-
- As long as one profile has \a enabled set to \c true, all other profiles
- will be able to use it for their certificate verification.
-
- Originally only affected Linux/NSS installations where it enabled OCSP.
-
- Since 5.15.3, no longer does anything. Certificate verification is done
- using AIO on the requesting profile.
-
- \sa isUsedForGlobalCertificateVerification(), httpCacheType()
-*/
-void QWebEngineProfile::setUseForGlobalCertificateVerification(bool enabled)
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->setUseForGlobalCertificateVerification(enabled);
-}
-
-/*!
- \since 5.13
-
- \obsolete
-
- Returns \c true if this profile is currently being used for global
- certificate verification.
-*/
-bool QWebEngineProfile::isUsedForGlobalCertificateVerification() const
-{
- Q_D(const QWebEngineProfile);
- return d->profileAdapter()->isUsedForGlobalCertificateVerification();
-}
-
-/*!
- \since 5.7
-
- Removes the profile's cache entries.
-*/
-void QWebEngineProfile::clearHttpCache()
-{
- Q_D(QWebEngineProfile);
- d->profileAdapter()->clearHttpCache();
-}
-
-/*!
- \since 5.13
-
- Returns the profile's client certificate store.
-*/
-QWebEngineClientCertificateStore *QWebEngineProfile::clientCertificateStore()
-{
-#if QT_CONFIG(ssl)
- Q_D(QWebEngineProfile);
- return d->profileAdapter()->clientCertificateStore();
-#else
- return nullptr;
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h
deleted file mode 100644
index 794ba6279..000000000
--- a/src/webenginewidgets/api/qwebengineprofile.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEPROFILE_H
-#define QWEBENGINEPROFILE_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qscopedpointer.h>
-#include <QtCore/qstring.h>
-
-#include <functional>
-#include <memory>
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-class QUrl;
-class QWebEngineClientCertificateStore;
-class QWebEngineCookieStore;
-class QWebEngineDownloadItem;
-class QWebEngineNotification;
-class QWebEnginePage;
-class QWebEnginePagePrivate;
-class QWebEngineProfilePrivate;
-class QWebEngineSettings;
-class QWebEngineScriptCollection;
-class QWebEngineUrlRequestInterceptor;
-class QWebEngineUrlSchemeHandler;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineProfile : public QObject {
- Q_OBJECT
-public:
- explicit QWebEngineProfile(QObject *parent = Q_NULLPTR);
- explicit QWebEngineProfile(const QString &name, QObject *parent = Q_NULLPTR);
- virtual ~QWebEngineProfile();
-
- enum HttpCacheType {
- MemoryHttpCache,
- DiskHttpCache,
- NoCache
- };
- Q_ENUM(HttpCacheType)
-
- enum PersistentCookiesPolicy {
- NoPersistentCookies,
- AllowPersistentCookies,
- ForcePersistentCookies
- };
- Q_ENUM(PersistentCookiesPolicy)
-
- QString storageName() const;
- bool isOffTheRecord() const;
-
- QString persistentStoragePath() const;
- void setPersistentStoragePath(const QString &path);
-
- QString cachePath() const;
- void setCachePath(const QString &path);
-
- QString httpUserAgent() const;
- void setHttpUserAgent(const QString &userAgent);
-
- HttpCacheType httpCacheType() const;
- void setHttpCacheType(QWebEngineProfile::HttpCacheType);
-
- void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
- QString httpAcceptLanguage() const;
-
- PersistentCookiesPolicy persistentCookiesPolicy() const;
- void setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy);
-
- int httpCacheMaximumSize() const;
- void setHttpCacheMaximumSize(int maxSize);
-
- QWebEngineCookieStore* cookieStore();
-#if QT_DEPRECATED_SINCE(5, 13)
- void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
-#endif
- void setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
-
- void clearAllVisitedLinks();
- void clearVisitedLinks(const QList<QUrl> &urls);
- bool visitedLinksContainsUrl(const QUrl &url) const;
-
- QWebEngineSettings *settings() const;
- QWebEngineScriptCollection *scripts() const;
-
- const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &) const;
- void installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *);
- void removeUrlScheme(const QByteArray &scheme);
- void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
- void removeAllUrlSchemeHandlers();
-
- void clearHttpCache();
-
- void setSpellCheckLanguages(const QStringList &languages);
- QStringList spellCheckLanguages() const;
- void setSpellCheckEnabled(bool enabled);
- bool isSpellCheckEnabled() const;
-
- void setUseForGlobalCertificateVerification(bool enabled = true);
- bool isUsedForGlobalCertificateVerification() const;
-
- QString downloadPath() const;
- void setDownloadPath(const QString &path);
-
- void setNotificationPresenter(std::function<void(std::unique_ptr<QWebEngineNotification>)> notificationPresenter);
-
- QWebEngineClientCertificateStore *clientCertificateStore();
-
- static QWebEngineProfile *defaultProfile();
-
-Q_SIGNALS:
- void downloadRequested(QWebEngineDownloadItem *download);
-
-private:
- Q_DISABLE_COPY(QWebEngineProfile)
- Q_DECLARE_PRIVATE(QWebEngineProfile)
- QWebEngineProfile(QWebEngineProfilePrivate *, QObject *parent = Q_NULLPTR);
-
- friend class QWebEnginePage;
- friend class QWebEnginePagePrivate;
- friend class QWebEngineUrlSchemeHandler;
- QScopedPointer<QWebEngineProfilePrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEPROFILE_H
diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h
deleted file mode 100644
index 64e9500b0..000000000
--- a/src/webenginewidgets/api/qwebengineprofile_p.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEPROFILE_P_H
-#define QWEBENGINEPROFILE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "profile_adapter_client.h"
-#include "qwebengineprofile.h"
-#include "qwebenginescriptcollection.h"
-
-#include <QMap>
-#include <QPointer>
-#include <QScopedPointer>
-#include <QSharedPointer>
-
-#include <functional>
-
-namespace QtWebEngineCore {
-class ProfileAdapter;
-}
-
-QT_BEGIN_NAMESPACE
-
-class QWebEngineBrowserContext;
-class QWebEngineProfilePrivate;
-class QWebEngineNotification;
-class QWebEngineSettings;
-
-class QWebEngineProfilePrivate : public QtWebEngineCore::ProfileAdapterClient {
-public:
- Q_DECLARE_PUBLIC(QWebEngineProfile)
- QWebEngineProfilePrivate(QtWebEngineCore::ProfileAdapter *profileAdapter);
- ~QWebEngineProfilePrivate();
-
- QtWebEngineCore::ProfileAdapter* profileAdapter() const;
- QWebEngineSettings *settings() const { return m_settings; }
-
- void downloadDestroyed(quint32 downloadId);
-
- void cleanDownloads();
-
- void downloadRequested(DownloadItemInfo &info) override;
- void downloadUpdated(const DownloadItemInfo &info) override;
-
- void showNotification(QSharedPointer<QtWebEngineCore::UserNotificationController> &) override;
-
- void addWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter) override;
- void removeWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter) override;
-
-private:
- QWebEngineProfile *q_ptr;
- QWebEngineSettings *m_settings;
- QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter;
- QScopedPointer<QWebEngineScriptCollection> m_scriptCollection;
- QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads;
- std::function<void(std::unique_ptr<QWebEngineNotification>)> m_notificationPresenter;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEPROFILE_P_H
diff --git a/src/webenginewidgets/api/qwebenginescript.cpp b/src/webenginewidgets/api/qwebenginescript.cpp
deleted file mode 100644
index af6b9aa8d..000000000
--- a/src/webenginewidgets/api/qwebenginescript.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qwebenginescript.h"
-
-#include "user_script.h"
-#include <QtCore/QDebug>
-
-using QtWebEngineCore::UserScript;
-
-/*!
- \class QWebEngineScript
- \inmodule QtWebEngineWidgets
- \since 5.5
- \brief The QWebEngineScript class encapsulates a JavaScript program.
-
-
- QWebEngineScript enables the programmatic injection of so called \e {user scripts} in the
- JavaScript engine at different points, determined by injectionPoint(), during the loading of web
- contents.
-
- Scripts can be executed either in the main JavaScript \e world, along with the rest of the
- JavaScript coming from the web contents, or in their own isolated world. While the DOM of the
- page can be accessed from any world, JavaScript variables of a function defined in one world are
- not accessible from a different one. ScriptWorldId provides some predefined IDs for this
- purpose.
-
- The following \l Greasemonkey attributes are supported since Qt 5.8:
- \c @exclude, \c @include, \c @name, \c @match, and \c @run-at.
-
- Use QWebEnginePage::scripts() and QWebEngineProfile::scripts() to access
- the collection of scripts associated with a single page or a
- number of pages sharing the same profile.
-
- \sa {Script Injection}
-*/
-/*!
- \enum QWebEngineScript::InjectionPoint
-
- This enum describes the timing of the script injection:
-
- \value DocumentCreation The script will be executed as soon as the document is created. This is not suitable for
- any DOM operation.
- \value DocumentReady The script will run as soon as the DOM is ready. This is equivalent to the
- \c DOMContentLoaded event firing in JavaScript.
- \value Deferred The script will run when the page load finishes, or 500ms after the document is ready, whichever
- comes first.
-
-*/
-/*!
- \enum QWebEngineScript::ScriptWorldId
-
- This enum provides pre-defined world IDs for isolating user scripts into different worlds:
-
- \value MainWorld The world used by the page's web contents. It can be useful in order to expose custom functionality
- to web contents in certain scenarios.
- \value ApplicationWorld The default isolated world used for application level functionality implemented in JavaScript.
- \value UserWorld The first isolated world to be used by scripts set by users if the application is not making use
- of more worlds. As a rule of thumb, if that functionality is exposed to the application users, each individual script
- should probably get its own isolated world.
-
-*/
-
-/*!
- \fn QWebEngineScript::operator!=(const QWebEngineScript &other) const
-
- Returns \c true if the script is not equal to \a other, otherwise returns \c false.
-*/
-
-/*!
- \fn QWebEngineScript::swap(QWebEngineScript &other)
-
- Swaps the contents of the script with the contents of \a other.
-*/
-
-/*!
- * Constructs a null script.
- */
-
-QWebEngineScript::QWebEngineScript()
- : d(new UserScript)
-{
-}
-
-/*!
- * Constructs a user script using the contents of \a other.
- */
-QWebEngineScript::QWebEngineScript(const QWebEngineScript &other)
- : d(other.d)
-{
-}
-
-/*!
- Destroys a script.
-*/
-QWebEngineScript::~QWebEngineScript()
-{
-}
-
-/*!
- Assigns \a other to the script.
-*/
-QWebEngineScript &QWebEngineScript::operator=(const QWebEngineScript &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Returns \c true is the script is null; otherwise returns \c false.
-*/
-bool QWebEngineScript::isNull() const
-{
- return d->isNull();
-}
-
-/*!
- * Returns the name of the script. Can be useful to retrieve a particular script from a
- * QWebEngineScriptCollection.
- *
- * \sa QWebEngineScriptCollection::findScript(), QWebEngineScriptCollection::findScripts()
- */
-
-QString QWebEngineScript::name() const
-{
- return d->name();
-}
-
-/*!
- * Sets the script name to \a scriptName.
- */
-void QWebEngineScript::setName(const QString &scriptName)
-{
- if (scriptName == name())
- return;
- d->setName(scriptName);
-}
-
-/*!
- Returns the source of the script.
- */
-QString QWebEngineScript::sourceCode() const
-{
- return d->sourceCode();
-}
-
-/*!
- * Sets the script source to \a scriptSource.
- */
-void QWebEngineScript::setSourceCode(const QString &scriptSource)
-{
- if (scriptSource == sourceCode())
- return;
- d->setSourceCode(scriptSource);
-}
-
-ASSERT_ENUMS_MATCH(QWebEngineScript::Deferred, UserScript::AfterLoad)
-ASSERT_ENUMS_MATCH(QWebEngineScript::DocumentReady, UserScript::DocumentLoadFinished)
-ASSERT_ENUMS_MATCH(QWebEngineScript::DocumentCreation, UserScript::DocumentElementCreation)
-
-/*!
- * Returns the point in the loading process at which the script will be executed.
- * The default value is QWebEngineScript::Deferred.
- *
- * \sa setInjectionPoint()
- */
-QWebEngineScript::InjectionPoint QWebEngineScript::injectionPoint() const
-{
- return static_cast<QWebEngineScript::InjectionPoint>(d->injectionPoint());
-}
-/*!
- * Sets the point at which to execute the script to be \a p.
- *
- * \sa InjectionPoint
- */
-void QWebEngineScript::setInjectionPoint(QWebEngineScript::InjectionPoint p)
-{
- if (p == injectionPoint())
- return;
- d->setInjectionPoint(static_cast<UserScript::InjectionPoint>(p));
-}
-
-/*!
- Returns the world ID defining which world the script is executed in.
- */
-quint32 QWebEngineScript::worldId() const
-{
- return d->worldId();
-}
-
-/*!
- Sets the world ID of the isolated world to \a id when running this script.
-
- Must be between \c 0 and \c 256.
- */
-void QWebEngineScript::setWorldId(quint32 id)
-{
- if (id == d->worldId())
- return;
- d->setWorldId(id);
-}
-
-/*!
- Returns \c true if the script is executed on every frame in the page, or \c false if it is only
- ran for the main frame.
- */
-bool QWebEngineScript::runsOnSubFrames() const
-{
- return d->runsOnSubFrames();
-}
-
-/*!
- * Executes the script on sub frames in addition to the main frame if \a on returns \c true.
- */
-void QWebEngineScript::setRunsOnSubFrames(bool on)
-{
- if (runsOnSubFrames() == on)
- return;
- d->setRunsOnSubFrames(on);
-}
-
-/*!
- Returns \c true if the script is equal to \a other, otherwise returns \c false.
- */
-bool QWebEngineScript::operator==(const QWebEngineScript &other) const
-{
- return d == other.d || *d == *(other.d);
-}
-
-QWebEngineScript::QWebEngineScript(const UserScript &coreScript)
- : d(new UserScript(coreScript))
-{
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug d, const QWebEngineScript &script)
-{
- if (script.isNull())
- return d.maybeSpace() << "QWebEngineScript()";
-
- d.nospace() << "QWebEngineScript(" << script.name() << ", ";
- switch (script.injectionPoint()) {
- case QWebEngineScript::DocumentCreation:
- d << "QWebEngineScript::DocumentCreation" << ", ";
- break;
- case QWebEngineScript::DocumentReady:
- d << "QWebEngineScript::DocumentReady" << ", ";
- break;
- case QWebEngineScript::Deferred:
- d << "QWebEngineScript::Deferred" << ", ";
- break;
- }
- d << script.worldId() << ", "
- << script.runsOnSubFrames() << ", " << script.sourceCode() << ")";
- return d.space();
-}
-#endif
diff --git a/src/webenginewidgets/api/qwebenginescript.h b/src/webenginewidgets/api/qwebenginescript.h
deleted file mode 100644
index e3f65ec59..000000000
--- a/src/webenginewidgets/api/qwebenginescript.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINESCRIPT_H
-#define QWEBENGINESCRIPT_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-#include <QtCore/qshareddata.h>
-#include <QtCore/qstring.h>
-
-namespace QtWebEngineCore {
-class UserScript;
-} // namespace
-
-QT_BEGIN_NAMESPACE
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineScript {
-public:
- enum InjectionPoint {
- Deferred,
- DocumentReady,
- DocumentCreation
- };
-
- enum ScriptWorldId {
- MainWorld = 0,
- ApplicationWorld,
- UserWorld
- };
-
- QWebEngineScript();
- QWebEngineScript(const QWebEngineScript &other);
- ~QWebEngineScript();
-
- QWebEngineScript &operator=(const QWebEngineScript &other);
-
- bool isNull() const;
-
- QString name() const;
- void setName(const QString &);
-
- QString sourceCode() const;
- void setSourceCode(const QString &);
-
- InjectionPoint injectionPoint() const;
- void setInjectionPoint(InjectionPoint);
-
- quint32 worldId() const;
- void setWorldId(quint32);
-
- bool runsOnSubFrames() const;
- void setRunsOnSubFrames(bool on);
-
- bool operator==(const QWebEngineScript &other) const;
- inline bool operator!=(const QWebEngineScript &other) const
- { return !operator==(other); }
- void swap(QWebEngineScript &other) { qSwap(d, other.d); }
-
-
-private:
- friend class QWebEngineScriptCollectionPrivate;
- friend class QWebEngineScriptCollection;
- QWebEngineScript(const QtWebEngineCore::UserScript &);
-
- QSharedDataPointer<QtWebEngineCore::UserScript> d;
-};
-
-Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QWebEngineScript)
-
-#ifndef QT_NO_DEBUG_STREAM
-QWEBENGINEWIDGETS_EXPORT QDebug operator<<(QDebug, const QWebEngineScript &);
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINESCRIPT_H
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp
deleted file mode 100644
index 8cbeeb804..000000000
--- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qwebenginescriptcollection.h"
-#include "qwebenginescriptcollection_p.h"
-
-#include "renderer_host/user_resource_controller_host.h"
-
-using QtWebEngineCore::UserScript;
-
-/*!
- \class QWebEngineScriptCollection
- \inmodule QtWebEngineWidgets
- \since 5.5
- \brief The QWebEngineScriptCollection class represents a collection of user scripts.
-
- QWebEngineScriptCollection manages a set of user scripts.
-
- Use QWebEnginePage::scripts() and QWebEngineProfile::scripts() to access
- the collection of scripts associated with a single page or a
- number of pages sharing the same profile.
-
- \sa {Script Injection}
-*/
-
-/*!
- \fn QWebEngineScriptCollection::isEmpty() const
-
- Returns \c true if the collection is empty; otherwise returns \c false.
-*/
-
-/*!
- \fn QWebEngineScriptCollection::size() const
-
- Returns the number of elements in the collection.
-*/
-
-QWebEngineScriptCollection::QWebEngineScriptCollection(QWebEngineScriptCollectionPrivate *collectionPrivate)
- :d(collectionPrivate)
-{
-}
-
-/*!
- Destroys the collection.
-*/
-QWebEngineScriptCollection::~QWebEngineScriptCollection()
-{
-}
-
-/*!
- Returns the number of elements in the collection.
- */
-
-int QWebEngineScriptCollection::count() const
-{
- return d->count();
-}
-
-/*!
- Returns \c true if the collection contains an occurrence of \a value; otherwise returns
- \c false.
- */
-
-bool QWebEngineScriptCollection::contains(const QWebEngineScript &value) const
-{
- return d->contains(value);
-}
-
-/*!
- * Returns the first script found in the collection with the name \a name, or a null
- * QWebEngineScript if none was found.
- * \note The order in which the script collection is traversed is undefined, which means this should
- * be used when the unicity is guaranteed at the application level.
- * \sa findScripts()
- */
-
-QWebEngineScript QWebEngineScriptCollection::findScript(const QString &name) const
-{
- return d->find(name);
-}
-
-/*!
- Returns the list of scripts in the collection with the name \a name, or an empty list if none
- was found.
- */
-
-QList<QWebEngineScript> QWebEngineScriptCollection::findScripts(const QString &name) const
-{
- return d->toList(name);
-}
-/*!
- Inserts the script \a s into the collection.
- */
-void QWebEngineScriptCollection::insert(const QWebEngineScript &s)
-{
- d->insert(s);
-}
-/*!
- Inserts scripts from the list \a list into the collection.
- */
-void QWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list)
-{
- d->reserve(list.size());
- for (const QWebEngineScript &s : list)
- d->insert(s);
-}
-
-/*!
- Removes \a script from the collection.
-
- Returns \c true if the script was found and successfully removed from the collection; otherwise
- returns \c false.
- */
-bool QWebEngineScriptCollection::remove(const QWebEngineScript &script)
-{
- return d->remove(script);
-}
-
-/*!
- * Removes all scripts from this collection.
- */
-void QWebEngineScriptCollection::clear()
-{
- d->clear();
-}
-
-/*!
- Returns a list with the values of the scripts used in this collection.
- */
-QList<QWebEngineScript> QWebEngineScriptCollection::toList() const
-{
- return d->toList();
-}
-
-
-QWebEngineScriptCollectionPrivate::QWebEngineScriptCollectionPrivate(QtWebEngineCore::UserResourceControllerHost *controller, QSharedPointer<QtWebEngineCore::WebContentsAdapter> webContents)
- : m_scriptController(controller)
- , m_contents(webContents)
-{
-}
-
-int QWebEngineScriptCollectionPrivate::count() const
-{
- return m_scripts.count();
-}
-
-bool QWebEngineScriptCollectionPrivate::contains(const QWebEngineScript &s) const
-{
- return m_scripts.contains(s);
-}
-
-void QWebEngineScriptCollectionPrivate::insert(const QWebEngineScript &script)
-{
- if (!script.d || script.d->isNull())
- return;
- m_scripts.append(script);
- if (!m_contents || m_contents->isInitialized())
- m_scriptController->addUserScript(*script.d, m_contents.data());
-}
-
-bool QWebEngineScriptCollectionPrivate::remove(const QWebEngineScript &script)
-{
- if (!script.d || script.d->isNull())
- return false;
- if (!m_contents || m_contents->isInitialized())
- m_scriptController->removeUserScript(*script.d, m_contents.data());
- return m_scripts.removeAll(script);
-}
-
-QList<QWebEngineScript> QWebEngineScriptCollectionPrivate::toList(const QString &scriptName) const
-{
- if (scriptName.isNull())
- return m_scripts;
-
- QList<QWebEngineScript> ret;
- for (const QWebEngineScript &script : qAsConst(m_scripts))
- if (scriptName == script.name())
- ret.append(script);
- return ret;
-}
-
-QWebEngineScript QWebEngineScriptCollectionPrivate::find(const QString &name) const
-{
- for (const QWebEngineScript &script : qAsConst(m_scripts))
- if (name == script.name())
- return script;
- return QWebEngineScript();
-}
-
-void QWebEngineScriptCollectionPrivate::clear()
-{
- m_scripts.clear();
- if (!m_contents || m_contents->isInitialized())
- m_scriptController->clearAllScripts(m_contents.data());
-}
-
-void QWebEngineScriptCollectionPrivate::reserve(int capacity)
-{
- m_scripts.reserve(capacity);
- if (!m_contents || m_contents->isInitialized())
- m_scriptController->reserve(m_contents.data(), capacity);
-}
-
-void QWebEngineScriptCollectionPrivate::initializationFinished(QSharedPointer<QtWebEngineCore::WebContentsAdapter> contents)
-{
- Q_ASSERT(m_contents);
- Q_ASSERT(contents);
-
- for (const QWebEngineScript &script : qAsConst(m_scripts))
- m_scriptController->addUserScript(*script.d, contents.data());
- m_contents = contents;
-}
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.h b/src/webenginewidgets/api/qwebenginescriptcollection.h
deleted file mode 100644
index e68dfce8f..000000000
--- a/src/webenginewidgets/api/qwebenginescriptcollection.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINESCRIPTCOLLECTION_H
-#define QWEBENGINESCRIPTCOLLECTION_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtWebEngineWidgets/qwebenginescript.h>
-
-#include <QtCore/qscopedpointer.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qset.h>
-
-QT_BEGIN_NAMESPACE
-class QWebEngineScriptCollectionPrivate;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineScriptCollection {
-public:
- ~QWebEngineScriptCollection();
- bool isEmpty() const { return !count(); }
- int count() const;
- inline int size() const { return count(); }
- bool contains(const QWebEngineScript &value) const;
-
- QWebEngineScript findScript(const QString &name) const;
- QList<QWebEngineScript> findScripts(const QString &name) const;
-
- void insert(const QWebEngineScript &);
- void insert(const QList<QWebEngineScript> &list);
-
- bool remove(const QWebEngineScript &);
- void clear();
-
- QList<QWebEngineScript> toList() const;
-
-private:
- Q_DISABLE_COPY(QWebEngineScriptCollection)
- friend class QWebEnginePagePrivate;
- friend class QWebEngineProfilePrivate;
- QWebEngineScriptCollection(QWebEngineScriptCollectionPrivate *);
-
- QScopedPointer<QWebEngineScriptCollectionPrivate> d;
-};
-
-QT_END_NAMESPACE
-#endif // QWEBENGINESCRIPTCOLLECTION_H
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection_p.h b/src/webenginewidgets/api/qwebenginescriptcollection_p.h
deleted file mode 100644
index 322ade3b6..000000000
--- a/src/webenginewidgets/api/qwebenginescriptcollection_p.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINESCRIPTCOLLECTION_P_H
-#define QWEBENGINESCRIPTCOLLECTION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qtwebenginewidgetsglobal.h"
-
-#include "qwebenginescript.h"
-#include "web_contents_adapter.h"
-
-#include <QtCore/QSet>
-#include <QtCore/QSharedPointer>
-
-namespace QtWebEngineCore {
-class UserResourceControllerHost;
-} // namespace
-
-QT_BEGIN_NAMESPACE
-class QWebEngineScriptCollectionPrivate {
-public:
- QWebEngineScriptCollectionPrivate(QtWebEngineCore::UserResourceControllerHost *, QSharedPointer<QtWebEngineCore::WebContentsAdapter> = QSharedPointer<QtWebEngineCore::WebContentsAdapter>());
-
- int count() const;
- bool contains(const QWebEngineScript &) const;
- QList<QWebEngineScript> toList(const QString &scriptName = QString()) const;
- QWebEngineScript find(const QString & name) const;
-
- void initializationFinished(QSharedPointer<QtWebEngineCore::WebContentsAdapter> contents);
-
- void insert(const QWebEngineScript &);
- bool remove(const QWebEngineScript &);
- void clear();
- void reserve(int);
-
-private:
- QtWebEngineCore::UserResourceControllerHost *m_scriptController;
- QSharedPointer<QtWebEngineCore::WebContentsAdapter> m_contents;
- QList<QWebEngineScript> m_scripts;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINESCRIPTCOLLECTION__PH
diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp
deleted file mode 100644
index d9fb3b000..000000000
--- a/src/webenginewidgets/api/qwebenginesettings.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qwebenginesettings.h"
-
-#include "qwebengineprofile.h"
-#include "web_engine_settings.h"
-
-QT_BEGIN_NAMESPACE
-
-using QtWebEngineCore::WebEngineSettings;
-
-static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::WebAttribute attribute)
-{
- switch (attribute) {
- case QWebEngineSettings::AutoLoadImages:
- return WebEngineSettings::AutoLoadImages;
- case QWebEngineSettings::JavascriptEnabled:
- return WebEngineSettings::JavascriptEnabled;
- case QWebEngineSettings::JavascriptCanOpenWindows:
- return WebEngineSettings::JavascriptCanOpenWindows;
- case QWebEngineSettings::JavascriptCanAccessClipboard:
- return WebEngineSettings::JavascriptCanAccessClipboard;
- case QWebEngineSettings::LinksIncludedInFocusChain:
- return WebEngineSettings::LinksIncludedInFocusChain;
- case QWebEngineSettings::LocalStorageEnabled:
- return WebEngineSettings::LocalStorageEnabled;
- case QWebEngineSettings::LocalContentCanAccessRemoteUrls:
- return WebEngineSettings::LocalContentCanAccessRemoteUrls;
- case QWebEngineSettings::XSSAuditingEnabled:
- return WebEngineSettings::XSSAuditingEnabled;
- case QWebEngineSettings::SpatialNavigationEnabled:
- return WebEngineSettings::SpatialNavigationEnabled;
- case QWebEngineSettings::LocalContentCanAccessFileUrls:
- return WebEngineSettings::LocalContentCanAccessFileUrls;
- case QWebEngineSettings::HyperlinkAuditingEnabled:
- return WebEngineSettings::HyperlinkAuditingEnabled;
- case QWebEngineSettings::ScrollAnimatorEnabled:
- return WebEngineSettings::ScrollAnimatorEnabled;
- case QWebEngineSettings::ErrorPageEnabled:
- return WebEngineSettings::ErrorPageEnabled;
- case QWebEngineSettings::PluginsEnabled:
- return WebEngineSettings::PluginsEnabled;
- case QWebEngineSettings::FullScreenSupportEnabled:
- return WebEngineSettings::FullScreenSupportEnabled;
- case QWebEngineSettings::ScreenCaptureEnabled:
- return WebEngineSettings::ScreenCaptureEnabled;
- case QWebEngineSettings::WebGLEnabled:
- return WebEngineSettings::WebGLEnabled;
- case QWebEngineSettings::Accelerated2dCanvasEnabled:
- return WebEngineSettings::Accelerated2dCanvasEnabled;
- case QWebEngineSettings::AutoLoadIconsForPage:
- return WebEngineSettings::AutoLoadIconsForPage;
- case QWebEngineSettings::TouchIconsEnabled:
- return WebEngineSettings::TouchIconsEnabled;
- case QWebEngineSettings::FocusOnNavigationEnabled:
- return WebEngineSettings::FocusOnNavigationEnabled;
- case QWebEngineSettings::PrintElementBackgrounds:
- return WebEngineSettings::PrintElementBackgrounds;
- case QWebEngineSettings::AllowRunningInsecureContent:
- return WebEngineSettings::AllowRunningInsecureContent;
- case QWebEngineSettings::AllowGeolocationOnInsecureOrigins:
- return WebEngineSettings::AllowGeolocationOnInsecureOrigins;
- case QWebEngineSettings::AllowWindowActivationFromJavaScript:
- return WebEngineSettings::AllowWindowActivationFromJavaScript;
- case QWebEngineSettings::ShowScrollBars:
- return WebEngineSettings::ShowScrollBars;
- case QWebEngineSettings::PlaybackRequiresUserGesture:
- return WebEngineSettings::PlaybackRequiresUserGesture;
- case QWebEngineSettings::WebRTCPublicInterfacesOnly:
- return WebEngineSettings::WebRTCPublicInterfacesOnly;
- case QWebEngineSettings::JavascriptCanPaste:
- return WebEngineSettings::JavascriptCanPaste;
- case QWebEngineSettings::DnsPrefetchEnabled:
- return WebEngineSettings::DnsPrefetchEnabled;
- case QWebEngineSettings::PdfViewerEnabled:
- return WebEngineSettings::PdfViewerEnabled;
- default:
- return WebEngineSettings::UnsupportedInCoreSettings;
- }
-}
-
-QWebEngineSettings::QWebEngineSettings(QWebEngineSettings *parentSettings)
- : d_ptr(new WebEngineSettings(parentSettings ? parentSettings->d_func() : 0))
-{
- Q_D(QWebEngineSettings);
- d->scheduleApplyRecursively();
-}
-
-QWebEngineSettings::~QWebEngineSettings()
-{
-}
-
-#if QT_DEPRECATED_SINCE(5, 5)
-QWebEngineSettings *QWebEngineSettings::globalSettings()
-{
- return defaultSettings();
-}
-#endif
-
-/*!
- Returns the settings for a web engine page that belongs to the default
- profile. All web pages not specifically created with another profile belong
- to the default profile.
-*/
-QWebEngineSettings *QWebEngineSettings::defaultSettings()
-{
- return QWebEngineProfile::defaultProfile()->settings();
-}
-
-ASSERT_ENUMS_MATCH(WebEngineSettings::StandardFont, QWebEngineSettings::StandardFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::FixedFont, QWebEngineSettings::FixedFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::SerifFont, QWebEngineSettings::SerifFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::SansSerifFont, QWebEngineSettings::SansSerifFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::CursiveFont, QWebEngineSettings::CursiveFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::FantasyFont, QWebEngineSettings::FantasyFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::PictographFont, QWebEngineSettings::PictographFont)
-
-void QWebEngineSettings::setFontFamily(QWebEngineSettings::FontFamily which, const QString &family)
-{
- Q_D(QWebEngineSettings);
- d->setFontFamily(static_cast<WebEngineSettings::FontFamily>(which), family);
-}
-
-QString QWebEngineSettings::fontFamily(QWebEngineSettings::FontFamily which) const
-{
- return d_ptr->fontFamily(static_cast<WebEngineSettings::FontFamily>(which));
-}
-
-void QWebEngineSettings::resetFontFamily(QWebEngineSettings::FontFamily which)
-{
- d_ptr->resetFontFamily(static_cast<WebEngineSettings::FontFamily>(which));
-}
-
-ASSERT_ENUMS_MATCH(WebEngineSettings::DefaultFixedFontSize, QWebEngineSettings::DefaultFixedFontSize)
-ASSERT_ENUMS_MATCH(WebEngineSettings::DefaultFontSize, QWebEngineSettings::DefaultFontSize)
-ASSERT_ENUMS_MATCH(WebEngineSettings::MinimumFontSize, QWebEngineSettings::MinimumFontSize)
-ASSERT_ENUMS_MATCH(WebEngineSettings::MinimumLogicalFontSize, QWebEngineSettings::MinimumLogicalFontSize)
-
-void QWebEngineSettings::setFontSize(QWebEngineSettings::FontSize type, int size)
-{
- Q_D(QWebEngineSettings);
- d->setFontSize(static_cast<WebEngineSettings::FontSize>(type), size);
-}
-
-int QWebEngineSettings::fontSize(QWebEngineSettings::FontSize type) const
-{
- Q_D(const QWebEngineSettings);
- return d->fontSize(static_cast<WebEngineSettings::FontSize>(type));
-}
-
-void QWebEngineSettings::resetFontSize(QWebEngineSettings::FontSize type)
-{
- Q_D(QWebEngineSettings);
- d->resetFontSize(static_cast<WebEngineSettings::FontSize>(type));
-}
-
-void QWebEngineSettings::setDefaultTextEncoding(const QString &encoding)
-{
- Q_D(QWebEngineSettings);
- d->setDefaultTextEncoding(encoding);
-}
-
-QString QWebEngineSettings::defaultTextEncoding() const
-{
- Q_D(const QWebEngineSettings);
- return d->defaultTextEncoding();
-}
-
-ASSERT_ENUMS_MATCH(WebEngineSettings::DisallowUnknownUrlSchemes, QWebEngineSettings::DisallowUnknownUrlSchemes)
-ASSERT_ENUMS_MATCH(WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction)
-ASSERT_ENUMS_MATCH(WebEngineSettings::AllowAllUnknownUrlSchemes, QWebEngineSettings::AllowAllUnknownUrlSchemes)
-
-QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const
-{
- Q_D(const QWebEngineSettings);
- WebEngineSettings::UnknownUrlSchemePolicy result = d->unknownUrlSchemePolicy();
- Q_ASSERT(result != WebEngineSettings::InheritedUnknownUrlSchemePolicy);
- return static_cast<QWebEngineSettings::UnknownUrlSchemePolicy>(result);
-}
-
-void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy)
-{
- Q_D(QWebEngineSettings);
- d->setUnknownUrlSchemePolicy(static_cast<WebEngineSettings::UnknownUrlSchemePolicy>(policy));
-}
-
-void QWebEngineSettings::resetUnknownUrlSchemePolicy()
-{
- Q_D(QWebEngineSettings);
- d->setUnknownUrlSchemePolicy(WebEngineSettings::InheritedUnknownUrlSchemePolicy);
-}
-
-void QWebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool on)
-{
- Q_D(QWebEngineSettings);
- WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
- Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
- d->setAttribute(webEngineAttribute, on);
-}
-
-bool QWebEngineSettings::testAttribute(QWebEngineSettings::WebAttribute attr) const
-{
- Q_D(const QWebEngineSettings);
- WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
- Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
- return d->testAttribute(webEngineAttribute);
-}
-
-void QWebEngineSettings::resetAttribute(QWebEngineSettings::WebAttribute attr)
-{
- Q_D(QWebEngineSettings);
- WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
- Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
- d->resetAttribute(webEngineAttribute);
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h
deleted file mode 100644
index d39291fed..000000000
--- a/src/webenginewidgets/api/qwebenginesettings.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINESETTINGS_H
-#define QWEBENGINESETTINGS_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtCore/qscopedpointer.h>
-#include <QtCore/qstring.h>
-
-namespace QtWebEngineCore {
-class WebEngineSettings;
-}
-
-QT_BEGIN_NAMESPACE
-
-class QIcon;
-class QPixmap;
-class QUrl;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineSettings {
-public:
- enum FontFamily {
- StandardFont,
- FixedFont,
- SerifFont,
- SansSerifFont,
- CursiveFont,
- FantasyFont,
- PictographFont
- };
- enum WebAttribute {
- AutoLoadImages,
- JavascriptEnabled,
- JavascriptCanOpenWindows,
- JavascriptCanAccessClipboard,
- LinksIncludedInFocusChain,
- LocalStorageEnabled,
- LocalContentCanAccessRemoteUrls,
- XSSAuditingEnabled,
- SpatialNavigationEnabled,
- LocalContentCanAccessFileUrls,
- HyperlinkAuditingEnabled,
- ScrollAnimatorEnabled,
- ErrorPageEnabled,
- PluginsEnabled,
- FullScreenSupportEnabled,
- ScreenCaptureEnabled,
- WebGLEnabled,
- Accelerated2dCanvasEnabled,
- AutoLoadIconsForPage,
- TouchIconsEnabled,
- FocusOnNavigationEnabled,
- PrintElementBackgrounds,
- AllowRunningInsecureContent,
- AllowGeolocationOnInsecureOrigins,
- AllowWindowActivationFromJavaScript,
- ShowScrollBars,
- PlaybackRequiresUserGesture,
- WebRTCPublicInterfacesOnly,
- JavascriptCanPaste,
- DnsPrefetchEnabled,
- PdfViewerEnabled,
- };
-
- enum FontSize {
- MinimumFontSize,
- MinimumLogicalFontSize,
- DefaultFontSize,
- DefaultFixedFontSize
- };
-
- enum UnknownUrlSchemePolicy {
- DisallowUnknownUrlSchemes = 1,
- AllowUnknownUrlSchemesFromUserInteraction,
- AllowAllUnknownUrlSchemes
- };
-
-#if QT_DEPRECATED_SINCE(5, 5)
- static QWebEngineSettings *globalSettings();
-#endif
- static QWebEngineSettings *defaultSettings();
-
- void setFontFamily(FontFamily which, const QString &family);
- QString fontFamily(FontFamily which) const;
- void resetFontFamily(FontFamily which);
-
- void setFontSize(FontSize type, int size);
- int fontSize(FontSize type) const;
- void resetFontSize(FontSize type);
-
- void setAttribute(WebAttribute attr, bool on);
- bool testAttribute(WebAttribute attr) const;
- void resetAttribute(WebAttribute attr);
-
- void setDefaultTextEncoding(const QString &encoding);
- QString defaultTextEncoding() const;
-
- UnknownUrlSchemePolicy unknownUrlSchemePolicy() const;
- void setUnknownUrlSchemePolicy(UnknownUrlSchemePolicy policy);
- void resetUnknownUrlSchemePolicy();
-
-private:
- Q_DISABLE_COPY(QWebEngineSettings)
- typedef ::QtWebEngineCore::WebEngineSettings QWebEngineSettingsPrivate;
- QWebEngineSettingsPrivate* d_func() { return d_ptr.data(); }
- const QWebEngineSettingsPrivate* d_func() const { return d_ptr.data(); }
- QScopedPointer<QWebEngineSettingsPrivate> d_ptr;
- friend class QWebEnginePagePrivate;
- friend class QWebEngineProfilePrivate;
-
- ~QWebEngineSettings();
- explicit QWebEngineSettings(QWebEngineSettings *parentSettings = Q_NULLPTR);
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINESETTINGS_H
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index b1346f65e..0891f9ca8 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -41,9 +41,13 @@
#include "qwebengineview_p.h"
#include "qwebenginepage_p.h"
+#include "qwebengineprofile.h"
#include "render_widget_host_view_qt_delegate_widget.h"
#include "web_contents_adapter.h"
-
+#include "file_picker_controller.h"
+#include "qwebenginenotificationpresenter_p.h"
+#include "color_chooser_controller.h"
+#include <QStandardPaths>
#if QT_CONFIG(action)
#include <QAction>
#endif
@@ -53,6 +57,28 @@
#include <QContextMenuEvent>
#include <QToolTip>
#include <QVBoxLayout>
+#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 <QStyle>
+#include <QGuiApplication>
QT_BEGIN_NAMESPACE
@@ -133,6 +159,182 @@ void QWebEngineViewPrivate::widgetChanged(QtWebEngineCore::RenderWidgetHostViewQ
}
}
+void QWebEngineViewPrivate::contextMenuRequested(QWebEngineContextMenuRequest *request)
+{
+#if QT_CONFIG(action)
+ m_contextRequest = request;
+ switch (q_ptr->contextMenuPolicy()) {
+ case Qt::DefaultContextMenu: {
+ QContextMenuEvent event(QContextMenuEvent::Mouse, request->position(),
+ q_ptr->mapToGlobal(request->position()));
+ q_ptr->contextMenuEvent(&event);
+ return;
+ }
+ case Qt::CustomContextMenu:
+ Q_EMIT q_ptr->customContextMenuRequested(request->position());
+ return;
+ case Qt::ActionsContextMenu:
+ if (q_ptr->actions().count()) {
+ QContextMenuEvent event(QContextMenuEvent::Mouse, request->position(),
+ q_ptr->mapToGlobal(request->position()));
+ QMenu::exec(q_ptr->actions(), event.globalPos(), 0, q_ptr);
+ }
+ return;
+ case Qt::PreventContextMenu:
+ case Qt::NoContextMenu:
+ return;
+ }
+
+ Q_UNREACHABLE();
+#else
+ Q_UNUSED(data);
+#endif // QT_CONFIG(action)
+}
+
+QStringList QWebEngineViewPrivate::chooseFiles(QWebEnginePage::FileSelectionMode mode,
+ const QStringList &oldFiles,
+ const QStringList &acceptedMimeTypes)
+{
+#if QT_CONFIG(filedialog)
+ Q_Q(QWebEngineView);
+ const QStringList &filter =
+ QtWebEngineCore::FilePickerController::nameFilters(acceptedMimeTypes);
+ QStringList ret;
+ QString str;
+ switch (static_cast<QtWebEngineCore::FilePickerController::FileChooserMode>(mode)) {
+ case QtWebEngineCore::FilePickerController::OpenMultiple:
+ ret = QFileDialog::getOpenFileNames(q, QString(), QString(),
+ filter.join(QStringLiteral(";;")), nullptr,
+ QFileDialog::HideNameFilterDetails);
+ break;
+ // Chromium extension, not exposed as part of the public API for now.
+ case QtWebEngineCore::FilePickerController::UploadFolder:
+ str = QFileDialog::getExistingDirectory(q, QObject::tr("Select folder to upload"));
+ if (!str.isNull())
+ ret << str;
+ break;
+ case QtWebEngineCore::FilePickerController::Save:
+ str = QFileDialog::getSaveFileName(
+ q, QString(),
+ (QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)
+ + oldFiles.first()));
+ if (!str.isNull())
+ ret << str;
+ break;
+ case QtWebEngineCore::FilePickerController::Open:
+ str = QFileDialog::getOpenFileName(q, QString(), oldFiles.first(),
+ filter.join(QStringLiteral(";;")), nullptr,
+ QFileDialog::HideNameFilterDetails);
+ if (!str.isNull())
+ ret << str;
+ break;
+ }
+ return ret;
+#else
+ Q_UNUSED(mode);
+ Q_UNUSED(oldFiles);
+ Q_UNUSED(acceptedMimeTypes);
+
+ return QStringList();
+#endif // QT_CONFIG(filedialog)
+}
+
+void QWebEngineViewPrivate::showColorDialog(
+ QSharedPointer<QtWebEngineCore::ColorChooserController> controller)
+{
+#if QT_CONFIG(colordialog)
+ Q_Q(QWebEngineView);
+ QColorDialog *dialog = new QColorDialog(controller.data()->initialColor(), q);
+
+ QColorDialog::connect(dialog, SIGNAL(colorSelected(QColor)), controller.data(),
+ SLOT(accept(QColor)));
+ QColorDialog::connect(dialog, SIGNAL(rejected()), controller.data(), SLOT(reject()));
+
+ // Delete when done
+ QColorDialog::connect(dialog, SIGNAL(colorSelected(QColor)), dialog, SLOT(deleteLater()));
+ QColorDialog::connect(dialog, SIGNAL(rejected()), dialog, SLOT(deleteLater()));
+
+ dialog->open();
+#else
+ Q_UNUSED(controller);
+#endif
+}
+
+bool QWebEngineViewPrivate::showAuthorizationDialog(const QString &title, const QString &message)
+{
+#if QT_CONFIG(messagebox)
+ Q_Q(QWebEngineView);
+ return QMessageBox::question(q, title, message, QMessageBox::Yes, QMessageBox::No)
+ == QMessageBox::Yes;
+#else
+ return false;
+#endif // QT_CONFIG(messagebox)
+}
+
+void QWebEngineViewPrivate::javaScriptAlert(const QUrl &url, const QString &msg)
+{
+#if QT_CONFIG(messagebox)
+ Q_Q(QWebEngineView);
+ QMessageBox::information(q, QStringLiteral("Javascript Alert - %1").arg(url.toString()),
+ msg.toHtmlEscaped());
+#else
+ Q_UNUSED(msg);
+#endif // QT_CONFIG(messagebox)
+}
+
+bool QWebEngineViewPrivate::javaScriptConfirm(const QUrl &url, const QString &msg)
+{
+#if QT_CONFIG(messagebox)
+ Q_Q(QWebEngineView);
+ return (QMessageBox::information(q,
+ QStringLiteral("Javascript Confirm - %1").arg(url.toString()),
+ msg.toHtmlEscaped(), QMessageBox::Ok, QMessageBox::Cancel)
+ == QMessageBox::Ok);
+#else
+ Q_UNUSED(msg);
+ return false;
+#endif // QT_CONFIG(messagebox)
+}
+
+bool QWebEngineViewPrivate::javaScriptPrompt(const QUrl &url, const QString &msg,
+ const QString &defaultValue, QString *result)
+{
+#if QT_CONFIG(inputdialog)
+ Q_Q(QWebEngineView);
+ bool ret = false;
+ if (result)
+ *result = QInputDialog::getText(
+ q, QStringLiteral("Javascript Prompt - %1").arg(url.toString()),
+ msg.toHtmlEscaped(), QLineEdit::Normal, defaultValue.toHtmlEscaped(), &ret);
+ return ret;
+#else
+ Q_UNUSED(msg);
+ Q_UNUSED(defaultValue);
+ Q_UNUSED(result);
+ return false;
+#endif // QT_CONFIG(inputdialog)
+}
+
+void QWebEngineViewPrivate::focusContainer()
+{
+ Q_Q(QWebEngineView);
+ q->activateWindow();
+ q->setFocus();
+}
+
+void QWebEngineViewPrivate::unhandledKeyEvent(QKeyEvent *event)
+{
+ Q_Q(QWebEngineView);
+ if (q->parentWidget())
+ QGuiApplication::sendEvent(q->parentWidget(), event);
+}
+
+bool QWebEngineViewPrivate::passOnFocus(bool reverse)
+{
+ Q_Q(QWebEngineView);
+ return q->focusNextPrevChild(!reverse);
+}
+
#ifndef QT_NO_ACCESSIBILITY
static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object)
{
@@ -143,15 +345,179 @@ static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *obje
#endif // QT_NO_ACCESSIBILITY
QWebEngineViewPrivate::QWebEngineViewPrivate()
- : page(0)
- , m_dragEntered(false)
- , m_ownsPage(false)
+ : page(0), m_dragEntered(false), m_ownsPage(false), m_contextRequest(nullptr)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installFactory(&webAccessibleFactory);
#endif // QT_NO_ACCESSIBILITY
}
+QWebEngineViewPrivate::~QWebEngineViewPrivate() = default;
+
+void QWebEngineViewPrivate::bindPageAndView(QWebEnginePage *page, QWebEngineView *view)
+{
+ QWebEngineViewPrivate *v =
+ page ? static_cast<QWebEngineViewPrivate *>(page->d_func()->view) : nullptr;
+ auto oldView = v ? v->q_func() : nullptr;
+ auto oldPage = view ? view->d_func()->page : nullptr;
+
+ bool ownNewPage = false;
+ bool deleteOldPage = false;
+
+ // Change pointers first.
+
+ if (page && oldView != view) {
+ if (oldView) {
+ ownNewPage = oldView->d_func()->m_ownsPage;
+ oldView->d_func()->page = nullptr;
+ oldView->d_func()->m_ownsPage = false;
+ }
+ page->d_func()->view = view ? view->d_func() : nullptr;
+ }
+
+ if (view && oldPage != page) {
+ if (oldPage) {
+ if (oldPage->d_func())
+ oldPage->d_func()->view = nullptr;
+ deleteOldPage = view->d_func()->m_ownsPage;
+ }
+ view->d_func()->m_ownsPage = ownNewPage;
+ view->d_func()->page = page;
+ }
+
+ // Then notify.
+
+ auto widget = page ? page->d_func()->widget : nullptr;
+ auto oldWidget = (oldPage && oldPage->d_func()) ? oldPage->d_func()->widget : nullptr;
+
+ if (page && oldView != view && oldView) {
+ oldView->d_func()->pageChanged(page, nullptr);
+ if (widget)
+ oldView->d_func()->widgetChanged(widget, nullptr);
+ }
+
+ if (view && oldPage != page) {
+ if (oldPage && oldPage->d_func())
+ view->d_func()->pageChanged(oldPage, page);
+ else
+ view->d_func()->pageChanged(nullptr, page);
+ if (oldWidget != widget)
+ view->d_func()->widgetChanged(oldWidget, widget);
+ }
+ if (deleteOldPage)
+ delete oldPage;
+}
+
+void QWebEngineViewPrivate::bindPageAndWidget(
+ QWebEnginePage *page, QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget)
+{
+ auto oldPage = widget ? widget->m_page : nullptr;
+ auto oldWidget = page ? page->d_func()->widget : nullptr;
+
+ // Change pointers first.
+
+ if (widget && oldPage != page) {
+ if (oldPage && oldPage->d_func())
+ oldPage->d_func()->widget = nullptr;
+ widget->m_page = page;
+ }
+
+ if (page && oldWidget != widget) {
+ if (oldWidget)
+ oldWidget->m_page = nullptr;
+ page->d_func()->widget = widget;
+ }
+
+ // Then notify.
+
+ if (widget && oldPage != page && oldPage && oldPage->d_func()) {
+ if (auto oldView = oldPage->d_func()->view)
+ static_cast<QWebEngineViewPrivate *>(oldView)->widgetChanged(widget, nullptr);
+ }
+
+ if (page && oldWidget != widget) {
+ if (auto view = page->d_func()->view)
+ static_cast<QWebEngineViewPrivate *>(view)->widgetChanged(oldWidget, widget);
+ }
+}
+
+QIcon QWebEngineViewPrivate::webActionIcon(QWebEnginePage::WebAction action)
+{
+ Q_Q(QWebEngineView);
+ QIcon icon;
+ QStyle *style = q->style();
+
+ switch (action) {
+ case QWebEnginePage::Back:
+ icon = style->standardIcon(QStyle::SP_ArrowBack);
+ break;
+ case QWebEnginePage::Forward:
+ icon = style->standardIcon(QStyle::SP_ArrowForward);
+ break;
+ case QWebEnginePage::Stop:
+ icon = style->standardIcon(QStyle::SP_BrowserStop);
+ break;
+ case QWebEnginePage::Reload:
+ icon = style->standardIcon(QStyle::SP_BrowserReload);
+ break;
+ case QWebEnginePage::ReloadAndBypassCache:
+ icon = style->standardIcon(QStyle::SP_BrowserReload);
+ break;
+ default:
+ break;
+ }
+ return icon;
+}
+
+QWebEnginePage *QWebEngineViewPrivate::createPageForWindow(QWebEnginePage::WebWindowType type)
+{
+ Q_Q(QWebEngineView);
+ QWebEngineView *newView = q->createWindow(type);
+ if (newView)
+ return newView->page();
+ return nullptr;
+}
+
+void QWebEngineViewPrivate::setToolTip(const QString &toolTipText)
+{
+ Q_Q(QWebEngineView);
+ q->setToolTip(toolTipText);
+}
+
+bool QWebEngineViewPrivate::isEnabled() const
+{
+ Q_Q(const QWebEngineView);
+ return q->isEnabled();
+}
+
+QObject *QWebEngineViewPrivate::accessibilityParentObject()
+{
+ Q_Q(QWebEngineView);
+ return q;
+}
+
+bool QWebEngineViewPrivate::isVisible() const
+{
+ Q_Q(const QWebEngineView);
+ return q->isVisible();
+}
+QRect QWebEngineViewPrivate::viewportRect() const
+{
+ Q_Q(const QWebEngineView);
+ return q->rect();
+}
+QtWebEngineCore::RenderWidgetHostViewQtDelegate *
+QWebEngineViewPrivate::CreateRenderWidgetHostViewQtDelegate(
+ QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client)
+{
+ Q_Q(QWebEngineView);
+ return new QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget(client, q);
+}
+
+QWebEngineContextMenuRequest *QWebEngineViewPrivate::lastContextMenuRequest() const
+{
+ return m_contextRequest;
+}
/*!
\fn QWebEngineView::renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode)
\since 5.6
@@ -187,7 +553,7 @@ QWebEngineView::QWebEngineView(QWidget *parent)
QWebEngineView::~QWebEngineView()
{
blockSignals(true);
- QWebEnginePagePrivate::bindPageAndView(nullptr, this);
+ QWebEngineViewPrivate::bindPageAndView(nullptr, this);
}
QWebEnginePage* QWebEngineView::page() const
@@ -203,7 +569,12 @@ QWebEnginePage* QWebEngineView::page() const
void QWebEngineView::setPage(QWebEnginePage *newPage)
{
- QWebEnginePagePrivate::bindPageAndView(newPage, this);
+ QWebEngineViewPrivate::bindPageAndView(newPage, this);
+ connect(newPage, &QWebEnginePage::_q_aboutToDelete, this,
+ [newPage]() { QWebEngineViewPrivate::bindPageAndView(newPage, nullptr); });
+ auto profile = newPage->profile();
+ if (!profile->notificationPresenter())
+ profile->setNotificationPresenter(&defaultNotificationPresenter);
}
void QWebEngineView::load(const QUrl& url)
@@ -334,7 +705,7 @@ void QWebEngineView::reload()
QWebEngineView *QWebEngineView::createWindow(QWebEnginePage::WebWindowType type)
{
- Q_UNUSED(type)
+ Q_UNUSED(type);
return 0;
}
@@ -386,7 +757,7 @@ bool QWebEngineView::event(QEvent *ev)
#if QT_CONFIG(contextmenu)
void QWebEngineView::contextMenuEvent(QContextMenuEvent *event)
{
- QMenu *menu = page()->createStandardContextMenu();
+ QMenu *menu = createStandardContextMenu();
menu->popup(event->globalPos());
}
#endif // QT_CONFIG(contextmenu)
@@ -429,7 +800,7 @@ void QWebEngineView::dragEnterEvent(QDragEnterEvent *e)
e->accept();
if (d->m_dragEntered)
d->page->d_ptr->adapter->leaveDrag();
- d->page->d_ptr->adapter->enterDrag(e, mapToGlobal(e->pos()));
+ d->page->d_ptr->adapter->enterDrag(e, mapToGlobal(e->position().toPoint()));
d->m_dragEntered = true;
}
@@ -455,7 +826,8 @@ void QWebEngineView::dragMoveEvent(QDragMoveEvent *e)
if (!d->m_dragEntered)
return;
QtWebEngineCore::WebContentsAdapter *adapter = d->page->d_ptr->adapter.data();
- Qt::DropAction dropAction = adapter->updateDragPosition(e, mapToGlobal(e->pos()));
+ Qt::DropAction dropAction =
+ adapter->updateDragPosition(e, mapToGlobal(e->position().toPoint()));
if (Qt::IgnoreAction == dropAction) {
e->ignore();
} else {
@@ -473,11 +845,40 @@ void QWebEngineView::dropEvent(QDropEvent *e)
if (!d->m_dragEntered)
return;
e->accept();
- d->page->d_ptr->adapter->endDragging(e, mapToGlobal(e->pos()));
+ d->page->d_ptr->adapter->endDragging(e, mapToGlobal(e->position().toPoint()));
d->m_dragEntered = false;
}
#endif // QT_CONFIG(draganddrop)
+#if QT_CONFIG(menu)
+QMenu *QWebEngineView::createStandardContextMenu()
+{
+ Q_D(QWebEngineView);
+ QMenu *menu = new QMenu(this);
+ QContextMenuBuilder contextMenuBuilder(d->m_contextRequest, this, menu);
+
+ contextMenuBuilder.initMenu();
+
+ menu->setAttribute(Qt::WA_DeleteOnClose, true);
+
+ return menu;
+}
+#endif // QT_CONFIG(menu)
+
+/*!
+ \since 6.0
+
+ Returns additional data about the current context menu. It is only guaranteed to be valid during
+ the call to the contextMenuEvent()
+
+ \sa createStandardContextMenu()
+*/
+QWebEngineContextMenuRequest *QWebEngineView::lastContextMenuRequest() const
+{
+ Q_D(const QWebEngineView);
+ return d->m_contextRequest;
+}
+
#ifndef QT_NO_ACCESSIBILITY
bool QWebEngineViewAccessible::isValid() const
{
@@ -517,6 +918,174 @@ int QWebEngineViewAccessible::indexOfChild(const QAccessibleInterface *c) const
}
#endif // QT_NO_ACCESSIBILITY
+#if QT_CONFIG(action)
+QContextMenuBuilder::QContextMenuBuilder(QWebEngineContextMenuRequest *request,
+ QWebEngineView *view, QMenu *menu)
+ : QtWebEngineCore::RenderViewContextMenuQt(request), m_view(view), m_menu(menu)
+{
+ m_view->page()->d_ptr->ensureInitialized();
+}
+
+bool QContextMenuBuilder::hasInspector()
+{
+ return m_view->page()->d_ptr->adapter->hasInspector();
+}
+
+bool QContextMenuBuilder::isFullScreenMode()
+{
+ return m_view->page()->d_ptr->isFullScreenMode();
+}
+
+void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem)
+{
+ QPointer<QWebEnginePage> thisRef(m_view->page());
+ QAction *action = 0;
+
+ switch (menuItem) {
+ case ContextMenuItem::Back:
+ action = thisRef->action(QWebEnginePage::Back);
+ break;
+ case ContextMenuItem::Forward:
+ action = thisRef->action(QWebEnginePage::Forward);
+ break;
+ case ContextMenuItem::Reload:
+ action = thisRef->action(QWebEnginePage::Reload);
+ break;
+ case ContextMenuItem::Cut:
+ action = thisRef->action(QWebEnginePage::Cut);
+ break;
+ case ContextMenuItem::Copy:
+ action = thisRef->action(QWebEnginePage::Copy);
+ break;
+ case ContextMenuItem::Paste:
+ action = thisRef->action(QWebEnginePage::Paste);
+ break;
+ case ContextMenuItem::Undo:
+ action = thisRef->action(QWebEnginePage::Undo);
+ break;
+ case ContextMenuItem::Redo:
+ action = thisRef->action(QWebEnginePage::Redo);
+ break;
+ case ContextMenuItem::SelectAll:
+ action = thisRef->action(QWebEnginePage::SelectAll);
+ break;
+ case ContextMenuItem::PasteAndMatchStyle:
+ action = thisRef->action(QWebEnginePage::PasteAndMatchStyle);
+ break;
+ case ContextMenuItem::OpenLinkInNewWindow:
+ action = thisRef->action(QWebEnginePage::OpenLinkInNewWindow);
+ break;
+ case ContextMenuItem::OpenLinkInNewTab:
+ action = thisRef->action(QWebEnginePage::OpenLinkInNewTab);
+ break;
+ case ContextMenuItem::CopyLinkToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyLinkToClipboard);
+ break;
+ case ContextMenuItem::DownloadLinkToDisk:
+ action = thisRef->action(QWebEnginePage::DownloadLinkToDisk);
+ break;
+ case ContextMenuItem::CopyImageToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyImageToClipboard);
+ break;
+ case ContextMenuItem::CopyImageUrlToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyImageUrlToClipboard);
+ break;
+ case ContextMenuItem::DownloadImageToDisk:
+ action = thisRef->action(QWebEnginePage::DownloadImageToDisk);
+ break;
+ case ContextMenuItem::CopyMediaUrlToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyMediaUrlToClipboard);
+ break;
+ case ContextMenuItem::ToggleMediaControls:
+ action = thisRef->action(QWebEnginePage::ToggleMediaControls);
+ break;
+ case ContextMenuItem::ToggleMediaLoop:
+ action = thisRef->action(QWebEnginePage::ToggleMediaLoop);
+ break;
+ case ContextMenuItem::DownloadMediaToDisk:
+ action = thisRef->action(QWebEnginePage::DownloadMediaToDisk);
+ break;
+ case ContextMenuItem::InspectElement:
+ action = thisRef->action(QWebEnginePage::InspectElement);
+ break;
+ case ContextMenuItem::ExitFullScreen:
+ action = thisRef->action(QWebEnginePage::ExitFullScreen);
+ break;
+ case ContextMenuItem::SavePage:
+ action = thisRef->action(QWebEnginePage::SavePage);
+ break;
+ case ContextMenuItem::ViewSource:
+ action = thisRef->action(QWebEnginePage::ViewSource);
+ break;
+ case ContextMenuItem::SpellingSuggestions:
+ for (int i = 0; i < m_contextData->spellCheckerSuggestions().count() && i < 4; i++) {
+ action = new QAction(m_menu);
+ QString replacement = m_contextData->spellCheckerSuggestions().at(i);
+ QObject::connect(action, &QAction::triggered, [thisRef, replacement] {
+ if (thisRef)
+ thisRef->replaceMisspelledWord(replacement);
+ });
+ action->setText(replacement);
+ m_menu->addAction(action);
+ }
+ return;
+ case ContextMenuItem::Separator:
+ if (!m_menu->isEmpty())
+ m_menu->addSeparator();
+ return;
+ }
+ action->setEnabled(isMenuItemEnabled(menuItem));
+ m_menu->addAction(action);
+}
+
+bool QContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem)
+{
+ switch (menuItem) {
+ case ContextMenuItem::Back:
+ return m_view->page()->d_ptr->adapter->canGoBack();
+ case ContextMenuItem::Forward:
+ return m_view->page()->d_ptr->adapter->canGoForward();
+ case ContextMenuItem::Reload:
+ return true;
+ case ContextMenuItem::Cut:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanCut;
+ case ContextMenuItem::Copy:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanCopy;
+ case ContextMenuItem::Paste:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste;
+ case ContextMenuItem::Undo:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanUndo;
+ case ContextMenuItem::Redo:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanRedo;
+ case ContextMenuItem::SelectAll:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanSelectAll;
+ case ContextMenuItem::PasteAndMatchStyle:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste;
+ case ContextMenuItem::OpenLinkInNewWindow:
+ case ContextMenuItem::OpenLinkInNewTab:
+ case ContextMenuItem::CopyLinkToClipboard:
+ case ContextMenuItem::DownloadLinkToDisk:
+ case ContextMenuItem::CopyImageToClipboard:
+ case ContextMenuItem::CopyImageUrlToClipboard:
+ case ContextMenuItem::DownloadImageToDisk:
+ case ContextMenuItem::CopyMediaUrlToClipboard:
+ case ContextMenuItem::ToggleMediaControls:
+ case ContextMenuItem::ToggleMediaLoop:
+ case ContextMenuItem::DownloadMediaToDisk:
+ case ContextMenuItem::InspectElement:
+ case ContextMenuItem::ExitFullScreen:
+ case ContextMenuItem::SavePage:
+ return true;
+ case ContextMenuItem::ViewSource:
+ return m_view->page()->d_ptr->adapter->canViewSource();
+ case ContextMenuItem::SpellingSuggestions:
+ case ContextMenuItem::Separator:
+ return true;
+ }
+ Q_UNREACHABLE();
+}
+#endif // QT_CONFIG(action)
+
QT_END_NAMESPACE
#include "moc_qwebengineview.cpp"
diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h
index 04c8ece74..d7f9d6a45 100644
--- a/src/webenginewidgets/api/qwebengineview.h
+++ b/src/webenginewidgets/api/qwebengineview.h
@@ -45,8 +45,9 @@
#include <QtWidgets/qwidget.h>
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtWebEngineWidgets/qwebenginepage.h>
+#include <QtWebEngineCore/qwebenginepage.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
+#include <QtWebEngineCore/qwebenginecontextmenurequest.h>
QT_BEGIN_NAMESPACE
class QContextMenuEvent;
@@ -101,6 +102,11 @@ public:
QSize sizeHint() const override;
QWebEngineSettings *settings() const;
+#if QT_CONFIG(menu)
+ QMenu *createStandardContextMenu();
+#endif
+ QWebEngineContextMenuRequest *lastContextMenuRequest() const;
+
public Q_SLOTS:
void stop();
void back();
diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h
index a3c619cea..47694ab24 100644
--- a/src/webenginewidgets/api/qwebengineview_p.h
+++ b/src/webenginewidgets/api/qwebengineview_p.h
@@ -52,18 +52,21 @@
//
#include <QtWebEngineWidgets/qwebengineview.h>
-
+#include "qwebenginecontextmenurequest.h"
+#include "render_view_context_menu_qt.h"
+#include "qwebenginepage_p.h"
#include <QtWidgets/qaccessiblewidget.h>
namespace QtWebEngineCore {
class RenderWidgetHostViewQtDelegateWidget;
+class RenderWidgetHostViewQtDelegate;
}
QT_BEGIN_NAMESPACE
class QWebEngineView;
-class QWebEngineViewPrivate
+class QWebEngineViewPrivate : public PageView
{
public:
Q_DECLARE_PUBLIC(QWebEngineView)
@@ -73,11 +76,38 @@ public:
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *oldWidget,
QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *newWidget);
+ void contextMenuRequested(QWebEngineContextMenuRequest *request) override;
+ QStringList chooseFiles(QWebEnginePage::FileSelectionMode mode, const QStringList &oldFiles,
+ const QStringList &acceptedMimeTypes) override;
+ void
+ showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController> controller) override;
+ bool showAuthorizationDialog(const QString &title, const QString &message) override;
+ void javaScriptAlert(const QUrl &url, const QString &msg) override;
+ bool javaScriptConfirm(const QUrl &url, const QString &msg) override;
+ bool javaScriptPrompt(const QUrl &url, const QString &msg, const QString &defaultValue,
+ QString *result) override;
+ void setToolTip(const QString &toolTipText) override;
+ QtWebEngineCore::RenderWidgetHostViewQtDelegate *CreateRenderWidgetHostViewQtDelegate(
+ QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
+ QWebEngineContextMenuRequest *lastContextMenuRequest() const override;
+ QWebEnginePage *createPageForWindow(QWebEnginePage::WebWindowType type) override;
+ QObject *accessibilityParentObject() override;
QWebEngineViewPrivate();
-
+ virtual ~QWebEngineViewPrivate();
+ static void bindPageAndView(QWebEnginePage *page, QWebEngineView *view);
+ static void bindPageAndWidget(QWebEnginePage *page,
+ QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget);
+ QIcon webActionIcon(QWebEnginePage::WebAction action);
+ void unhandledKeyEvent(QKeyEvent *event) override;
+ void focusContainer() override;
+ bool passOnFocus(bool reverse) override;
+ bool isEnabled() const override;
+ bool isVisible() const override;
+ QRect viewportRect() const override;
QWebEnginePage *page;
bool m_dragEntered;
mutable bool m_ownsPage;
+ QWebEngineContextMenuRequest *m_contextRequest;
};
#ifndef QT_NO_ACCESSIBILITY
@@ -98,6 +128,22 @@ private:
};
#endif // QT_NO_ACCESSIBILITY
+class QContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt
+{
+public:
+ QContextMenuBuilder(QWebEngineContextMenuRequest *reqeust, QWebEngineView *view, QMenu *menu);
+
+private:
+ virtual bool hasInspector() override;
+ virtual bool isFullScreenMode() override;
+
+ virtual void addMenuItem(ContextMenuItem entry) override;
+ virtual bool isMenuItemEnabled(ContextMenuItem entry) override;
+
+ QWebEngineView *m_view;
+ QMenu *m_menu;
+};
+
QT_END_NAMESPACE
#endif // QWEBENGINEVIEW_P_H
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index 789d9794e..5def0d65c 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -513,16 +513,13 @@
*/
/*!
- \fn bool QWebEnginePage::certificateError(const QWebEngineCertificateError & certificateError)
+ \fn void QWebEnginePage::certificateError(const QWebEngineCertificateError & certificateError)
This function is called when an invalid certificate error is raised while loading a given request.
- The \a certificateError parameter contains information about the certificate and details of the error.
-
- Return \c true to ignore the error and complete the request. Return \c false to stop loading
+ The \a certificateError parameter contains information about the certificate and details of the error,
+ it also provides the way to ignore the error and complete the request or stop loading
the request.
- \note If the error was successfully deferred then the returned value will be ignored.
-
\sa QWebEngineCertificateError
*/
diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
deleted file mode 100644
index b83da9440..000000000
--- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- Copyright (C) 2015 The Qt Company Ltd.
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-// The documentation in this file was imported from QtWebKit and is thus constrained
-// by its LGPL license. Documentation written from scratch for new methods should be
-// placed inline in the code as usual.
-
-#if QT_DEPRECATED_SINCE(5, 5)
-/*!
- \fn static QWebEngineSettings *QWebEngineSettings::globalSettings()
- \obsolete
-
- Use defaultSettings() instead.
-*/
-#endif
-
-/*!
- \class QWebEngineSettings
- \since 5.4
- \brief The QWebEngineSettings class provides an object to store the settings used
- by QWebEnginePage.
-
- \inmodule QtWebEngineWidgets
-
- QWebEngineSettings allows configuration of browser properties, such as font sizes and
- families, the location of a custom style sheet, and generic attributes, such as JavaScript
- support. Individual attributes are set using the setAttribute() function. The
- \l{QWebEngineSettings::WebAttribute}{WebAttribute} enum further describes each attribute.
-
- Each QWebEnginePage object has its own QWebEngineSettings object, which configures the
- settings for that page. If a setting is not configured for a web engine
- page, it is looked up in the settings of the profile the page belongs to.
-
- \sa QWebEnginePage::settings(), QWebEngineView::settings()
-*/
-
-/*!
- \enum QWebEngineSettings::FontFamily
-
- This enum describes the generic font families defined by CSS 2.
- For more information see the
- \l{http://www.w3.org/TR/REC-CSS2/fonts.html#generic-font-families}{CSS standard}.
-
- \value StandardFont
- \value FixedFont
- \value SerifFont
- \value SansSerifFont
- \value CursiveFont
- \value FantasyFont
- \value PictographFont
- (added in Qt 5.7)
-*/
-
-/*!
- \enum QWebEngineSettings::FontSize
-
- This enum describes the font sizes configurable through QWebEngineSettings:
-
- \value MinimumFontSize The hard minimum font size.
- \value MinimumLogicalFontSize The minimum logical font size that is applied
- when zooming out.
- \value DefaultFontSize The default font size for regular text.
- \value DefaultFixedFontSize The default font size for fixed-pitch text.
-*/
-
-/*!
- \enum QWebEngineSettings::WebAttribute
-
- This enum type specifies settings for web pages:
-
- \value AutoLoadImages
- Automatically dowloads images for web pages. When this setting is
- disabled, images are loaded from the cache. Enabled by default.
- \value JavascriptEnabled
- Enables the running of JavaScript programs in the
- \l{QWebEngineScript::MainWorld}{MainWorld}. Enabled by default.
- \value JavascriptCanOpenWindows
- Allows JavaScript programs to open popup windows without user
- interaction. Enabled by default.
- \value JavascriptCanAccessClipboard
- Allows JavaScript programs to read from and write to the clipboard.
- Writing to the clipboard is always allowed if it is specifically requested by the user.
- See JavascriptCanPaste to also allow pasting the content of the clipboard content from
- JavaScript.
- Disabled by default.
- \value LinksIncludedInFocusChain
- Includes hyperlinks in the keyboard focus chain. Enabled by default.
- \value LocalStorageEnabled
- Enables support for the HTML 5 local storage feature. Enabled by default.
- \value LocalContentCanAccessRemoteUrls
- Allows locally loaded documents to ignore cross-origin rules so that they can access
- remote resources that would normally be blocked, because all remote resources are
- considered cross-origin for a local file. Remote access that would not be blocked by
- cross-origin rules is still possible when this setting is disabled (default).
- Note that disabling this setting does not stop XMLHttpRequests or media elements in
- local files from accessing remote content. Basically, it only stops some HTML
- subresources, such as scripts, and therefore disabling this setting is not a safety
- mechanism.
- \value XSSAuditingEnabled
- Obsolete and has no effect.
- \value SpatialNavigationEnabled
- Enables the Spatial Navigation feature, which means the ability to navigate between
- focusable elements, such as hyperlinks and form controls, on a web page by using the
- Left, Right, Up and Down arrow keys. For example, if a user presses the
- Right key, heuristics determine whether there is an element they might be
- trying to reach towards the right and which element they probably want.
- Disabled by default.
- \value LocalContentCanAccessFileUrls
- Allows locally loaded documents to access other local URLs. Enabled by default.
- \value HyperlinkAuditingEnabled
- Enables support for the \c ping attribute for hyperlinks. Disabled by default.
- \value ScrollAnimatorEnabled
- Enables animated scrolling. Disabled by default.
- \value ErrorPageEnabled
- Enables displaying the built-in error pages of Chromium. Enabled by default.
- \value PluginsEnabled
- Enables support for Pepper plugins, such as the Flash player. Disabled by default.
- See also \l{Pepper Plugin API}. (Added in Qt 5.6)
- \value FullScreenSupportEnabled
- Enables fullscreen support in an application. Disabled by default. (Added in Qt 5.6)
- \value ScreenCaptureEnabled
- Enables screen capture in an application. Disabled by default. (Added in Qt 5.7)
- \value WebGLEnabled
- Enables support for HTML 5 WebGL. Enabled by default if available. (Added in Qt 5.7)
- \value Accelerated2dCanvasEnabled
- Specifies whether the HTML5 2D canvas should be a OpenGL framebuffer.
- This makes many painting operations faster, but slows down pixel access. Enabled by default if available. (Added in Qt 5.7)
- \value AutoLoadIconsForPage
- Automatically downloads icons for web pages. Enabled by default. (Added in Qt 5.7)
- \value TouchIconsEnabled
- Enables support for touch icons and precomposed touch icons
- Disabled by default. (Added in Qt 5.7)
- \value FocusOnNavigationEnabled
- Gives focus to the view associated with the page, whenever a navigation operation occurs
- (load, stop, reload, reload and bypass cache, forward, backward, set content, and so
- on).
- Disabled by default. (Added in Qt 5.8)
- \value PrintElementBackgrounds
- Turns on printing of CSS backgrounds when printing a web page.
- Enabled by default. (Added in Qt 5.8)
- \value AllowRunningInsecureContent
- By default, HTTPS pages cannot run JavaScript, CSS, plugins or
- web-sockets from HTTP URLs. This provides an override to get
- the old insecure behavior.
- Disabled by default. (Added in Qt 5.8)
- \value AllowGeolocationOnInsecureOrigins
- Since Qt 5.7, only secure origins such as HTTPS have been able to request
- Geolocation features. This provides an override to allow non secure
- origins to access Geolocation again.
- Disabled by default. (Added in Qt 5.9)
- \value AllowWindowActivationFromJavaScript
- Allows activating windows by using the window.focus() JavaScript
- method. Disabled by default.
- (Added in Qt 5.10)
- \value ShowScrollBars
- Shows scroll bars.
- Enabled by default. (Added in Qt 5.10)
- \value PlaybackRequiresUserGesture
- Inhibits playback of media content until the user interacts with
- the page. By default, WebEngine uses Chromium settings, as described
- in \l {Autoplay Policy Changes}. This is similar to how Chrome on
- Android behaves, while the default behavior when it is disabled is
- similar to Chrome on desktops. To overwrite the default behavior,
- disable this setting. (Added in Qt 5.11)
- \value JavascriptCanPaste
- Enables JavaScript \c{execCommand("paste")}. This also requires
- enabling JavascriptCanAccessClipboard.
- Disabled by default. (Added in Qt 5.11)
- \value WebRTCPublicInterfacesOnly
- Limits WebRTC to public IP addresses only. When disabled WebRTC may also use
- local network IP addresses, but remote hosts can also see your local network
- IP address.
- Disabled by default. (Added in Qt 5.11)
- \value DnsPrefetchEnabled Specifies whether WebEngine will try to pre-fetch DNS entries to
- speed up browsing.
- Disabled by default. (Added in Qt 5.12)
- \value PdfViewerEnabled Specifies that PDF documents will be opened in the internal PDF viewer
- instead of being downloaded.
- Enabled by default. (Added in Qt 5.13)
-*/
-
-/*!
- \enum QWebEngineSettings::UnknownUrlSchemePolicy
- \since Qt 5.11
-
- This enum describes how navigation requests to URLs with unknown schemes are handled.
-
- \value DisallowUnknownUrlSchemes
- Disallows all navigation requests to URLs with unknown schemes.
- \value AllowUnknownUrlSchemesFromUserInteraction
- Allows navigation requests to URLs with unknown schemes that are issued from
- user-interaction (like a mouse-click), whereas other navigation requests (for example
- from JavaScript) are suppressed.
- \value AllowAllUnknownUrlSchemes
- Allows all navigation requests to URLs with unknown schemes.
-
- \sa unknownUrlSchemePolicy setUnknownUrlSchemePolicy resetUnknownUrlSchemePolicy
-*/
-
-/*!
- \fn void QWebEngineSettings::setFontSize(FontSize type, int size)
- Sets the font size for \a type to \a size in pixels.
-*/
-
-/*!
- \fn int QWebEngineSettings::fontSize(FontSize type) const
- Returns the default font size for \a type in pixels.
-*/
-
-/*!
- \fn void QWebEngineSettings::resetFontSize(FontSize type)
- Resets the font size for \a type to the size specified in the profile that
- the page belongs to.
-*/
-
-/*!
- \fn void QWebEngineSettings::setDefaultTextEncoding(const QString& encoding)
- Specifies the default text encoding system.
-
- The value of \a encoding must be a string describing an encoding such as "utf-8" or
- "iso-8859-1". If left empty, a default value will be used. For a more
- extensive list of encoding names see \l{QTextCodec}.
-
- \sa defaultTextEncoding()
-*/
-
-/*!
- \fn QString QWebEngineSettings::defaultTextEncoding() const
- Returns the default text encoding.
-
- \sa setDefaultTextEncoding()
-*/
-
-/*!
- \fn void QWebEngineSettings::setFontFamily(FontFamily which, const QString& family)
- Sets the actual font family to \a family for the specified generic family,
- \a which.
-*/
-
-/*!
- \fn QString QWebEngineSettings::fontFamily(FontFamily which) const
- Returns the actual font family for the specified generic font family,
- \a which.
-*/
-
-/*!
- \fn void QWebEngineSettings::resetFontFamily(FontFamily which)
- Resets the actual font family specified by \a which to the one specified
- in the profile that the page belongs to.
-*/
-
-/*!
- \fn QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const
- \since Qt 5.11
- Returns the currently selected policy for handling navigation requests to URLs with
- unknown schemes. Default is \l{QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction}.
- \sa setUnknownUrlSchemePolicy resetUnknownUrlSchemePolicy
-*/
-
-/*!
- \fn void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy)
- \since Qt 5.11
- Sets the policy for handling navigation requests to URLs with unknown schemes to \a policy.
- Default is \l{QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction}.
- \sa unknownUrlSchemePolicy resetUnknownUrlSchemePolicy
-*/
-
-/*!
- \fn void QWebEngineSettings::resetUnknownUrlSchemePolicy()
- \since Qt 5.11
- Removes the policy for handling navigation requests to URLs with unknown schemes.
- \sa unknownUrlSchemePolicy setUnknownUrlSchemePolicy
-*/
-
-/*!
- \fn void QWebEngineSettings::setAttribute(WebAttribute attribute, bool on)
-
- Enables or disables the specified \a attribute feature depending on the
- value of \a on.
-*/
-
-/*!
- \fn bool QWebEngineSettings::testAttribute(WebAttribute attribute) const
-
- Returns \c true if \a attribute is enabled; otherwise returns \c false.
-*/
-
-/*!
- \fn void QWebEngineSettings::resetAttribute(WebAttribute attribute)
-
- Resets the setting of \a attribute to the value specified in the
- profile that the page belongs to.
-*/
diff --git a/src/webenginewidgets/printer_worker.cpp b/src/webenginewidgets/printer_worker.cpp
deleted file mode 100644
index 8e1c2a985..000000000
--- a/src/webenginewidgets/printer_worker.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** 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 "printer_worker.h"
-
-#include "printing/pdfium_document_wrapper_qt.h"
-
-#include <QPainter>
-#include <QPrinter>
-
-namespace QtWebEngineCore {
-
-PrinterWorker::PrinterWorker(QSharedPointer<QByteArray> data, QPrinter *printer)
- : m_data(data)
- , m_printer(printer)
-{
-}
-
-PrinterWorker::~PrinterWorker()
-{
-}
-
-void PrinterWorker::print()
-{
- if (!m_data->size()) {
- qWarning("Failure to print on printer %ls: Print result data is empty.",
- qUtf16Printable(m_printer->printerName()));
- Q_EMIT resultReady(false);
- return;
- }
-
- PdfiumDocumentWrapperQt pdfiumWrapper(m_data->constData(), m_data->size());
-
- int toPage = m_printer->toPage();
- int fromPage = m_printer->fromPage();
- bool ascendingOrder = true;
-
- if (fromPage == 0 && toPage == 0) {
- fromPage = 1;
- toPage = pdfiumWrapper.pageCount();
- }
- fromPage = qMax(1, fromPage);
- toPage = qMin(pdfiumWrapper.pageCount(), toPage);
-
- if (m_printer->pageOrder() == QPrinter::LastPageFirst) {
- qSwap(fromPage, toPage);
- ascendingOrder = false;
- }
-
- int pageCopies = 1;
- int documentCopies = 1;
-
- if (!m_printer->supportsMultipleCopies())
- documentCopies = m_printer->copyCount();
-
- if (m_printer->collateCopies()) {
- pageCopies = documentCopies;
- documentCopies = 1;
- }
-
- qreal resolution = m_printer->resolution() / 72.0; // pdfium uses points so 1/72 inch
-
- QPainter painter;
-
- for (int printedDocuments = 0; printedDocuments < documentCopies; printedDocuments++) {
- if (printedDocuments > 0)
- m_printer->newPage();
-
- int currentPageIndex = fromPage;
-
- for (int i = 0; true; i++) {
- QSizeF documentSize = (pdfiumWrapper.pageSize(currentPageIndex - 1) * resolution);
- bool isLandscape = documentSize.width() > documentSize.height();
- m_printer->setPageOrientation(isLandscape ? QPageLayout::Landscape : QPageLayout::Portrait);
- QRectF pageRect = m_printer->pageRect(QPrinter::DevicePixel);
- documentSize = documentSize.scaled(pageRect.size(), Qt::KeepAspectRatio);
-
- // setPageOrientation has to be called before qpainter.begin() or before qprinter.newPage() so correct metrics is used,
- // therefore call begin now for only first page
- if (!painter.isActive() && !painter.begin(m_printer)) {
- qWarning("Failure to print on printer %ls: Could not open printer for painting.",
- qUtf16Printable(m_printer->printerName()));
- Q_EMIT resultReady(false);
- return;
- }
-
- if (i > 0)
- m_printer->newPage();
-
- for (int printedPages = 0; printedPages < pageCopies; printedPages++) {
- if (m_printer->printerState() == QPrinter::Aborted
- || m_printer->printerState() == QPrinter::Error) {
- Q_EMIT resultReady(false);
- return;
- }
-
- if (printedPages > 0)
- m_printer->newPage();
-
- QImage currentImage = pdfiumWrapper.pageAsQImage(currentPageIndex - 1,documentSize.width(),documentSize.height());
- if (currentImage.isNull()) {
- Q_EMIT resultReady(false);
- return;
- }
- painter.drawImage(0,0, currentImage);
- }
-
- if (currentPageIndex == toPage)
- break;
-
- if (ascendingOrder)
- currentPageIndex++;
- else
- currentPageIndex--;
- }
- }
- painter.end();
-
- Q_EMIT resultReady(true);
- return;
-}
-
-} // namespace QtWebEngineCore
diff --git a/src/webenginewidgets/printer_worker.h b/src/webenginewidgets/printer_worker.h
deleted file mode 100644
index 96025c90e..000000000
--- a/src/webenginewidgets/printer_worker.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#ifndef PRINTER_WORKER_H
-#define PRINTER_WORKER_H
-
-#include "qtwebenginecoreglobal_p.h"
-
-#include <QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-class QPrinter;
-QT_END_NAMESPACE
-
-namespace QtWebEngineCore {
-
-class PrinterWorker : public QObject
-{
- Q_OBJECT
-public:
- PrinterWorker(QSharedPointer<QByteArray> data, QPrinter *printer);
- virtual ~PrinterWorker();
-
-public Q_SLOTS:
- void print();
-
-Q_SIGNALS:
- void resultReady(bool success);
-
-private:
- Q_DISABLE_COPY(PrinterWorker)
-
- QSharedPointer<QByteArray> m_data;
- QPrinter *m_printer;
-};
-
-} // namespace QtWebEngineCore
-
-Q_DECLARE_METATYPE(QtWebEngineCore::PrinterWorker*)
-
-#endif // PRINTER_WORKER_H
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 5124eabed..5d8932fb7 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -39,28 +39,35 @@
#include "render_widget_host_view_qt_delegate_widget.h"
+#include "render_widget_host_view_qt_delegate_client.h"
+
#include "qwebenginepage_p.h"
#include "qwebengineview.h"
#include "qwebengineview_p.h"
+
#include <QGuiApplication>
#include <QLayout>
#include <QMouseEvent>
#include <QOpenGLContext>
#include <QResizeEvent>
-#include <QSGAbstractRenderer>
-#include <QSGNode>
+#include <QSGImageNode>
#include <QWindow>
namespace QtWebEngineCore {
-class RenderWidgetHostViewQuickItem : public QQuickItem {
+class RenderWidgetHostViewQuickItem : public QQuickItem, public Compositor::Observer
+{
public:
RenderWidgetHostViewQuickItem(RenderWidgetHostViewQtDelegateClient *client) : m_client(client)
{
setFlag(ItemHasContents, true);
// Mark that this item should receive focus when the parent QQuickWidget receives focus.
setFocus(true);
+
+ bind(client->compositorId());
}
+ ~RenderWidgetHostViewQuickItem() { unbind(); }
+
protected:
bool event(QEvent *event) override
{
@@ -81,17 +88,76 @@ protected:
{
m_client->forwardEvent(event);
}
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
+ void itemChange(ItemChange change, const ItemChangeData &value) override
{
- return m_client->updatePaintNode(oldNode);
+ QQuickItem::itemChange(change, value);
+ if (change == QQuickItem::ItemSceneChange) {
+ for (const QMetaObject::Connection &c : qAsConst(m_windowConnections))
+ disconnect(c);
+ m_windowConnections.clear();
+ if (value.window) {
+ m_windowConnections.append(connect(
+ value.window, &QQuickWindow::beforeRendering, this,
+ &RenderWidgetHostViewQuickItem::onBeforeRendering, Qt::DirectConnection));
+ }
+ }
}
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
+ {
+ auto comp = compositor();
+ if (!comp)
+ return nullptr;
+
+ QQuickWindow *win = QQuickItem::window();
+
+ // Delete old node before swapFrame to decrement refcount of
+ // QImage in software mode.
+ delete oldNode;
+ QSGImageNode *node = win->createImageNode();
+ node->setOwnsTexture(true);
+
+ comp->swapFrame();
+
+ QSize texSize = comp->size();
+ QSizeF texSizeInDips = QSizeF(texSize) / comp->devicePixelRatio();
+ node->setRect(QRectF(QPointF(0, 0), texSizeInDips));
+
+ if (comp->type() == Compositor::Type::Software) {
+ QImage image = comp->image();
+ node->setTexture(win->createTextureFromImage(image));
+ } else if (comp->type() == Compositor::Type::OpenGL) {
+ QQuickWindow::CreateTextureOptions texOpts;
+ if (comp->hasAlphaChannel())
+ texOpts.setFlag(QQuickWindow::TextureHasAlphaChannel);
+ int texId = comp->textureId();
+ node->setTexture(QNativeInterface::QSGOpenGLTexture::fromNative(texId, win, texSize, texOpts));
+ node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
+ } else {
+ Q_UNREACHABLE();
+ }
+ return node;
+ }
+ void onBeforeRendering()
+ {
+ auto comp = compositor();
+ if (!comp || comp->type() != Compositor::Type::OpenGL)
+ return;
+ comp->waitForTexture();
+ }
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
{
return m_client->inputMethodQuery(query);
}
+ void readyToSwap() override
+ {
+ // Call update() on UI thread.
+ QMetaObject::invokeMethod(this, &QQuickItem::update, Qt::QueuedConnection);
+ }
+
private:
RenderWidgetHostViewQtDelegateClient *m_client;
+ QList<QMetaObject::Connection> m_windowConnections;
};
RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent)
@@ -101,62 +167,6 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
, m_isPopup(false)
{
setFocusPolicy(Qt::StrongFocus);
-
- QSurfaceFormat format;
- format.setDepthBufferSize(24);
- format.setStencilBufferSize(8);
-
-#if QT_CONFIG(opengl)
- QOpenGLContext *globalSharedContext = QOpenGLContext::globalShareContext();
- if (globalSharedContext) {
- QSurfaceFormat sharedFormat = globalSharedContext->format();
-
-#ifdef Q_OS_OSX
- // Check that the default QSurfaceFormat OpenGL profile is compatible with the global OpenGL
- // shared context profile, otherwise this could lead to a nasty crash.
- QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat();
-
- if (defaultFormat.profile() != sharedFormat.profile()
- && defaultFormat.profile() == QSurfaceFormat::CoreProfile
- && defaultFormat.version() >= qMakePair(3, 2)) {
- qFatal("QWebEngine: Default QSurfaceFormat OpenGL profile is not compatible with the "
- "global shared context OpenGL profile. Please make sure you set a compatible "
- "QSurfaceFormat before the QtGui application instance is created.");
- }
-#endif
- int major;
- int minor;
- QSurfaceFormat::OpenGLContextProfile profile;
-#ifdef Q_OS_MACOS
- // Due to QTBUG-63180, requesting the sharedFormat.majorVersion() on macOS will lead to
- // a failed creation of QQuickWidget shared context. Thus make sure to request the
- // major version specified in the defaultFormat instead.
- major = defaultFormat.majorVersion();
- minor = defaultFormat.minorVersion();
- profile = defaultFormat.profile();
-#else
- major = sharedFormat.majorVersion();
- minor = sharedFormat.minorVersion();
- profile = sharedFormat.profile();
-#endif
-
- // Make sure the OpenGL profile of the QQuickWidget matches the shared context profile.
- // It covers the following cases:
- // 1) Desktop OpenGL Core Profile.
- // 2) Windows ANGLE OpenGL ES profile.
- if (sharedFormat.profile() == QSurfaceFormat::CoreProfile
-#ifdef Q_OS_WIN
- || globalSharedContext->isOpenGLES()
-#endif
- ) {
- format.setMajorVersion(major);
- format.setMinorVersion(minor);
- format.setProfile(profile);
- }
- }
-
- setFormat(format);
-#endif
setMouseTracking(true);
setAttribute(Qt::WA_AcceptTouchEvents);
setAttribute(Qt::WA_OpaquePaintEvent);
@@ -169,7 +179,7 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
RenderWidgetHostViewQtDelegateWidget::~RenderWidgetHostViewQtDelegateWidget()
{
- QWebEnginePagePrivate::bindPageAndWidget(nullptr, this);
+ QWebEngineViewPrivate::bindPageAndWidget(nullptr, this);
}
void RenderWidgetHostViewQtDelegateWidget::connectRemoveParentBeforeParentDelete()
@@ -290,21 +300,6 @@ QWindow* RenderWidgetHostViewQtDelegateWidget::window() const
return root ? root->windowHandle() : 0;
}
-QSGTexture *RenderWidgetHostViewQtDelegateWidget::createTextureFromImage(const QImage &image)
-{
- return quickWindow()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas);
-}
-
-QSGImageNode *RenderWidgetHostViewQtDelegateWidget::createImageNode()
-{
- return quickWindow()->createImageNode();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::update()
-{
- m_rootItem->update();
-}
-
void RenderWidgetHostViewQtDelegateWidget::updateCursor(const QCursor &cursor)
{
QQuickWidget::setCursor(cursor);
@@ -381,15 +376,6 @@ void RenderWidgetHostViewQtDelegateWidget::hideEvent(QHideEvent *event)
m_client->notifyHidden();
}
-bool RenderWidgetHostViewQtDelegateWidget::copySurface(const QRect &rect, const QSize &size, QImage &image)
-{
- QPixmap pixmap = rect.isEmpty() ? QQuickWidget::grab(QQuickWidget::rect()) : QQuickWidget::grab(rect);
- if (pixmap.isNull())
- return false;
- image = pixmap.toImage().scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- return true;
-}
-
bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
{
bool handled = false;
@@ -453,8 +439,9 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
// QtQuick is different by sending both the Press and DblClick events for the second press
// where we can simply ignore the DblClick event.
QMouseEvent *dblClick = static_cast<QMouseEvent *>(event);
- QMouseEvent press(QEvent::MouseButtonPress, dblClick->localPos(), dblClick->windowPos(), dblClick->screenPos(),
- dblClick->button(), dblClick->buttons(), dblClick->modifiers(), dblClick->source());
+ QMouseEvent press(QEvent::MouseButtonPress, dblClick->position(), dblClick->scenePosition(),
+ dblClick->globalPosition(), dblClick->button(), dblClick->buttons(),
+ dblClick->modifiers(), dblClick->source());
press.setTimestamp(dblClick->timestamp());
handled = m_client->forwardEvent(&press);
} else
@@ -477,6 +464,14 @@ void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged()
m_client->visualPropertiesChanged();
}
+void RenderWidgetHostViewQtDelegateWidget::adapterClientChanged(WebContentsAdapterClient *client)
+{
+ QWebEnginePage *page = static_cast<QWebEnginePagePrivate *>(client)->q_func();
+ QWebEngineViewPrivate::bindPageAndWidget(page, this);
+ connect(page, &QWebEnginePage::_q_aboutToDelete, this,
+ [this]() { QWebEngineViewPrivate::bindPageAndWidget(nullptr, this); });
+}
+
#if QT_CONFIG(accessibility)
RenderWidgetHostViewQtDelegateWidgetAccessible::RenderWidgetHostViewQtDelegateWidgetAccessible(RenderWidgetHostViewQtDelegateWidget *o, QWebEngineView *view)
: QAccessibleWidget(o)
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
index fd8654d95..bd66eee68 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
class QWebEnginePage;
class QWebEngineView;
class QWebEngineViewAccessible;
-class QWebEnginePagePrivate;
+class QWebEngineViewPrivate;
QT_END_NAMESPACE
namespace QtWebEngineCore {
@@ -79,16 +79,12 @@ public:
void hide() override;
bool isVisible() const override;
QWindow* window() const override;
- QSGTexture *createTextureFromImage(const QImage &) override;
- QSGImageNode *createImageNode() override;
- void update() override;
void updateCursor(const QCursor &) override;
void resize(int width, int height) override;
void move(const QPoint &screenPos) override;
void inputMethodStateChanged(bool editorVisible, bool passwordInput) override;
void setInputMethodHints(Qt::InputMethodHints) override;
void setClearColor(const QColor &color) override;
- bool copySurface(const QRect &, const QSize &, QImage &) override;
void unhandledWheelEvent(QWheelEvent *ev) override;
protected:
@@ -99,6 +95,7 @@ protected:
void closeEvent(QCloseEvent *event) override;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
+ void adapterClientChanged(WebContentsAdapterClient *client) override;
private slots:
void onWindowPosChanged();
@@ -106,7 +103,7 @@ private slots:
void removeParentBeforeParentDelete();
private:
- friend QWebEnginePagePrivate;
+ friend QWebEngineViewPrivate;
RenderWidgetHostViewQtDelegateClient *m_client;
QScopedPointer<QQuickItem> m_rootItem;
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index d4fb40dc7..e726bdc8c 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -12,48 +12,15 @@ QT_PRIVATE += quick-private gui-private core-private widgets-private quickwidget
INCLUDEPATH += $$PWD api ../core ../core/api ../webengine/api
SOURCES = \
- api/qtwebenginewidgetsglobal.cpp \
- api/qwebenginecertificateerror.cpp \
- api/qwebengineclientcertificateselection.cpp \
- api/qwebenginecontextmenudata.cpp \
- api/qwebenginedownloaditem.cpp \
- api/qwebenginefullscreenrequest.cpp \
- api/qwebenginehistory.cpp \
api/qwebenginenotificationpresenter.cpp \
- api/qwebenginepage.cpp \
- api/qwebengineprofile.cpp \
- api/qwebenginescript.cpp \
- api/qwebenginescriptcollection.cpp \
- api/qwebenginesettings.cpp \
api/qwebengineview.cpp \
render_widget_host_view_qt_delegate_widget.cpp
HEADERS = \
api/qtwebenginewidgetsglobal.h \
- api/qwebenginecertificateerror.h \
- api/qwebengineclientcertificateselection.h \
- api/qwebenginecontextmenudata.h \
- api/qwebenginedownloaditem.h \
- api/qwebenginedownloaditem_p.h \
- api/qwebenginefullscreenrequest.h \
- api/qwebenginehistory.h \
api/qwebenginenotificationpresenter_p.h \
- api/qwebenginepage.h \
- api/qwebenginepage_p.h \
- api/qwebengineprofile.h \
- api/qwebengineprofile_p.h \
- api/qwebenginescriptcollection.h \
- api/qwebenginescriptcollection_p.h \
- api/qwebenginesettings.h \
api/qwebengineview.h \
api/qwebengineview_p.h \
render_widget_host_view_qt_delegate_widget.h
-qtConfig(webengine-printing-and-pdf) {
- QT += printsupport
-
- SOURCES += printer_worker.cpp
- HEADERS += printer_worker.h
-}
-
load(qt_module)