diff options
Diffstat (limited to 'src/webengine/api')
45 files changed, 0 insertions, 12869 deletions
diff --git a/src/webengine/api/qquickwebengineaction.cpp b/src/webengine/api/qquickwebengineaction.cpp deleted file mode 100644 index 77ac8d340..000000000 --- a/src/webengine/api/qquickwebengineaction.cpp +++ /dev/null @@ -1,173 +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 "qquickwebengineaction_p.h" -#include "qquickwebengineaction_p_p.h" -#include "qquickwebengineview_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype WebEngineAction - \instantiates QQuickWebEngineAction - \inqmlmodule QtWebEngine - \since QtWebEngine 1.8 - - \brief An action that represents a \l WebEngineView::WebAction. - - A WebEngineAction is returned by the \l WebEngineView::action() - method. It provides information about the action, such as - whether it is \l enabled. - - The following code uses the \l WebEngineView::action() method to check if the - the copy action is enabled: - - \code - var copyAction = webEngineView.action(WebEngineView.Copy); - if (copyAction.enabled) - console.log("Copy is enabled."); - else - console.log("Copy is disabled."); - \endcode -*/ - -QQuickWebEngineActionPrivate::QQuickWebEngineActionPrivate(const QVariant &data, const QString &text, const QString &iconName, bool enabled) - : m_data(data) - , m_text(text) - , m_iconName(iconName) - , m_enabled(enabled) -{ -} - -QQuickWebEngineActionPrivate::~QQuickWebEngineActionPrivate() -{ -} - -void QQuickWebEngineActionPrivate::setEnabled(bool enabled) -{ - Q_Q(QQuickWebEngineAction); - if (m_enabled == enabled) - return; - m_enabled = enabled; - emit q->enabledChanged(); -} - -QVariant QQuickWebEngineActionPrivate::data() const -{ - return m_data; -} - -void QQuickWebEngineActionPrivate::trigger() -{ - Q_Q(QQuickWebEngineAction); - if (QQuickWebEngineView *view = static_cast<QQuickWebEngineView*>(q->parent())) { - view->triggerWebAction(static_cast<QQuickWebEngineView::WebAction>(data().toInt())); - } -} - -QQuickWebEngineAction::QQuickWebEngineAction(const QVariant &data, const QString &text, const QString &iconName, bool enabled, QObject *parent) - : QObject(parent) - , d_ptr(new QQuickWebEngineActionPrivate(data, text, iconName, enabled)) -{ - d_ptr->q_ptr = this; -} - -QQuickWebEngineAction::QQuickWebEngineAction(QObject *parent) - : QObject(parent) - , d_ptr(new QQuickWebEngineActionPrivate(-1, QStringLiteral(""), QStringLiteral(""), false)) -{ - d_ptr->q_ptr = this; -} - -QQuickWebEngineAction::~QQuickWebEngineAction() -{ -} - -/*! - \qmlproperty int WebEngineAction::text - - This property holds a textual description of the action. -*/ -QString QQuickWebEngineAction::text() const -{ - Q_D(const QQuickWebEngineAction); - return d->m_text; -} - -/*! - \qmlproperty string WebEngineAction::iconName - - This property holds the name of the icon for the action. This name - can be used to pick the icon from a theme. -*/ -QString QQuickWebEngineAction::iconName() const -{ - Q_D(const QQuickWebEngineAction); - return d->m_iconName; -} - -/*! - \qmlproperty bool WebEngineAction::enabled - - This property holds whether the action is enabled. -*/ -bool QQuickWebEngineAction::isEnabled() const -{ - Q_D(const QQuickWebEngineAction); - return d->m_enabled; -} - -/*! - \qmlmethod void WebEngineAction::trigger() - - Triggers the action. -*/ -void QQuickWebEngineAction::trigger() -{ - Q_D(QQuickWebEngineAction); - if (!isEnabled()) - return; - - d->trigger(); - emit triggered(); -} - -QT_END_NAMESPACE - diff --git a/src/webengine/api/qquickwebengineaction_p.h b/src/webengine/api/qquickwebengineaction_p.h deleted file mode 100644 index 8f5f3386c..000000000 --- a/src/webengine/api/qquickwebengineaction_p.h +++ /dev/null @@ -1,107 +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 QQUICKWEBENGINEACTION_P_H -#define QQUICKWEBENGINEACTION_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 <QObject> -#include <QtQml/qqml.h> -#include "qtwebengineglobal_p.h" -#include <QVariant> - -namespace QtWebEngineCore { - class UIDelegatesManager; - class UI2DelegatesManager; -} - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineActionPrivate; - -class Q_WEBENGINE_EXPORT QQuickWebEngineAction : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString text READ text CONSTANT FINAL) - Q_PROPERTY(QString iconName READ iconName CONSTANT FINAL) - Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged FINAL) - -public: - QQuickWebEngineAction(const QVariant &data, const QString &text, const QString &iconName, bool enabled, QObject *parent); - QQuickWebEngineAction(QObject *parent); - ~QQuickWebEngineAction(); - - QString text() const; - QString iconName() const; - bool isEnabled() const; - -public Q_SLOTS: - Q_INVOKABLE void trigger(); - -Q_SIGNALS: - void triggered(); - void enabledChanged(); - -private: - Q_DECLARE_PRIVATE(QQuickWebEngineAction) - friend class QQuickWebEngineView; - friend class QQuickWebEngineViewPrivate; - friend class QtWebEngineCore::UIDelegatesManager; - friend class QtWebEngineCore::UI2DelegatesManager; - friend class QQuickContextMenuBuilder; - - QScopedPointer<QQuickWebEngineActionPrivate> d_ptr; -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickWebEngineAction) - -#endif // QQUICKWEBENGINEACTION_P_H diff --git a/src/webengine/api/qquickwebengineaction_p_p.h b/src/webengine/api/qquickwebengineaction_p_p.h deleted file mode 100644 index d2ead30e9..000000000 --- a/src/webengine/api/qquickwebengineaction_p_p.h +++ /dev/null @@ -1,86 +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 QQUICKWEBENGINEACTION_P_P_H -#define QQUICKWEBENGINEACTION_P_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 <QObject> -#include "qtwebengineglobal_p.h" -#include <QVariant> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineAction; - -class QQuickWebEngineActionPrivate -{ -public: - Q_DECLARE_PUBLIC(QQuickWebEngineAction) - QQuickWebEngineActionPrivate(const QVariant &data, const QString &text, const QString &iconName, bool enabled); - ~QQuickWebEngineActionPrivate(); - - void setEnabled(bool enabled); - - QVariant data() const; - - void trigger(); - - QVariant m_data; - QString m_text; - QString m_iconName; - bool m_enabled; - -private: - QQuickWebEngineAction *q_ptr; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEACTION_P_P_H diff --git a/src/webengine/api/qquickwebenginecertificateerror.cpp b/src/webengine/api/qquickwebenginecertificateerror.cpp deleted file mode 100644 index 6d50ea851..000000000 --- a/src/webengine/api/qquickwebenginecertificateerror.cpp +++ /dev/null @@ -1,257 +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 <qquickwebenginecertificateerror_p.h> -#include "certificate_error_controller.h" -QT_BEGIN_NAMESPACE - -class QQuickWebEngineCertificateErrorPrivate { -public: - QQuickWebEngineCertificateErrorPrivate(const QSharedPointer<CertificateErrorController> &controller) - : weakRefCertErrorController(controller), - error(static_cast<QQuickWebEngineCertificateError::Error>(static_cast<int>(controller->error()))), - description(controller->errorString()), - overridable(controller->overridable()), - async(false), - answered(false) - { - } - - const QWeakPointer<CertificateErrorController> weakRefCertErrorController; - QQuickWebEngineCertificateError::Error error; - QString description; - bool overridable; - bool async; - bool answered; -}; - -/*! - \qmltype WebEngineCertificateError - \instantiates QQuickWebEngineCertificateError - \inqmlmodule QtWebEngine - \since QtWebEngine 1.1 - - \brief A utility type for ignoring certificate errors or rejecting erroneous certificates. - - This QML type contains information about a certificate error that occurred. The \l error - property holds the reason that the error occurred and the \l description property holds a - short localized description of the error. The \l url property holds the URL that triggered - the error. - - The certificate can be rejected by calling \l rejectCertificate, which will stop loading the - web engine request. By default, an invalid certificate will be automatically rejected. - - The certificate error can be ignored by calling \l ignoreCertificateError, which will - resume loading the request. - - It is possible to defer the decision of rejecting a certificate by calling \l defer, - which is useful when waiting for user input. - - \sa WebEngineView::certificateError -*/ -QQuickWebEngineCertificateError::QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent) - : QObject(parent) - , d_ptr(new QQuickWebEngineCertificateErrorPrivate(controller)) -{ -} - -QQuickWebEngineCertificateError::~QQuickWebEngineCertificateError() -{ - Q_D(QQuickWebEngineCertificateError); - if (!d->answered) - rejectCertificate(); -} - - -/*! - \qmlmethod void WebEngineCertificateError::defer() - - 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 WebEngineCertificateError::ignoreCertificateError() or - WebEngineCertificateError::rejectCertificate() is called. - */ -void QQuickWebEngineCertificateError::defer() -{ - Q_D(QQuickWebEngineCertificateError); - d->async = true; -} -/*! - \qmlmethod void WebEngineCertificateError::ignoreCertificateError() - - The certificate error is ignored, and the web engine view continues to load the requested URL. - */ -void QQuickWebEngineCertificateError::ignoreCertificateError() -{ - Q_D(QQuickWebEngineCertificateError); - - if (d->answered) - return; - - d->answered = true; - - QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef(); - if (strongRefCert) - strongRefCert->accept(true); -} - -/*! - \qmlmethod void WebEngineCertificateError::rejectCertificate() - - The certificate is rejected, and the web engine view stops loading the requested URL. - */ -void QQuickWebEngineCertificateError::rejectCertificate() -{ - Q_D(QQuickWebEngineCertificateError); - - if (d->answered) - return; - - d->answered = true; - - QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef(); - if (strongRefCert) - strongRefCert->accept(false); -} - -/*! - \qmlproperty url WebEngineCertificateError::url - \readonly - - The URL that triggered the error. - */ -QUrl QQuickWebEngineCertificateError::url() const -{ - Q_D(const QQuickWebEngineCertificateError); - QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef(); - if (strongRefCert) - return strongRefCert->url(); - return QUrl(); -} - -/*! - \qmlproperty enumeration WebEngineCertificateError::error - \readonly - - The type of the error. - - \value WebEngineCertificateError.SslPinnedKeyNotInCertificateChain - The certificate did not match the built-in public keys pinned for - the host name. - \value WebEngineCertificateError.CertificateCommonNameInvalid - The certificate's common name did not match the host name. - \value WebEngineCertificateError.CertificateDateInvalid - The certificate is not valid at the current date and time. - \value WebEngineCertificateError.CertificateAuthorityInvalid - The certificate is not signed by a trusted authority. - \value WebEngineCertificateError.CertificateContainsErrors - The certificate contains errors. - \value WebEngineCertificateError.CertificateNoRevocationMechanism - The certificate has no mechanism for determining if it has been - revoked. - \value WebEngineCertificateError.CertificateUnableToCheckRevocation - Revocation information for the certificate is not available. - \value WebEngineCertificateError.CertificateRevoked - The certificate has been revoked. - \value WebEngineCertificateError.CertificateInvalid - The certificate is invalid. - \value WebEngineCertificateError.CertificateWeakSignatureAlgorithm - The certificate is signed using a weak signature algorithm. - \value WebEngineCertificateError.CertificateNonUniqueName - The host name specified in the certificate is not unique. - \value WebEngineCertificateError.CertificateWeakKey - The certificate contains a weak key. - \value WebEngineCertificateError.CertificateNameConstraintViolation - The certificate claimed DNS names that are in violation of name - constraints. - \value WebEngineCertificateError.CertificateValidityTooLong - The certificate has a validity period that is too long. - (Added in 5.7) - \value WebEngineCertificateError.CertificateTransparencyRequired - Certificate Transparency was required for this connection, but the server - did not provide CT information that complied with the policy. (Added in 5.8) - \value WebEngineCertificateError.CertificateKnownInterceptionBlocked - The certificate is known to be used for interception by an entity other - the device owner. (Added in 5.15) - -*/ -QQuickWebEngineCertificateError::Error QQuickWebEngineCertificateError::error() const -{ - Q_D(const QQuickWebEngineCertificateError); - return d->error; -} - -/*! - \qmlproperty string WebEngineCertificateError::description - \readonly - - A short localized human-readable description of the error. -*/ -QString QQuickWebEngineCertificateError::description() const -{ - Q_D(const QQuickWebEngineCertificateError); - return d->description; -} - -/*! - \qmlproperty bool WebEngineCertificateError::overridable - \readonly - - A boolean that indicates whether the certificate error can be overridden and ignored. -*/ -bool QQuickWebEngineCertificateError::overridable() const -{ - Q_D(const QQuickWebEngineCertificateError); - return d->overridable; -} - -bool QQuickWebEngineCertificateError::deferred() const -{ - Q_D(const QQuickWebEngineCertificateError); - return d->async; -} - -bool QQuickWebEngineCertificateError::answered() const -{ - Q_D(const QQuickWebEngineCertificateError); - return d->answered; -} - -QT_END_NAMESPACE - diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h deleted file mode 100644 index 4a8ef6ae0..000000000 --- a/src/webengine/api/qquickwebenginecertificateerror_p.h +++ /dev/null @@ -1,115 +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 QQUICKWEBENGINECERTIFICATEERROR_P_H -#define QQUICKWEBENGINECERTIFICATEERROR_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 <QObject> -#include "qquickwebengineview_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineCertificateErrorPrivate; -class CertificateErrorController; - -class Q_WEBENGINE_EXPORT QQuickWebEngineCertificateError : public QObject { - Q_OBJECT - Q_PROPERTY(QUrl url READ url CONSTANT FINAL) - Q_PROPERTY(Error error READ error CONSTANT FINAL) - Q_PROPERTY(QString description READ description CONSTANT FINAL) - Q_PROPERTY(bool overridable READ overridable CONSTANT FINAL) - -public: - - // 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, - }; - Q_ENUM(Error) - - QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent = 0); - ~QQuickWebEngineCertificateError(); - - Q_INVOKABLE void defer(); - Q_INVOKABLE void ignoreCertificateError(); - Q_INVOKABLE void rejectCertificate(); - QUrl url() const; - Error error() const; - QString description() const; - bool overridable() const; - bool deferred() const; - bool answered() const; - -private: - Q_DISABLE_COPY(QQuickWebEngineCertificateError) - Q_DECLARE_PRIVATE(QQuickWebEngineCertificateError) - QScopedPointer<QQuickWebEngineCertificateErrorPrivate> d_ptr; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickWebEngineCertificateError) - -#endif // QQUICKWEBENGINECERTIFICATEERROR_P_H diff --git a/src/webengine/api/qquickwebengineclientcertificateselection.cpp b/src/webengine/api/qquickwebengineclientcertificateselection.cpp deleted file mode 100644 index c48a59887..000000000 --- a/src/webengine/api/qquickwebengineclientcertificateselection.cpp +++ /dev/null @@ -1,226 +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 "qquickwebengineclientcertificateselection_p.h" - -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) - -#include "client_cert_select_controller.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype WebEngineClientCertificateOption - \instantiates QQuickWebEngineClientCertificateOption - \inqmlmodule QtWebEngine - \since QtWebEngine 1.9 - \brief Represents a client certificate option. - - \sa {WebEngineClientCertificateSelection::certificates} {WebEngineClientCertificateSelection.certificates} -*/ - -QQuickWebEngineClientCertificateOption::QQuickWebEngineClientCertificateOption(QQuickWebEngineClientCertificateSelection *selection, int index) - : QObject(selection), m_selection(selection), m_index(index) -{} - -/*! - \qmlproperty string WebEngineClientCertificateOption::issuer - \brief The issuer of the certificate. -*/ - -QString QQuickWebEngineClientCertificateOption::issuer() const -{ - return m_selection->d_ptr->certificates().at(m_index).issuerDisplayName(); -} - -/*! - \qmlproperty string WebEngineClientCertificateOption::subject - \brief The subject of the certificate. -*/ -QString QQuickWebEngineClientCertificateOption::subject() const -{ - return m_selection->d_ptr->certificates().at(m_index).subjectDisplayName(); -} - -/*! - \qmlproperty datetime WebEngineClientCertificateOption::effectiveDate - \brief The date and time when the certificate becomes valid. -*/ -QDateTime QQuickWebEngineClientCertificateOption::effectiveDate() const -{ - return m_selection->d_ptr->certificates().at(m_index).effectiveDate(); -} - -/*! - \qmlproperty datetime WebEngineClientCertificateOption::expiryDate - \brief The date and time when the certificate becomes invalid. -*/ -QDateTime QQuickWebEngineClientCertificateOption::expiryDate() const -{ - return m_selection->d_ptr->certificates().at(m_index).expiryDate(); -} - -/*! - \qmlproperty bool WebEngineClientCertificateOption::isSelfSigned - \brief Whether the certificate is only self-signed. -*/ -bool QQuickWebEngineClientCertificateOption::isSelfSigned() const -{ - return m_selection->d_ptr->certificates().at(m_index).isSelfSigned(); -} - -/*! - \qmlmethod void WebEngineClientCertificateOption::select() - - Selects this client certificate option. -*/ -void QQuickWebEngineClientCertificateOption::select() -{ - m_selection->select(m_index); -} - -/*! - \qmltype WebEngineClientCertificateSelection - \instantiates QQuickWebEngineClientCertificateSelection - \inqmlmodule QtWebEngine - \since QtWebEngine 1.9 - \brief Provides a selection of client certificates. - - When a web site requests an SSL client certificate, and one or more certificates - are found in the system's client certificate store, this type 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 {WebEngineView::selectClientCertificate}{WebEngineView.selectClientCertificate} -*/ - -QQuickWebEngineClientCertificateSelection::QQuickWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController> selectController) - : QObject(), d_ptr(selectController) -{} - -int QQuickWebEngineClientCertificateSelection::certificates_count( - QQmlListProperty<QQuickWebEngineClientCertificateOption> *p) -{ - Q_ASSERT(p && p->object); - QQuickWebEngineClientCertificateSelection *d = static_cast<QQuickWebEngineClientCertificateSelection *>(p->object); - return d->m_certificates.size(); -} - -QQuickWebEngineClientCertificateOption *QQuickWebEngineClientCertificateSelection::certificates_at( - QQmlListProperty<QQuickWebEngineClientCertificateOption> *p, int idx) -{ - Q_ASSERT(p && p->object); - QQuickWebEngineClientCertificateSelection *d = static_cast<QQuickWebEngineClientCertificateSelection *>(p->object); - if (idx < 0 || idx >= d->m_certificates.size()) - return nullptr; - return d->m_certificates[idx]; -} - -/*! - \qmlproperty list<WebEngineClientCertificateOption> WebEngineClientCertificateSelection::certificates - \brief The client certificates available to choose from. -*/ - -QQmlListProperty<QQuickWebEngineClientCertificateOption> QQuickWebEngineClientCertificateSelection::certificates() -{ - if (m_certificates.empty()) { - QVector<QSslCertificate> certificates = d_ptr->certificates(); - for (int i = 0; i < certificates.count(); ++i) - m_certificates.push_back(new QQuickWebEngineClientCertificateOption(this, i)); - } - - return QQmlListProperty<QQuickWebEngineClientCertificateOption>( - this, nullptr, - certificates_count, - certificates_at); -} - -/*! - \qmlmethod void WebEngineClientCertificateSelection::select(WebEngineClientCertificateOption certificate) - - Selects the client certificate \a certificate. The certificate must be one - of the offered certificates. - - \sa selectNone() -*/ -void QQuickWebEngineClientCertificateSelection::select(const QQuickWebEngineClientCertificateOption *certificate) -{ - select(certificate->m_index); -} - -/*! - \qmlmethod void WebEngineClientCertificateSelection::select(int index) - - Selects the client certificate at the index \a index in the list of offered certificates. - - \sa selectNone() -*/ -void QQuickWebEngineClientCertificateSelection::select(int index) -{ - d_ptr->select(index); -} - -/*! - \qmlmethod void WebEngineClientCertificateSelection::selectNone() - - Continues 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 QQuickWebEngineClientCertificateSelection::selectNone() -{ - d_ptr->selectNone(); -} - -/*! - \qmlproperty url WebEngineClientCertificateSelection::host - \brief The host and port of the server requesting the client certificate. -*/ -QUrl QQuickWebEngineClientCertificateSelection::host() const -{ - return d_ptr->hostAndPort(); -} - -QT_END_NAMESPACE - -#endif // QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) diff --git a/src/webengine/api/qquickwebengineclientcertificateselection_p.h b/src/webengine/api/qquickwebengineclientcertificateselection_p.h deleted file mode 100644 index adf8b5f7c..000000000 --- a/src/webengine/api/qquickwebengineclientcertificateselection_p.h +++ /dev/null @@ -1,131 +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 QQUICKWEBENGINECERTSELECTION_P_H -#define QQUICKWEBENGINECERTSELECTION_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 <QtWebEngine/private/qtwebengineglobal_p.h> - -#include <QtCore/QDateTime> -#include <QtCore/QObject> -#include <QtCore/QSharedPointer> -#include <QtCore/QUrl> -#include <QtCore/QVector> -#include <QtQml/QQmlListProperty> - -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) - -QT_BEGIN_NAMESPACE - -class ClientCertSelectController; -class QQuickWebEngineClientCertificateSelection; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineClientCertificateOption : public QObject { - Q_OBJECT - Q_PROPERTY(QString issuer READ issuer CONSTANT FINAL) - Q_PROPERTY(QString subject READ subject CONSTANT FINAL) - Q_PROPERTY(QDateTime effectiveDate READ effectiveDate CONSTANT FINAL) - Q_PROPERTY(QDateTime expiryDate READ expiryDate CONSTANT FINAL) - Q_PROPERTY(bool isSelfSigned READ isSelfSigned CONSTANT FINAL) - -public: - QString issuer() const; - QString subject() const; - QDateTime effectiveDate() const; - QDateTime expiryDate() const; - bool isSelfSigned() const; - - Q_INVOKABLE void select(); - -private: - friend class QQuickWebEngineClientCertificateSelection; - QQuickWebEngineClientCertificateOption(QQuickWebEngineClientCertificateSelection *selection, int index); - - QQuickWebEngineClientCertificateSelection *m_selection; - int m_index; -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineClientCertificateSelection : public QObject { - Q_OBJECT - Q_PROPERTY(QUrl host READ host CONSTANT FINAL) - Q_PROPERTY(QQmlListProperty<QQuickWebEngineClientCertificateOption> certificates READ certificates CONSTANT FINAL) - -public: - QQuickWebEngineClientCertificateSelection() = default; - - QUrl host() const; - - Q_INVOKABLE void select(int idx); - Q_INVOKABLE void select(const QQuickWebEngineClientCertificateOption *certificate); - Q_INVOKABLE void selectNone(); - QQmlListProperty<QQuickWebEngineClientCertificateOption> certificates(); - -private: - friend class QQuickWebEngineViewPrivate; - friend class QQuickWebEngineClientCertificateOption; - - static int certificates_count(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p); - static QQuickWebEngineClientCertificateOption *certificates_at(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p, int idx); - - explicit QQuickWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController>); - - mutable QVector<QQuickWebEngineClientCertificateOption *> m_certificates; - QSharedPointer<ClientCertSelectController> d_ptr; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QQuickWebEngineClientCertificateOption *) -Q_DECLARE_METATYPE(QQmlListProperty<QQuickWebEngineClientCertificateOption>) -Q_DECLARE_METATYPE(QQuickWebEngineClientCertificateSelection *) - -#endif - -#endif // QQUICKWEBENGINECERTSELECTION_P_H diff --git a/src/webengine/api/qquickwebenginecontextmenurequest.cpp b/src/webengine/api/qquickwebenginecontextmenurequest.cpp deleted file mode 100644 index e1ebd4c8c..000000000 --- a/src/webengine/api/qquickwebenginecontextmenurequest.cpp +++ /dev/null @@ -1,383 +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 "qquickwebenginecontextmenurequest_p.h" -#include "web_contents_adapter_client.h" - -QT_BEGIN_NAMESPACE - -// Match MediaType enum -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeNone, - QQuickWebEngineContextMenuRequest::MediaTypeNone) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeImage, - QQuickWebEngineContextMenuRequest::MediaTypeImage) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeAudio, - QQuickWebEngineContextMenuRequest::MediaTypeAudio) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeVideo, - QQuickWebEngineContextMenuRequest::MediaTypeVideo) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeCanvas, - QQuickWebEngineContextMenuRequest::MediaTypeCanvas) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeFile, - QQuickWebEngineContextMenuRequest::MediaTypeFile) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypePlugin, - QQuickWebEngineContextMenuRequest::MediaTypePlugin) - -// Match MediaFlag enum -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaInError, - QQuickWebEngineContextMenuRequest::MediaInError) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaPaused, - QQuickWebEngineContextMenuRequest::MediaPaused) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaMuted, - QQuickWebEngineContextMenuRequest::MediaMuted) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaLoop, - QQuickWebEngineContextMenuRequest::MediaLoop) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanSave, - QQuickWebEngineContextMenuRequest::MediaCanSave) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaHasAudio, - QQuickWebEngineContextMenuRequest::MediaHasAudio) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanToggleControls, - QQuickWebEngineContextMenuRequest::MediaCanToggleControls) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaControls, - QQuickWebEngineContextMenuRequest::MediaControls) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanPrint, - QQuickWebEngineContextMenuRequest::MediaCanPrint) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanRotate, - QQuickWebEngineContextMenuRequest::MediaCanRotate) - -// Match EditFlag enum -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanUndo, - QQuickWebEngineContextMenuRequest::CanUndo) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanRedo, - QQuickWebEngineContextMenuRequest::CanRedo) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCut, - QQuickWebEngineContextMenuRequest::CanCut) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCopy, - QQuickWebEngineContextMenuRequest::CanCopy) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanPaste, - QQuickWebEngineContextMenuRequest::CanPaste) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanDelete, - QQuickWebEngineContextMenuRequest::CanDelete) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanSelectAll, - QQuickWebEngineContextMenuRequest::CanSelectAll) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanTranslate, - QQuickWebEngineContextMenuRequest::CanTranslate) -ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanEditRichly, - QQuickWebEngineContextMenuRequest::CanEditRichly) - -/*! - \qmltype ContextMenuRequest - \instantiates QQuickWebEngineContextMenuRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.4 - - \brief A request for showing a context menu. - - A ContextMenuRequest is passed as an argument of the - WebEngineView::contextMenuRequested signal. It provides further - information about the context of the request. The position of the - request origin can be found via the \l x and \l y properties. - - The \l accepted property of the request indicates whether the request - is handled by the user code or the default context menu should - be displayed. - - The following code uses a custom menu to handle the request: - - \code - WebEngineView { - id: view - // ... - onContextMenuRequested: function(request) { - request.accepted = true; - myMenu.x = request.x; - myMenu.y = request.y; - myMenu.trigger.connect(view.triggerWebAction); - myMenu.popup(); - } - // ... - } - \endcode -*/ - -QQuickWebEngineContextMenuRequest::QQuickWebEngineContextMenuRequest( - const QtWebEngineCore::WebEngineContextMenuData &data, QObject *parent): - QObject(parent) - , m_data(new QtWebEngineCore::WebEngineContextMenuData(data)) - , m_accepted(false) -{ -} - -QQuickWebEngineContextMenuRequest::~QQuickWebEngineContextMenuRequest() -{ -} - -/*! - \qmlproperty int ContextMenuRequest::x - \readonly - - The x coordinate of the user action from where the context - menu request originates. -*/ - -int QQuickWebEngineContextMenuRequest::x() const -{ - return m_data->position().x(); -} - -/*! - \qmlproperty int ContextMenuRequest::y - \readonly - - The y coordinate of the user action from where the context - menu request originates. -*/ - -int QQuickWebEngineContextMenuRequest::y() const -{ - return m_data->position().y(); -} - -/*! - \qmlproperty string ContextMenuRequest::selectedText - \readonly - - The selected text the context menu was created for. -*/ - -QString QQuickWebEngineContextMenuRequest::selectedText() const -{ - return m_data->selectedText(); -} - -/*! - \qmlproperty string ContextMenuRequest::linkText - \readonly - - The text of the link if the context menu was requested for a link. -*/ - -QString QQuickWebEngineContextMenuRequest::linkText() const -{ - return m_data->linkText(); -} - -/*! - \qmlproperty url ContextMenuRequest::linkUrl - \readonly - - The URL of the link if the selected web page content is a link. - It is not guaranteed to be a valid URL. -*/ - -QUrl QQuickWebEngineContextMenuRequest::linkUrl() const -{ - return m_data->unfilteredLinkUrl(); -} - -/*! - \qmlproperty url ContextMenuRequest::mediaUrl - \readonly - - The URL of media if the selected web content is a media element. -*/ - -QUrl QQuickWebEngineContextMenuRequest::mediaUrl() const -{ - return m_data->mediaUrl(); -} - -/*! - \qmlproperty enumeration ContextMenuRequest::mediaType - \readonly - - The type of the media element or \c MediaTypeNone if - the selected web page content is not a media element. - - \value ContextMenuRequest.MediaTypeNone - Not a media. - \value ContextMenuRequest.MediaTypeImage - An image. - \value ContextMenuRequest.MediaTypeVideo - A video. - \value ContextMenuRequest.MediaTypeAudio - An audio element. - \value ContextMenuRequest.MediaTypeCanvas - A canvas. - \value ContextMenuRequest.MediaTypeFile - A file. - \value ContextMenuRequest.MediaTypePlugin - A plugin. -*/ - -QQuickWebEngineContextMenuRequest::MediaType QQuickWebEngineContextMenuRequest::mediaType() const -{ - return static_cast<QQuickWebEngineContextMenuRequest::MediaType>(m_data->mediaType()); -} - -/*! - \qmlproperty bool ContextMenuRequest::isContentEditable - \readonly - - Indicates whether the selected web content is editable. -*/ - -bool QQuickWebEngineContextMenuRequest::isContentEditable() const -{ - return m_data->isEditable(); -} - -/*! - \qmlproperty string ContextMenuRequest::misspelledWord - \readonly - - If the context is a word considered misspelled by the spell-checker, - returns the misspelled word. -*/ - -QString QQuickWebEngineContextMenuRequest::misspelledWord() const -{ - return m_data->misspelledWord(); -} - -/*! - \qmlproperty stringlist ContextMenuRequest::spellCheckerSuggestions - \readonly - - If the context is a word considered misspelled by the spell-checker, - returns a list of suggested replacements. -*/ - -QStringList QQuickWebEngineContextMenuRequest::spellCheckerSuggestions() const -{ - return m_data->spellCheckerSuggestions(); -} - -/*! - \qmlproperty bool ContextMenuRequest::accepted - - Indicates whether the context menu request has been - handled by the signal handler. - - If the property is \c false after any signal handlers - for WebEngineView::contextMenuRequested have been executed, - a default context menu will be shown. - To prevent this, set \c{request.accepted} to \c true. - - The default is \c false. - - \note The default content of the context menu depends on the - web element for which the request was actually generated. -*/ - -bool QQuickWebEngineContextMenuRequest::isAccepted() const -{ - return m_accepted; -} - -void QQuickWebEngineContextMenuRequest::setAccepted(bool accepted) -{ - m_accepted = accepted; -} - -/*! - \qmlproperty flags ContextMenuRequest::mediaFlags - \readonly - \since QtWebEngine 1.7 - - The current media element's status and its available operations. - \c MediaNone if the selected web page content is not a media element. - - \value ContextMenuRequest.MediaInError - An error occurred. - \value ContextMenuRequest.MediaPaused - Media is paused. - \value ContextMenuRequest.MediaMuted - Media is muted. - \value ContextMenuRequest.MediaLoop - Media can be looped. - \value ContextMenuRequest.MediaCanSave - Media can be saved. - \value ContextMenuRequest.MediaHasAudio - Media has audio. - \value ContextMenuRequest.MediaCanToggleControls - Media can show controls. - \value ContextMenuRequest.MediaControls - Media controls are shown. - \value ContextMenuRequest.MediaCanPrint - Media is printable. - \value ContextMenuRequest.MediaCanRotate - Media is rotatable. -*/ -QQuickWebEngineContextMenuRequest::MediaFlags QQuickWebEngineContextMenuRequest::mediaFlags() const -{ - return static_cast<QQuickWebEngineContextMenuRequest::MediaFlags>(m_data->mediaFlags()); -} - -/*! - \qmlproperty flags ContextMenuRequest::editFlags - \readonly - \since QtWebEngine 1.7 - - The available edit operations in the current context or \c CanDoNone if no actions are available. - - \value ContextMenuRequest.CanUndo - Undo is available. - \value ContextMenuRequest.CanRedo - Redo is available. - \value ContextMenuRequest.CanCut - Cut is available. - \value ContextMenuRequest.CanCopy - Copy is available. - \value ContextMenuRequest.CanPaste - Paste is available. - \value ContextMenuRequest.CanDelete - Delete is available. - \value ContextMenuRequest.CanSelectAll - Select All is available. - \value ContextMenuRequest.CanTranslate - Translate is available. - \value ContextMenuRequest.CanEditRichly - Context is richly editable. -*/ -QQuickWebEngineContextMenuRequest::EditFlags QQuickWebEngineContextMenuRequest::editFlags() const -{ - return static_cast<QQuickWebEngineContextMenuRequest::EditFlags>(m_data->editFlags()); -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginecontextmenurequest_p.h b/src/webengine/api/qquickwebenginecontextmenurequest_p.h deleted file mode 100644 index bc50eccb8..000000000 --- a/src/webengine/api/qquickwebenginecontextmenurequest_p.h +++ /dev/null @@ -1,150 +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 QQUICKWEBENGINECONTEXTMENUREQUEST_H -#define QQUICKWEBENGINECONTEXTMENUREQUEST_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 <QtWebEngine/private/qtwebengineglobal_p.h> -#include <QtCore/QScopedPointer> -#include <QtCore/QObject> -#include <QtCore/QUrl> - -namespace QtWebEngineCore { - class WebEngineContextMenuData; -} - -QT_BEGIN_NAMESPACE - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineContextMenuRequest: public QObject { - Q_OBJECT -public: - enum MediaType { - MediaTypeNone, - MediaTypeImage, - MediaTypeVideo, - MediaTypeAudio, - MediaTypeCanvas, - MediaTypeFile, - MediaTypePlugin - }; - Q_ENUM(MediaType) - - // 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) - - Q_PROPERTY(int x READ x CONSTANT FINAL) - Q_PROPERTY(int y READ y CONSTANT FINAL) - Q_PROPERTY(QString selectedText READ selectedText CONSTANT FINAL) - Q_PROPERTY(QString linkText READ linkText CONSTANT FINAL) - Q_PROPERTY(QUrl linkUrl READ linkUrl CONSTANT FINAL) - Q_PROPERTY(QUrl mediaUrl READ mediaUrl CONSTANT FINAL) - Q_PROPERTY(MediaType mediaType READ mediaType CONSTANT FINAL) - Q_PROPERTY(bool isContentEditable READ isContentEditable CONSTANT FINAL) - Q_PROPERTY(QString misspelledWord READ misspelledWord CONSTANT FINAL) - Q_PROPERTY(QStringList spellCheckerSuggestions READ spellCheckerSuggestions CONSTANT FINAL) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL) - Q_PROPERTY(MediaFlags mediaFlags READ mediaFlags CONSTANT FINAL REVISION 1) - Q_PROPERTY(EditFlags editFlags READ editFlags CONSTANT FINAL REVISION 1) - - ~QQuickWebEngineContextMenuRequest(); - int x() const; - int y() 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; - bool isAccepted() const; - void setAccepted(bool accepted); - MediaFlags mediaFlags() const; - EditFlags editFlags() const; - -private: - QQuickWebEngineContextMenuRequest(const QtWebEngineCore::WebEngineContextMenuData &data, QObject *parent = nullptr); - QScopedPointer<QtWebEngineCore::WebEngineContextMenuData> m_data; - bool m_accepted; - friend class QQuickWebEngineView; - friend class QQuickWebEngineViewPrivate; - Q_DISABLE_COPY(QQuickWebEngineContextMenuRequest) -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINECONTEXTMENUREQUEST_H diff --git a/src/webengine/api/qquickwebenginedialogrequests.cpp b/src/webengine/api/qquickwebenginedialogrequests.cpp deleted file mode 100644 index da1aecaf6..000000000 --- a/src/webengine/api/qquickwebenginedialogrequests.cpp +++ /dev/null @@ -1,936 +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 "qquickwebenginedialogrequests_p.h" -#include "authentication_dialog_controller.h" -#include "javascript_dialog_controller.h" -#include "color_chooser_controller.h" -#include "file_picker_controller.h" -#include "web_contents_adapter_client.h" - -#include <QCursor> -#include <QQuickItem> - -QT_BEGIN_NAMESPACE - -using namespace QtWebEngineCore; - -ASSERT_ENUMS_MATCH(WebContentsAdapterClient::AlertDialog, - QQuickWebEngineJavaScriptDialogRequest::DialogTypeAlert) -ASSERT_ENUMS_MATCH(WebContentsAdapterClient::ConfirmDialog, - QQuickWebEngineJavaScriptDialogRequest::DialogTypeConfirm) -ASSERT_ENUMS_MATCH(WebContentsAdapterClient::PromptDialog, - QQuickWebEngineJavaScriptDialogRequest::DialogTypePrompt) -ASSERT_ENUMS_MATCH(WebContentsAdapterClient::UnloadDialog, - QQuickWebEngineJavaScriptDialogRequest::DialogTypeBeforeUnload) - -ASSERT_ENUMS_MATCH(FilePickerController::Open, - QQuickWebEngineFileDialogRequest::FileModeOpen) -ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, - QQuickWebEngineFileDialogRequest::FileModeOpenMultiple) -ASSERT_ENUMS_MATCH(FilePickerController::UploadFolder, - QQuickWebEngineFileDialogRequest::FileModeUploadFolder) -ASSERT_ENUMS_MATCH(FilePickerController::Save, - QQuickWebEngineFileDialogRequest::FileModeSave) - -/*! - \qmltype AuthenticationDialogRequest - \instantiates QQuickWebEngineAuthenticationDialogRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.4 - - \brief A request for providing authentication credentials required - by proxies or HTTP servers. - - An AuthenticationDialogRequest is passed as an argument of the - WebEngineView::authenticationDialogRequested signal. It is generated - when basic HTTP or proxy authentication is required. The type - of authentication can be checked with the \l type property. - - The \l accepted property of the request indicates whether the request - is handled by the user code or the default dialog should be displayed. - If you set the \l accepted property to \c true, make sure to call - either \l dialogAccept() or \l dialogReject() afterwards. - - The following code uses a custom dialog to handle the request: - \code - - WebEngineView { - // ... - onAuthenticationDialogRequested: function(request) { - request.accepted = true; - myDialog.request = request // keep the reference to the request - myDialog.accept.connect(request.dialogAccept); - myDialog.reject.connect(request.dialogReject); - myDialog.visible = true; - } - // ... - } - - \endcode -*/ - -QQuickWebEngineAuthenticationDialogRequest::QQuickWebEngineAuthenticationDialogRequest( - QSharedPointer<AuthenticationDialogController> controller, - QObject *parent): - QObject(parent) - , m_controller(controller.toWeakRef()) - , m_url(controller->url()) - , m_realm(controller->realm()) - , m_type(controller->isProxy() ? AuthenticationTypeProxy - : AuthenticationTypeHTTP) - , m_host(controller->host()) - , m_accepted(false) -{ - -} - -QQuickWebEngineAuthenticationDialogRequest::~QQuickWebEngineAuthenticationDialogRequest() -{ -} - -/*! - \qmlproperty url AuthenticationDialogRequest::url - \readonly - - The URL of the HTTP request for which authentication was requested. - In case of proxy authentication, this is a request URL which is proxied - via host. - - \sa proxyHost -*/ - -QUrl QQuickWebEngineAuthenticationDialogRequest::url() const -{ - return m_url; -} - -/*! - \qmlproperty string AuthenticationDialogRequest::realm - \readonly - - The HTTP authentication realm attribute value of the \c WWW-Authenticate - header. Empty if \l type is AuthenticationTypeProxy. -*/ - -QString QQuickWebEngineAuthenticationDialogRequest::realm() const -{ - return m_realm; -} - -/*! - \qmlproperty string AuthenticationDialogRequest::proxyHost - \readonly - - The hostname of the authentication proxy. - Empty if \l type is AuthenticationTypeHTTP. -*/ - -QString QQuickWebEngineAuthenticationDialogRequest::proxyHost() const -{ - return m_host; -} - -/*! - \qmlproperty enumeration AuthenticationDialogRequest::type - \readonly - - The type of the authentication request. - - \value WebEngineAuthenticationDialogRequest.AuthenticationTypeHTTP - HTTP authentication. - \value WebEngineAuthenticationDialogRequest.AuthenticationTypeProxy - Proxy authentication. -*/ - -QQuickWebEngineAuthenticationDialogRequest::AuthenticationType -QQuickWebEngineAuthenticationDialogRequest::type() const -{ - return m_type; -} - -/*! - \qmlproperty bool AuthenticationDialogRequest::accepted - - Indicates whether the authentication dialog request has been - accepted by the signal handler. - - If the property is \c false after any signal handlers - for WebEngineView::authenticationDialogRequested have been executed, - a default authentication dialog will be shown. - To prevent this, set \c{request.accepted} to \c true. - - The default is \c false. -*/ - -bool QQuickWebEngineAuthenticationDialogRequest::isAccepted() const -{ - return m_accepted; -} - -void QQuickWebEngineAuthenticationDialogRequest::setAccepted(bool accepted) -{ - m_accepted = accepted; -} - -/*! - \qmlmethod void AuthenticationDialogRequest::dialogAccept(string username, string password) - - This function notifies the engine that the user accepted the dialog, - providing the \a username and the \a password required for authentication. -*/ - -void QQuickWebEngineAuthenticationDialogRequest::dialogAccept(const QString &user, - const QString &password) -{ - m_accepted = true; - QSharedPointer<AuthenticationDialogController> controller - = m_controller.toStrongRef(); - if (controller) - controller->accept(user,password); -} - -/*! - \qmlmethod void AuthenticationDialogRequest::dialogReject() - - This function notifies the engine that the user rejected the dialog and the - authentication shall not proceed. -*/ - -void QQuickWebEngineAuthenticationDialogRequest::dialogReject() -{ - m_accepted = true; - QSharedPointer<AuthenticationDialogController> controller - = m_controller.toStrongRef(); - if (controller) - controller->reject(); -} - -/////////////////////////////////////////////////////////////////////////////// - -/*! - \qmltype JavaScriptDialogRequest - \instantiates QQuickWebEngineJavaScriptDialogRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.4 - - \brief A request for showing an alert, a confirmation, or a prompt dialog - from within JavaScript to the user. - - A JavaScriptDialogRequest is passed as an argument of the - WebEngineView::javaScriptDialogRequested signal. The request is emitted - if JavaScript on the page calls HTML5's - \l{https://www.w3.org/TR/html5/webappapis.html#simple-dialogs}{Simple Dialogs} - API, or in response to HTML5's - \l {https://www.w3.org/TR/html5/browsers.html#beforeunloadevent}{BeforeUnloadEvent}. - The type of a particular dialog can be checked with the \l type property. - - The \l accepted property of the request indicates whether the request - is handled by the user code or the default dialog should be displayed. - If you set the \l accepted property to \c true, make sure to call either - \l dialogAccept() or \l dialogReject() afterwards. The JavaScript call - causing the request will be blocked until then. - - The following code uses a custom dialog to handle the request: - - \code - WebEngineView { - // ... - onJavaScriptDialogRequested: function(request) { - request.accepted = true; - myDialog.request = request // keep the reference to the request - myDialog.accept.connect(request.dialogAccept); - myDialog.reject.connect(request.dialogReject); - myDialog.visible = true; - } - // ... - } - \endcode -*/ - -QQuickWebEngineJavaScriptDialogRequest::QQuickWebEngineJavaScriptDialogRequest( - QSharedPointer<JavaScriptDialogController> controller, QObject *parent): - QObject(parent) - , m_controller(controller.toWeakRef()) - , m_message(controller->message()) - , m_defaultPrompt(controller->defaultPrompt()) - , m_title(controller->title()) - , m_type(static_cast<QQuickWebEngineJavaScriptDialogRequest::DialogType>(controller->type())) - , m_securityOrigin(controller->securityOrigin()) - , m_accepted(false) -{ -} - -QQuickWebEngineJavaScriptDialogRequest::~QQuickWebEngineJavaScriptDialogRequest() -{ - -} - -/*! - \qmlproperty string JavaScriptDialogRequest::message - \readonly - - The message to be shown to the user. -*/ - -QString QQuickWebEngineJavaScriptDialogRequest::message() const -{ - return m_message; -} - -/*! - \qmlproperty string JavaScriptDialogRequest::defaultText - \readonly - - The default prompt text, if the requested dialog is a prompt. -*/ - - -QString QQuickWebEngineJavaScriptDialogRequest::defaultText() const -{ - return m_defaultPrompt; -} - -/*! - \qmlproperty string JavaScriptDialogRequest::title - \readonly - - A default title for the dialog. -*/ - -QString QQuickWebEngineJavaScriptDialogRequest::title() const -{ - return m_title; -} - -/*! - \qmlproperty enumeration JavaScriptDialogRequest::type - \readonly - - Returns the type of the requested dialog box. For more information, see - HTML5's - \l{https://www.w3.org/TR/html5/webappapis.html#simple-dialogs}{Simple Dialogs}. - - \value JavaScriptDialogRequest.DialogTypeAlert - A JavaScript alert dialog. - \value JavaScriptDialogRequest.DialogTypeConfirm - A JavaScript confirmation dialog. - \value JavaScriptDialogRequest.DialogTypePrompt - A JavaScript prompt dialog. - \value JavaScriptDialogRequest.DialogTypeBeforeUnload - The users should be asked if they want to leave the page. -*/ - -QQuickWebEngineJavaScriptDialogRequest::DialogType QQuickWebEngineJavaScriptDialogRequest::type() const -{ - return m_type; -} - -/*! - \qmlproperty url JavaScriptDialogRequest::securityOrigin - \readonly - - The URL of the security origin. -*/ - -QUrl QQuickWebEngineJavaScriptDialogRequest::securityOrigin() const -{ - return m_securityOrigin; -} - -/*! - \qmlproperty bool JavaScriptDialogRequest::accepted - - Indicates whether the JavaScript dialog request has been - accepted by the signal handler. - - If the property is \c false after any signal handlers - for WebEngineView::javaScriptDialogRequested have been executed, - a default dialog will be shown. - To prevent this, set \c{request.accepted} to \c true. - - The default is \c false. -*/ - -bool QQuickWebEngineJavaScriptDialogRequest::isAccepted() const -{ - return m_accepted; -} - -void QQuickWebEngineJavaScriptDialogRequest::setAccepted(bool accepted) -{ - m_accepted = accepted; -} - -/*! - \qmlmethod void JavaScriptDialogRequest::dialogAccept() - - This function notifies the engine that the user accepted the dialog. -*/ - -/*! - \qmlmethod void JavaScriptDialogRequest::dialogAccept(string text) - - This function notifies the engine that the user accepted the dialog, - providing the \a text in case of a prompt message box. -*/ - -void QQuickWebEngineJavaScriptDialogRequest::dialogAccept(const QString& text) -{ - m_accepted = true; - QSharedPointer<JavaScriptDialogController> controller - = m_controller.toStrongRef(); - if (controller) { - controller->textProvided(text); - controller->accept(); - } -} - -/*! - \qmlmethod void JavaScriptDialogRequest::dialogReject() - - This function notifies the engine that the user rejected the dialog. -*/ - -void QQuickWebEngineJavaScriptDialogRequest::dialogReject() -{ - m_accepted = true; - QSharedPointer<JavaScriptDialogController> controller - = m_controller.toStrongRef(); - if (controller) - controller->reject(); -} - -/////////////////////////////////////////////////////////////////////////////// - -/*! - \qmltype ColorDialogRequest - \instantiates QQuickWebEngineColorDialogRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.4 - - \brief A request for selecting a color by the user. - - A ColorDialogRequest is passed as an argument of the - WebEngineView::colorDialogRequested signal. It is generated when - a color picker dialog is requested. See - \l { https://www.w3.org/TR/html5/forms.html#color-state-(type=color)} - {HTML5 Color State}. - - The \l accepted property of the request indicates whether the request - is handled by the user code or the default dialog should be displayed. - If you set the \l accepted property to \c true, make sure to call either - \l dialogAccept() or \l dialogReject() afterwards. - - The following code uses a custom dialog to handle the request: - - \code - WebEngineView { - // ... - onColorDialogRequested: function(request) { - request.accepted = true; - myDialog.request = request // keep the reference to the request - myDialog.accept.connect(request.dialogAccept); - myDialog.reject.connect(request.dialogReject); - myDialog.visible = true; - } - // ... - } - \endcode -*/ - -QQuickWebEngineColorDialogRequest::QQuickWebEngineColorDialogRequest( - QSharedPointer<ColorChooserController> controller, QObject *parent): - QObject(parent) - , m_controller(controller.toWeakRef()) - , m_color(controller->initialColor()) - , m_accepted(false) -{ - -} - -QQuickWebEngineColorDialogRequest::~QQuickWebEngineColorDialogRequest() -{ - -} - -/*! - \qmlproperty color ColorDialogRequest::color - \readonly - - The default color to be selected in the dialog. -*/ - -QColor QQuickWebEngineColorDialogRequest::color() const -{ - return m_color; -} - -/*! - \qmlproperty bool ColorDialogRequest::accepted - - Indicates whether the color picker dialog request has been - accepted by the signal handler. - - If the property is \c false after any signal handlers - for WebEngineView::colorDialogRequested have been executed, - a default color picker dialog will be shown. - To prevent this, set \c{request.accepted} to \c true. - - The default is \c false. -*/ - -bool QQuickWebEngineColorDialogRequest::isAccepted() const -{ - return m_accepted; -} - -void QQuickWebEngineColorDialogRequest::setAccepted(bool accepted) -{ - m_accepted = accepted; -} - - -/*! - \qmlmethod void ColorDialogRequest::dialogAccept(color color) - - This function notifies the engine that the user accepted the dialog, - providing the \a color. -*/ - -void QQuickWebEngineColorDialogRequest::dialogAccept(const QColor &color) -{ - m_accepted = true; - QSharedPointer<ColorChooserController> controller = m_controller.toStrongRef(); - if (controller) - controller->accept(color); -} - -/*! - \qmlmethod void ColorDialogRequest::dialogReject() - - This function notifies the engine that the user rejected the dialog. -*/ - -void QQuickWebEngineColorDialogRequest::dialogReject() -{ - m_accepted = true; - QSharedPointer<ColorChooserController> controller = m_controller.toStrongRef(); - if (controller) - controller->reject(); -} - -/////////////////////////////////////////////////////////////////////////////// - -/*! - \qmltype FileDialogRequest - \instantiates QQuickWebEngineFileDialogRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.4 - - \brief A request for letting the user choose a (new or existing) file or - directory. - - A FileDialogRequest is passed as an argument of the - WebEngineView::fileDialogRequested signal. It is generated - when the file dialog is requested by the input element. - See \l {https://www.w3.org/TR/html5/forms.html#file-upload-state-(type=file)}{File Upload state}. - - The \l accepted property of the request indicates whether the request - is handled by the user code or the default dialog should be displayed. - If you set the \l accepted property to \c true, make sure to call either - \l dialogAccept() or \l dialogReject() afterwards. - - The following code uses a custom dialog to handle the request: - - \code - WebEngineView { - // ... - onFileDialogRequested: function(request) { - request.accepted = true; - myDialog.request = request // keep the reference to the request - myDialog.accept.connect(request.dialogAccept); - myDialog.reject.connect(request.dialogReject); - myDialog.visible = true; - } - // ... - } - \endcode -*/ - -QQuickWebEngineFileDialogRequest::QQuickWebEngineFileDialogRequest( - QSharedPointer<FilePickerController> controller, QObject *parent): - QObject(parent) - , m_controller(controller.toWeakRef()) - , m_filename(controller->defaultFileName()) - , m_acceptedMimeTypes(controller->acceptedMimeTypes()) - , m_mode(static_cast<QQuickWebEngineFileDialogRequest::FileMode>(controller->mode())) - , m_accepted(false) -{ - -} - -QQuickWebEngineFileDialogRequest::~QQuickWebEngineFileDialogRequest() -{ - -} - -/*! - \qmlproperty stringlist FileDialogRequest::acceptedMimeTypes - \readonly - - A list of MIME types specified in the input element. The selection - should be restricted to only these types of files. -*/ - -QStringList QQuickWebEngineFileDialogRequest::acceptedMimeTypes() const -{ - return m_acceptedMimeTypes; -} - -/*! - \qmlproperty string FileDialogRequest::defaultFileName - \readonly - - The default name of the file to be selected in the dialog. -*/ - -QString QQuickWebEngineFileDialogRequest::defaultFileName() const -{ - return m_filename; -} - -/*! - \qmlproperty enumeration FileDialogRequest::mode - \readonly - - The mode of the file dialog. - - \value FileDialogRequest.FileModeOpen - Allows users to specify a single existing file. - \value FileDialogRequest.FileModeOpenMultiple - Allows users to specify multiple existing files. - \value FileDialogRequest.FileModeUploadFolder - Allows users to specify a single existing folder for upload. - \value FileDialogRequest.FileModeSave - Allows users to specify a non-existing file. If an existing file - is selected, the users should be informed that the file is going - to be overwritten. -*/ - -QQuickWebEngineFileDialogRequest::FileMode QQuickWebEngineFileDialogRequest::mode() const -{ - return m_mode; -} - -/*! - \qmlproperty bool FileDialogRequest::accepted - - Indicates whether the file picker dialog request has been - handled by the signal handler. - - If the property is \c false after any signal handlers - for WebEngineView::fileDialogRequested have been executed, - a default file picker dialog will be shown. - To prevent this, set \c{request.accepted} to \c true. - - The default is \c false. -*/ - -bool QQuickWebEngineFileDialogRequest::isAccepted() const -{ - return m_accepted; -} - -void QQuickWebEngineFileDialogRequest::setAccepted(bool accepted) -{ - m_accepted = accepted; -} - -/*! - \qmlmethod void FileDialogRequest::dialogAccept(stringlist files) - - This function needs to be called when the user accepted the dialog with - \a files. -*/ - -void QQuickWebEngineFileDialogRequest::dialogAccept(const QStringList &files) -{ - m_accepted = true; - QSharedPointer<FilePickerController> controller = m_controller.toStrongRef(); - if (controller) - controller->accepted(files); -} - -/*! - \qmlmethod void FileDialogRequest::dialogReject() - - This function needs to be called when the user did not accepted the dialog. -*/ - -void QQuickWebEngineFileDialogRequest::dialogReject() -{ - m_accepted = true; - QSharedPointer<FilePickerController> controller = m_controller.toStrongRef(); - if (controller) - controller->rejected(); -} - -/////////////////////////////////////////////////////////////////////////////// - -/*! - \qmltype FormValidationMessageRequest - \instantiates QQuickWebEngineFormValidationMessageRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.4 - \obsolete - - \brief A request for showing a HTML5 form validation message to the user. - - No longer used since 5.11, as Blink now renders Validation messages internally. -*/ - -QQuickWebEngineFormValidationMessageRequest::QQuickWebEngineFormValidationMessageRequest( - QQuickWebEngineFormValidationMessageRequest::RequestType type, const QRect& anchor, - const QString &mainText, const QString &subText, QObject *parent): - QObject(parent) - , m_anchor(anchor) - , m_mainText(mainText) - , m_subText(subText) - , m_type(type) - , m_accepted(false) -{ - -} - -QQuickWebEngineFormValidationMessageRequest::~QQuickWebEngineFormValidationMessageRequest() -{ - -} - -/*! - \qmlproperty rectangle FormValidationMessageRequest::anchor - \readonly - - An anchor of an element in the viewport for which the form - validation message should be displayed. -*/ - -QRect QQuickWebEngineFormValidationMessageRequest::anchor() const -{ - return m_anchor; -} - -/*! - \qmlproperty bool FormValidationMessageRequest::text - \readonly - - The text of the form validation message. -*/ - - -QString QQuickWebEngineFormValidationMessageRequest::text() const -{ - return m_mainText; -} - -/*! - \qmlproperty bool FormValidationMessageRequest::subText - \readonly - - The subtext of the form validation message. -*/ - - -QString QQuickWebEngineFormValidationMessageRequest::subText() const -{ - return m_subText; -} - -/*! - \qmlproperty enumeration FormValidationMessageRequest::type - \readonly - - The type of the form validation message request. - - \value ValidationMessageRequest.Show - The form validation message should be shown. - \value ValidationMessageRequest.Hide - The form validation message should be hidden. - \value ValidationMessageRequest.Move - The form validation message should be moved. -*/ - -QQuickWebEngineFormValidationMessageRequest::RequestType QQuickWebEngineFormValidationMessageRequest::type() const -{ - return m_type; -} - -/*! - \qmlproperty bool FormValidationMessageRequest::accepted - - Indicates whether the form validation request has been - accepted by the signal handler. - - If the property is \c false after any signal handlers - for WebEngineView::validationMessageRequested have been executed, - a default file validation message will be shown. - To prevent this, set \c {request.accepted} to \c true. - - The default is \c false. -*/ - -bool QQuickWebEngineFormValidationMessageRequest::isAccepted() const -{ - return m_accepted; -} - -void QQuickWebEngineFormValidationMessageRequest::setAccepted(bool accepted) -{ - m_accepted = accepted; -} - -/////////////////////////////////////////////////////////////////////////////// - -/*! - \qmltype TooltipRequest - \instantiates QQuickWebEngineTooltipRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.10 - - \brief A request for showing a tooltip to the user. -*/ - -QQuickWebEngineTooltipRequest::QQuickWebEngineTooltipRequest( - const QString &text, QObject *parent): - QObject(parent) - , m_text(text) - , m_type(text.isEmpty() ? RequestType::Hide : RequestType::Show) - , m_accepted(false) -{ - Q_ASSERT(parent); - if (QQuickItem *view = qobject_cast<QQuickItem *>(parent)) - m_position = view->mapFromGlobal(view->cursor().pos()).toPoint(); -} - -QQuickWebEngineTooltipRequest::~QQuickWebEngineTooltipRequest() -{ - -} - -/*! - \qmlproperty int TooltipRequest::x - \readonly - - The x coordinate of the top-left corner of the requested tooltip. -*/ - -int QQuickWebEngineTooltipRequest::x() const -{ - return m_position.x(); -} - -/*! - \qmlproperty int TooltipRequest::y - \readonly - - The y coordinate of the top-left corner of the requested tooltip. -*/ - -int QQuickWebEngineTooltipRequest::y() const -{ - return m_position.y(); -} - -/*! - \qmlproperty bool TooltipRequest::text - \readonly - - The text of the tooltip. It contains an empty string when the - tooltip should be hidden. -*/ - - -QString QQuickWebEngineTooltipRequest::text() const -{ - return m_text; -} - -/*! - \qmlproperty enumeration TooltipRequest::type - \readonly - - The type of the tooltip request. - - \value TooltipRequest.Show - The tooltip should be shown. - \value TooltipRequest.Hide - The tooltip should be hidden. -*/ - -QQuickWebEngineTooltipRequest::RequestType QQuickWebEngineTooltipRequest::type() const -{ - return m_type; -} - -/*! - \qmlproperty bool TooltipRequest::accepted - - Indicates whether the tooltip request has been accepted - by the signal handler. - - If the property is \c false after any signal handlers - for WebEngineView::tooltipRequested have been executed, - a default tooltip will be shown. - To prevent this, set \c {request.accepted} to \c true. - - The default is \c false. -*/ - -bool QQuickWebEngineTooltipRequest::isAccepted() const -{ - return m_accepted; -} - -void QQuickWebEngineTooltipRequest::setAccepted(bool accepted) -{ - m_accepted = accepted; -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginedialogrequests_p.h b/src/webengine/api/qquickwebenginedialogrequests_p.h deleted file mode 100644 index 5e3f7c547..000000000 --- a/src/webengine/api/qquickwebenginedialogrequests_p.h +++ /dev/null @@ -1,298 +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 QQUICKWEBENGINDIALOGREQUESTS_H -#define QQUICKWEBENGINDIALOGREQUESTS_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 <QtWebEngine/private/qtwebengineglobal_p.h> -#include <QtCore/QUrl> -#include <QtCore/QWeakPointer> -#include <QtCore/QRect> -#include <QtGui/QColor> - -namespace QtWebEngineCore { - class AuthenticationDialogController; - class ColorChooserController; - class FilePickerController; - class JavaScriptDialogController; -} - -QT_BEGIN_NAMESPACE - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineAuthenticationDialogRequest : public QObject { - Q_OBJECT -public: - - enum AuthenticationType { - AuthenticationTypeHTTP, - AuthenticationTypeProxy - }; - - Q_ENUM(AuthenticationType) - - Q_PROPERTY(QUrl url READ url CONSTANT FINAL) - Q_PROPERTY(QString realm READ realm CONSTANT FINAL) - Q_PROPERTY(QString proxyHost READ proxyHost CONSTANT FINAL) - Q_PROPERTY(AuthenticationType type READ type CONSTANT FINAL) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL) - - ~QQuickWebEngineAuthenticationDialogRequest(); - - QUrl url() const; - QString realm() const; - QString proxyHost() const; - AuthenticationType type() const; - bool isAccepted() const; - void setAccepted(bool accepted); - -public slots: - void dialogAccept(const QString &user, const QString &password); - void dialogReject(); - -private: - QQuickWebEngineAuthenticationDialogRequest(QSharedPointer<QtWebEngineCore::AuthenticationDialogController> controller, - QObject *parent = nullptr); - QWeakPointer<QtWebEngineCore::AuthenticationDialogController> m_controller; - QUrl m_url; - QString m_realm; - AuthenticationType m_type; - QString m_host; - bool m_accepted; - friend class QQuickWebEngineViewPrivate; - Q_DISABLE_COPY(QQuickWebEngineAuthenticationDialogRequest) -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineJavaScriptDialogRequest : public QObject { - Q_OBJECT -public: - - enum DialogType { - DialogTypeAlert, - DialogTypeConfirm, - DialogTypePrompt, - DialogTypeBeforeUnload, - }; - Q_ENUM(DialogType) - - Q_PROPERTY(QString message READ message CONSTANT FINAL) - Q_PROPERTY(QString defaultText READ defaultText CONSTANT FINAL) - Q_PROPERTY(QString title READ title CONSTANT FINAL) - Q_PROPERTY(DialogType type READ type CONSTANT FINAL) - Q_PROPERTY(QUrl securityOrigin READ securityOrigin CONSTANT FINAL) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL) - - ~QQuickWebEngineJavaScriptDialogRequest(); - - QString message() const; - QString defaultText() const; - QString title() const; - DialogType type() const; - QUrl securityOrigin() const; - bool isAccepted() const; - void setAccepted(bool accepted); - -public slots: - void dialogAccept(const QString& text = QString()); - void dialogReject(); - -private: - QQuickWebEngineJavaScriptDialogRequest(QSharedPointer<QtWebEngineCore::JavaScriptDialogController> controller, - QObject *parent = nullptr); - QWeakPointer<QtWebEngineCore::JavaScriptDialogController> m_controller; - QString m_message; - QString m_defaultPrompt; - QString m_title; - DialogType m_type; - QUrl m_securityOrigin; - bool m_accepted; - friend class QQuickWebEngineViewPrivate; - Q_DISABLE_COPY(QQuickWebEngineJavaScriptDialogRequest) -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineColorDialogRequest : public QObject { - Q_OBJECT -public: - - Q_PROPERTY(QColor color READ color CONSTANT FINAL) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL) - - ~QQuickWebEngineColorDialogRequest(); - - QColor color() const; - bool isAccepted() const; - void setAccepted(bool accepted); - -public slots: - void dialogAccept(const QColor &color); - void dialogReject(); - -private: - QQuickWebEngineColorDialogRequest(QSharedPointer<QtWebEngineCore::ColorChooserController> controller, - QObject *parent = nullptr); - QWeakPointer<QtWebEngineCore::ColorChooserController> m_controller; - QColor m_color; - bool m_accepted; - friend class QQuickWebEngineViewPrivate; - Q_DISABLE_COPY(QQuickWebEngineColorDialogRequest) -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFileDialogRequest : public QObject { - Q_OBJECT -public: - - enum FileMode { - FileModeOpen, - FileModeOpenMultiple, - FileModeUploadFolder, - FileModeSave - }; - Q_ENUM(FileMode) - - Q_PROPERTY(QString defaultFileName READ defaultFileName CONSTANT FINAL) - Q_PROPERTY(QStringList acceptedMimeTypes READ acceptedMimeTypes CONSTANT FINAL) - Q_PROPERTY(FileMode mode READ mode CONSTANT FINAL) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL) - - ~QQuickWebEngineFileDialogRequest(); - - QStringList acceptedMimeTypes() const; - QString defaultFileName() const; - FileMode mode() const; - bool isAccepted() const; - void setAccepted(bool accepted); - -public slots: - void dialogAccept(const QStringList &files); - void dialogReject(); - -private: - QQuickWebEngineFileDialogRequest(QSharedPointer<QtWebEngineCore::FilePickerController> controller, - QObject *parent = nullptr); - QWeakPointer<QtWebEngineCore::FilePickerController> m_controller; - QString m_filename; - QStringList m_acceptedMimeTypes; - FileMode m_mode; - bool m_accepted; - friend class QQuickWebEngineViewPrivate; - Q_DISABLE_COPY(QQuickWebEngineFileDialogRequest) -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFormValidationMessageRequest : public QObject { - Q_OBJECT -public: - enum RequestType { - Show, - Hide, - Move, - }; - Q_ENUM(RequestType) - Q_PROPERTY(QRect anchor READ anchor CONSTANT FINAL) - Q_PROPERTY(QString text READ text CONSTANT FINAL) - Q_PROPERTY(QString subText READ subText CONSTANT FINAL) - Q_PROPERTY(RequestType type READ type CONSTANT FINAL) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL) - - ~QQuickWebEngineFormValidationMessageRequest(); - QRect anchor() const; - QString text() const; - QString subText() const; - RequestType type() const; - bool isAccepted() const; - void setAccepted(bool accepted); - -private: - QQuickWebEngineFormValidationMessageRequest(RequestType type, const QRect &anchor = QRect(), - const QString &mainText = QString(), - const QString &subText = QString(), - QObject *parent = nullptr); - QRect m_anchor; - QString m_mainText; - QString m_subText; - RequestType m_type; - bool m_accepted; - friend class QQuickWebEngineViewPrivate; -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTooltipRequest : public QObject { - Q_OBJECT -public: - enum RequestType { - Show, - Hide, - }; - Q_ENUM(RequestType) - Q_PROPERTY(int x READ x CONSTANT FINAL) - Q_PROPERTY(int y READ y CONSTANT FINAL) - Q_PROPERTY(QString text READ text CONSTANT FINAL) - Q_PROPERTY(RequestType type READ type CONSTANT FINAL) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL) - - ~QQuickWebEngineTooltipRequest(); - int x() const; - int y() const; - QString text() const; - RequestType type() const; - bool isAccepted() const; - void setAccepted(bool accepted); - -private: - QQuickWebEngineTooltipRequest(const QString &text = QString(), - QObject *parent = nullptr); - QPoint m_position; - QString m_text; - RequestType m_type; - bool m_accepted; - friend class QQuickWebEngineViewPrivate; - Q_DISABLE_COPY(QQuickWebEngineTooltipRequest) -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINDIALOGREQUESTS_H diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp deleted file mode 100644 index 767ada58f..000000000 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ /dev/null @@ -1,789 +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 "qquickwebenginedownloaditem_p.h" -#include "qquickwebenginedownloaditem_p_p.h" - -#include "profile_adapter.h" -#include "qquickwebengineprofile_p.h" - -#include <QDir> -#include "QFileInfo" - -using QtWebEngineCore::ProfileAdapterClient; - -QT_BEGIN_NAMESPACE - -ASSERT_ENUMS_MATCH(ProfileAdapterClient::NoReason, QQuickWebEngineDownloadItem::NoReason) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileFailed, QQuickWebEngineDownloadItem::FileFailed) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileAccessDenied, QQuickWebEngineDownloadItem::FileAccessDenied) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNoSpace, QQuickWebEngineDownloadItem::FileNoSpace) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNameTooLong, QQuickWebEngineDownloadItem::FileNameTooLong) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooLarge, QQuickWebEngineDownloadItem::FileTooLarge) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileVirusInfected, QQuickWebEngineDownloadItem::FileVirusInfected) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTransientError, QQuickWebEngineDownloadItem::FileTransientError) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileBlocked, QQuickWebEngineDownloadItem::FileBlocked) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileSecurityCheckFailed, QQuickWebEngineDownloadItem::FileSecurityCheckFailed) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooShort, QQuickWebEngineDownloadItem::FileTooShort) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileHashMismatch, QQuickWebEngineDownloadItem::FileHashMismatch) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkFailed, QQuickWebEngineDownloadItem::NetworkFailed) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkTimeout, QQuickWebEngineDownloadItem::NetworkTimeout) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkDisconnected, QQuickWebEngineDownloadItem::NetworkDisconnected) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkServerDown, QQuickWebEngineDownloadItem::NetworkServerDown) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkInvalidRequest, QQuickWebEngineDownloadItem::NetworkInvalidRequest) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerFailed, QQuickWebEngineDownloadItem::ServerFailed) -//ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerNoRange, QQuickWebEngineDownloadItem::ServerNoRange) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerBadContent, QQuickWebEngineDownloadItem::ServerBadContent) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnauthorized, QQuickWebEngineDownloadItem::ServerUnauthorized) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerCertProblem, QQuickWebEngineDownloadItem::ServerCertProblem) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerForbidden, QQuickWebEngineDownloadItem::ServerForbidden) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnreachable, QQuickWebEngineDownloadItem::ServerUnreachable) -ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserCanceled, QQuickWebEngineDownloadItem::UserCanceled) -//ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserShutdown, QQuickWebEngineDownloadItem::UserShutdown) -//ASSERT_ENUMS_MATCH(ProfileAdapterClient::Crash, QQuickWebEngineDownloadItem::Crash) - -static inline QQuickWebEngineDownloadItem::DownloadState toDownloadState(int state) { - switch (state) { - case ProfileAdapterClient::DownloadInProgress: - return QQuickWebEngineDownloadItem::DownloadInProgress; - case ProfileAdapterClient::DownloadCompleted: - return QQuickWebEngineDownloadItem::DownloadCompleted; - case ProfileAdapterClient::DownloadCancelled: - return QQuickWebEngineDownloadItem::DownloadCancelled; - case ProfileAdapterClient::DownloadInterrupted: - return QQuickWebEngineDownloadItem::DownloadInterrupted; - default: - Q_UNREACHABLE(); - return QQuickWebEngineDownloadItem::DownloadCancelled; - } -} - -static inline QQuickWebEngineDownloadItem::DownloadInterruptReason toDownloadInterruptReason(int reason) -{ - return static_cast<QQuickWebEngineDownloadItem::DownloadInterruptReason>(reason); -} - -QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url) - : profile(p) - , downloadId(-1) - , downloadState(QQuickWebEngineDownloadItem::DownloadCancelled) - , savePageFormat(QQuickWebEngineDownloadItem::UnknownSaveFormat) - , type(QQuickWebEngineDownloadItem::Attachment) - , interruptReason(QQuickWebEngineDownloadItem::NoReason) - , totalBytes(-1) - , receivedBytes(0) - , downloadFinished(false) - , downloadPaused(false) - , view(nullptr) - , downloadUrl(url) - , isCustomFileName(false) -{ -} - -QQuickWebEngineDownloadItemPrivate::~QQuickWebEngineDownloadItemPrivate() -{ - if (profile) - profile->d_ptr->downloadDestroyed(downloadId); -} - -/*! - \qmltype WebEngineDownloadItem - \instantiates QQuickWebEngineDownloadItem - \inqmlmodule QtWebEngine - \since QtWebEngine 1.1 - \brief Provides information about a download. - - WebEngineDownloadItem 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 - WebEngineProfile's responsibility to notify the application of new download - requests, which it does by emitting the - \l{WebEngineProfile::downloadRequested}{downloadRequested} signal together - with a newly created WebEngineDownloadItem. 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, like the \l path under which the file will be saved, - can only be changed before calling accept(). - - \section2 Object Life Cycle - - All items are guaranteed to be valid during the emission of the - \l{WebEngineProfile::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. - - \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 WebEngineProfile, WebEngineProfile::downloadRequested, - WebEngineProfile::downloadFinished -*/ - -void QQuickWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadItemInfo &info) -{ - Q_Q(QQuickWebEngineDownloadItem); - - updateState(toDownloadState(info.state)); - - if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason) { - interruptReason = toDownloadInterruptReason(info.downloadInterruptReason); - Q_EMIT q->interruptReasonChanged(); - } - - if (info.receivedBytes != receivedBytes) { - receivedBytes = info.receivedBytes; - Q_EMIT q->receivedBytesChanged(); - } - - if (info.totalBytes != totalBytes) { - totalBytes = info.totalBytes; - Q_EMIT q->totalBytesChanged(); - } - - if (info.done) - setFinished(); - - if (info.paused != downloadPaused) { - downloadPaused = info.paused; - Q_EMIT q->isPausedChanged(); - } -} - -void QQuickWebEngineDownloadItemPrivate::updateState(QQuickWebEngineDownloadItem::DownloadState newState) -{ - Q_Q(QQuickWebEngineDownloadItem); - - if (downloadState != newState) { - downloadState = newState; - Q_EMIT q->stateChanged(); - } -} - -void QQuickWebEngineDownloadItemPrivate::setFinished() -{ - Q_Q(QQuickWebEngineDownloadItem); - - if (downloadFinished) - return; - - downloadFinished = true; - Q_EMIT q->isFinishedChanged(); -} - -/*! - \qmlmethod void WebEngineDownloadItem::accept() - - Accepts the download request, which will start the download. - - If the item is in the \c DownloadRequested state, then it will transition - into the \c DownloadInProgress state and the downloading will begin. If the - item is in any other state, then nothing will happen. - - \sa state -*/ - -void QQuickWebEngineDownloadItem::accept() -{ - Q_D(QQuickWebEngineDownloadItem); - - if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) - return; - - d->updateState(QQuickWebEngineDownloadItem::DownloadInProgress); -} - -/*! - \qmlmethod void WebEngineDownloadItem::cancel() - - Cancels the download. - - If the item is in the \c DownloadInProgress state, then it will transition - into the \c DownloadCancelled state, the downloading will stop, and - partially downloaded files will be deleted from disk. - - If the item is in the \c DownloadCompleted state, then nothing will happen. - If the item is in any other state, then it will transition into the \c - DownloadCancelled state without further effect. - - \sa state -*/ - -void QQuickWebEngineDownloadItem::cancel() -{ - Q_D(QQuickWebEngineDownloadItem); - - QQuickWebEngineDownloadItem::DownloadState state = d->downloadState; - - if (state == QQuickWebEngineDownloadItem::DownloadCompleted - || state == QQuickWebEngineDownloadItem::DownloadCancelled) - return; - - d->updateState(QQuickWebEngineDownloadItem::DownloadCancelled); - d->setFinished(); - - // We directly cancel the download if the user cancels before - // it even started, so no need to notify the profile here. - if (state == QQuickWebEngineDownloadItem::DownloadInProgress) { - if (d->profile) - d->profile->d_ptr->cancelDownload(d->downloadId); - } -} - - -/*! - \qmlmethod void WebEngineDownloadItem::pause() - \since QtWebEngine 1.6 - - Pauses the download. - - Has no effect if the state is not \c DownloadInProgress. Does not change the - state. - - \sa resume, isPaused -*/ - -void QQuickWebEngineDownloadItem::pause() -{ - Q_D(QQuickWebEngineDownloadItem); - - QQuickWebEngineDownloadItem::DownloadState state = d->downloadState; - - if (state != QQuickWebEngineDownloadItem::DownloadInProgress) - return; - - if (d->profile) - d->profile->d_ptr->profileAdapter()->pauseDownload(d->downloadId); -} - -/*! - \qmlmethod void WebEngineDownloadItem::resume() - \since QtWebEngine 1.6 - - Resumes the download if it was paused or interrupted. - - Has no effect if the state is not \c DownloadInProgress or \c - DownloadInterrupted. Does not change the state. - - \sa pause, isPaused -*/ -void QQuickWebEngineDownloadItem::resume() -{ - Q_D(QQuickWebEngineDownloadItem); - - QQuickWebEngineDownloadItem::DownloadState state = d->downloadState; - - if (d->downloadFinished || (state != QQuickWebEngineDownloadItem::DownloadInProgress && state != QQuickWebEngineDownloadItem::DownloadInterrupted)) - return; - - if (d->profile) - d->profile->d_ptr->profileAdapter()->resumeDownload(d->downloadId); -} - -/*! - \qmlproperty int WebEngineDownloadItem::id - - Holds the download item's ID. -*/ - -quint32 QQuickWebEngineDownloadItem::id() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->downloadId; -} - -/*! - \qmlproperty enumeration WebEngineDownloadItem::state - - Describes the state of the download: - - \value WebEngineDownloadItem.DownloadRequested - Download has been requested, but it has not been accepted yet. - \value WebEngineDownloadItem.DownloadInProgress - Download is in progress. - \value WebEngineDownloadItem.DownloadCompleted - Download completed successfully. - \value WebEngineDownloadItem.DownloadCancelled - Download was cancelled by the user. - \value WebEngineDownloadItem.DownloadInterrupted - Download has been interrupted (by the server or because of lost connectivity). -*/ - -QQuickWebEngineDownloadItem::DownloadState QQuickWebEngineDownloadItem::state() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->downloadState; -} - -/*! - \qmlproperty int WebEngineDownloadItem::totalBytes - - Holds the total amount of data to download in bytes. - - \c -1 means the total size is unknown. -*/ - -qint64 QQuickWebEngineDownloadItem::totalBytes() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->totalBytes; -} - -/*! - \qmlproperty int WebEngineDownloadItem::receivedBytes - - Holds the amount of data in bytes that has been downloaded so far. -*/ - -qint64 QQuickWebEngineDownloadItem::receivedBytes() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->receivedBytes; -} - -/*! - \qmlproperty url WebEngineDownloadItem::url - \readonly - \since QtWebEngine 1.10 - - Returns the download's origin URL. -*/ - -QUrl QQuickWebEngineDownloadItem::url() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->downloadUrl; -} - -/*! - \qmlproperty string WebEngineDownloadItem::mimeType - \since QtWebEngine 1.2 - - Holds the MIME type of the download. -*/ - -QString QQuickWebEngineDownloadItem::mimeType() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->mimeType; -} - -/*! - \qmlproperty string WebEngineDownloadItem::path - \obsolete - - Use \l suggestedFileName, \l downloadDirectory, and - \l downloadFileName instead. - - Holds the full target path where data is being downloaded to. - - The path includes the file name. The default suggested path is the standard - download location and file name is deduced not to overwrite already existing files. - - The download path can only be set in the - \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before - the download is accepted. - - \sa WebEngineProfile::downloadRequested(), accept() -*/ - -QString QQuickWebEngineDownloadItem::path() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return QDir::cleanPath(QDir(d->downloadDirectory).filePath(d->downloadFileName)); -} - -void QQuickWebEngineDownloadItem::setPath(QString path) -{ - Q_D(QQuickWebEngineDownloadItem); - if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) { - qWarning("Setting the download path is not allowed after the download has been accepted."); - return; - } - if (QDir(d->downloadDirectory).filePath(d->downloadFileName) != path) { - if (QFileInfo(path).fileName().isEmpty()) { - qWarning("The download path does not include file name."); - return; - } - - if (QFileInfo(path).isDir()) { - qWarning("The download path matches with an already existing directory path."); - return; - } - - QString newDirectory; - QString newFileName; - - if (QFileInfo(path).fileName() == path) { - newDirectory = QStringLiteral(""); - newFileName = path; - } else { - newDirectory = QFileInfo(path).path(); - newFileName = QFileInfo(path).fileName(); - } - - if (d->downloadDirectory != newDirectory) { - d->downloadDirectory = newDirectory; - Q_EMIT pathChanged(); - Q_EMIT downloadDirectoryChanged(); - } - - if (d->downloadFileName != newFileName) { - d->downloadFileName = newFileName; - Q_EMIT pathChanged(); - Q_EMIT downloadFileNameChanged(); - } - } -} - -/*! - \qmlproperty string WebEngineDownloadItem::downloadDirectory - \since QtWebEngine 1.10 - - Holds the full target path without file name where data is being downloaded to. - - The download directory can only be set in the - \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before - the download is accepted. - - \sa WebEngineProfile::downloadRequested(), accept() -*/ - -QString QQuickWebEngineDownloadItem::downloadDirectory() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->downloadDirectory; -} - -void QQuickWebEngineDownloadItem::setDownloadDirectory(const QString &directory) -{ - Q_D(QQuickWebEngineDownloadItem); - if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) { - qWarning("Setting the download directory is not allowed after the download has been accepted."); - return; - } - - bool isPathChanged = false; - QString changeDirectory = d->downloadDirectory; - if (!directory.isEmpty() && changeDirectory != directory) { - changeDirectory = directory; - - if (d->downloadDirectory != changeDirectory) { - d->downloadDirectory = changeDirectory; - Q_EMIT downloadDirectoryChanged(); - isPathChanged = true; - } - - if (!d->isCustomFileName) { - QString newFileName = QFileInfo(d->profile->d_ptr->profileAdapter()->determineDownloadPath(d->downloadDirectory, - d->suggestedFileName, - d->startTime)).fileName(); - if (d->downloadFileName != newFileName) { - d->downloadFileName = newFileName; - Q_EMIT downloadFileNameChanged(); - isPathChanged = true; - } - } - } - - if (isPathChanged) - Q_EMIT pathChanged(); -} - -/*! - \qmlproperty string WebEngineDownloadItem::downloadFileName - \since QtWebEngine 1.10 - - Holds the name of the file to which data is being downloaded. - - The download file name can only be set in the - \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before - the download is accepted. - - \sa WebEngineProfile::downloadRequested(), accept() -*/ - -QString QQuickWebEngineDownloadItem::downloadFileName() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->downloadFileName; -} - -void QQuickWebEngineDownloadItem::setDownloadFileName(const QString &fileName) -{ - Q_D(QQuickWebEngineDownloadItem); - if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) { - qWarning("Setting the download file name is not allowed after the download has been accepted."); - return; - } - - if (d->downloadFileName != fileName && !fileName.isEmpty()) { - d->downloadFileName = fileName; - d->isCustomFileName = true; - Q_EMIT downloadFileNameChanged(); - Q_EMIT pathChanged(); - } -} - -/*! - \qmlproperty string WebEngineDownloadItem::suggestedFileName - \since QtWebEngine 1.10 - - Returns the suggested file name. -*/ - -QString QQuickWebEngineDownloadItem::suggestedFileName() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->suggestedFileName; -} - -/*! - \qmlproperty enumeration WebEngineDownloadItem::savePageFormat - \since QtWebEngine 1.3 - - Describes the format that is used to save a web page. - - \value WebEngineDownloadItem.UnknownSaveFormat - This is not a request for downloading a complete web page. - \value WebEngineDownloadItem.SingleHtmlSaveFormat - The page is saved as a single HTML page. Resources such as images - are not saved. - \value WebEngineDownloadItem.CompleteHtmlSaveFormat - The page is saved as a complete HTML page, for example a directory - containing the single HTML page and the resources. - \value WebEngineDownloadItem.MimeHtmlSaveFormat - The page is saved as a complete web page in the MIME HTML format. -*/ - -QQuickWebEngineDownloadItem::SavePageFormat QQuickWebEngineDownloadItem::savePageFormat() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->savePageFormat; -} - -void QQuickWebEngineDownloadItem::setSavePageFormat(QQuickWebEngineDownloadItem::SavePageFormat format) -{ - Q_D(QQuickWebEngineDownloadItem); - if (d->savePageFormat != format) { - d->savePageFormat = format; - Q_EMIT savePageFormatChanged(); - } -} - -/*! - \qmlproperty enumeration WebEngineDownloadItem::type - \readonly - \since QtWebEngine 1.4 - \obsolete - - Describes the requested download's type. - - \note This property works unreliably, except for \c SavePage - downloads. Use \l isSavePageDownload instead. - - \value WebEngineDownloadItem.Attachment The web server's response includes a - \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition - is present in the reply, the web server is indicating that the client should prompt the - user to save the content regardless of the content type. - See \l {RFC 2616 section 19.5.1} for details. - \value WebEngineDownloadItem.DownloadAttribute The user clicked a link with the \c download - attribute. - \value WebEngineDownloadItem.UserRequested The user initiated the download, for example by - selecting a web action. - \value WebEngineDownloadItem.SavePage Saving of the current page was requested (for example by - the \l{WebEngineView::WebAction}{WebEngineView.SavePage} web action). - -*/ - -QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->type; -} - -/*! - \qmlproperty bool WebEngineDownloadItem::isSavePageDownload - \readonly - \since QtWebEngine 1.7 - - Whether this is a download request for saving a web page or a file. - - \sa savePageFormat -*/ -bool QQuickWebEngineDownloadItem::isSavePageDownload() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->type == QQuickWebEngineDownloadItem::SavePage; -} - -/*! - \qmlproperty enumeration WebEngineDownloadItem::interruptReason - \readonly - \since QtWebEngine 1.5 - - Returns the reason why the download was interrupted: - - \value WebEngineDownloadItem.NoReason Unknown reason or not interrupted. - \value WebEngineDownloadItem.FileFailed General file operation failure. - \value WebEngineDownloadItem.FileAccessDenied The file cannot be written locally, due to access restrictions. - \value WebEngineDownloadItem.FileNoSpace Insufficient space on the target drive. - \value WebEngineDownloadItem.FileNameTooLong The directory or file name is too long. - \value WebEngineDownloadItem.FileTooLarge The file size exceeds the file system limitation. - \value WebEngineDownloadItem.FileVirusInfected The file is infected with a virus. - \value WebEngineDownloadItem.FileTransientError Temporary problem (for example the file is in use, - out of memory, or too many files are opened at once). - \value WebEngineDownloadItem.FileBlocked The file was blocked due to local policy. - \value WebEngineDownloadItem.FileSecurityCheckFailed An attempt to check the safety of the download - failed due to unexpected reasons. - \value WebEngineDownloadItem.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 WebEngineDownloadItem.FileHashMismatch The partial file did not match the expected hash. - - \value WebEngineDownloadItem.NetworkFailed General network failure. - \value WebEngineDownloadItem.NetworkTimeout The network operation has timed out. - \value WebEngineDownloadItem.NetworkDisconnected The network connection has been terminated. - \value WebEngineDownloadItem.NetworkServerDown The server has gone down. - \value WebEngineDownloadItem.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 WebEngineDownloadItem.ServerFailed General server failure. - \value WebEngineDownloadItem.ServerBadContent The server does not have the requested data. - \value WebEngineDownloadItem.ServerUnauthorized The server did not authorize access to the resource. - \value WebEngineDownloadItem.ServerCertProblem A problem with the server certificate occurred. - \value WebEngineDownloadItem.ServerForbidden Access forbidden by the server. - \value WebEngineDownloadItem.ServerUnreachable Unexpected server response (might indicate that - the responding server may not be the intended server). - \value WebEngineDownloadItem.UserCanceled The user canceled the download. - - \sa interruptReasonString -*/ - -QQuickWebEngineDownloadItem::DownloadInterruptReason QQuickWebEngineDownloadItem::interruptReason() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->interruptReason; -} - -/*! - \qmlproperty string WebEngineDownloadItem::interruptReasonString - Returns a human-readable description of the reason for interrupting the download. - \since QtWebEngine 1.5 - - \sa interruptReason -*/ -QString QQuickWebEngineDownloadItem::interruptReasonString() const -{ - return ProfileAdapterClient::downloadInterruptReasonToString( - static_cast<ProfileAdapterClient::DownloadInterruptReason>(interruptReason())); -} - -/*! - \qmlproperty bool WebEngineDownloadItem::isFinished - \readonly - \since QtWebEngine 1.6 - - Whether this download is finished (completed, cancelled, or non-resumable interrupted state). - */ - -bool QQuickWebEngineDownloadItem::isFinished() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->downloadFinished; -} - -/*! - \qmlproperty bool WebEngineDownloadItem::isPaused - \readonly - \since QtWebEngine 1.6 - - Whether this download is paused. - - \sa pause, resume - */ - -bool QQuickWebEngineDownloadItem::isPaused() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->downloadPaused; -} - -/*! - \qmlproperty WebEngineView WebEngineDownloadItem::view - \readonly - \since QtWebEngine 1.8 - - Returns the view the download was requested on. If the download was not triggered by content in a view, - \c nullptr is returned. - - \sa WebEngineView -*/ -QQuickWebEngineView *QQuickWebEngineDownloadItem::view() const -{ - Q_D(const QQuickWebEngineDownloadItem); - return d->view; -} - -QQuickWebEngineDownloadItem::QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate *p, QObject *parent) - : QObject(parent) - , d_ptr(p) -{ - p->q_ptr = this; -} - -QQuickWebEngineDownloadItem::~QQuickWebEngineDownloadItem() -{ - if (!isFinished()) - cancel(); -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h deleted file mode 100644 index e1b1b9040..000000000 --- a/src/webengine/api/qquickwebenginedownloaditem_p.h +++ /dev/null @@ -1,199 +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 QQUICKWEBENGINEDOWNLOADITEM_P_H -#define QQUICKWEBENGINEDOWNLOADITEM_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 <QtWebEngine/private/qtwebengineglobal_p.h> -#include <QObject> -#include <QScopedPointer> -#include <QString> -#include <QUrl> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineDownloadItemPrivate; -class QQuickWebEngineProfilePrivate; -class QQuickWebEngineView; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineDownloadItem: public QObject { - Q_OBJECT -public: - ~QQuickWebEngineDownloadItem(); - 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) - - Q_PROPERTY(quint32 id READ id CONSTANT FINAL) - Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged FINAL) - Q_PROPERTY(SavePageFormat savePageFormat READ savePageFormat WRITE setSavePageFormat NOTIFY savePageFormatChanged REVISION 2 FINAL) - Q_PROPERTY(qint64 totalBytes READ totalBytes NOTIFY totalBytesChanged FINAL) - Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY receivedBytesChanged FINAL) - Q_PROPERTY(QString mimeType READ mimeType NOTIFY mimeTypeChanged REVISION 1 FINAL) - Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged FINAL) - Q_PROPERTY(DownloadType type READ type NOTIFY typeChanged REVISION 3 FINAL) - Q_PROPERTY(DownloadInterruptReason interruptReason READ interruptReason NOTIFY interruptReasonChanged REVISION 4 FINAL) - Q_PROPERTY(QString interruptReasonString READ interruptReasonString NOTIFY interruptReasonChanged REVISION 4 FINAL) - Q_PROPERTY(bool isFinished READ isFinished NOTIFY isFinishedChanged REVISION 5 FINAL) - Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged REVISION 5 FINAL) - Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT REVISION 6 FINAL) - Q_PROPERTY(QQuickWebEngineView *view READ view CONSTANT REVISION 7 FINAL) - Q_PROPERTY(QUrl url READ url CONSTANT REVISION 10 FINAL) - Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT REVISION 10 FINAL) - Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged REVISION 10 FINAL) - Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged REVISION 10 FINAL) - - Q_INVOKABLE void accept(); - Q_INVOKABLE void cancel(); - Q_INVOKABLE void pause(); - Q_INVOKABLE void resume(); - - quint32 id() const; - DownloadState state() const; - qint64 totalBytes() const; - qint64 receivedBytes() const; - QString mimeType() const; - QString path() const; - void setPath(QString path); - SavePageFormat savePageFormat() const; - void setSavePageFormat(SavePageFormat format); - DownloadType Q_DECL_DEPRECATED type() const; - DownloadInterruptReason interruptReason() const; - QString interruptReasonString() const; - bool isFinished() const; - bool isPaused() const; - bool isSavePageDownload() const; - QQuickWebEngineView *view() const; - QUrl url() const; - QString suggestedFileName() const; - QString downloadDirectory() const; - void setDownloadDirectory(const QString &directory); - QString downloadFileName() const; - void setDownloadFileName(const QString &fileName); - bool isCustomFileName; - -Q_SIGNALS: - void stateChanged(); - Q_REVISION(2) void savePageFormatChanged(); - void receivedBytesChanged(); - void totalBytesChanged(); - Q_REVISION(1) void mimeTypeChanged(); - void pathChanged(); - Q_REVISION(3) void typeChanged(); - Q_REVISION(4) void interruptReasonChanged(); - Q_REVISION(5) void isFinishedChanged(); - Q_REVISION(5) void isPausedChanged(); - Q_REVISION(10) void downloadDirectoryChanged(); - Q_REVISION(10) void downloadFileNameChanged(); - -private: - QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate*, QObject *parent = 0); - Q_DISABLE_COPY(QQuickWebEngineDownloadItem) - Q_DECLARE_PRIVATE(QQuickWebEngineDownloadItem) - friend class QQuickWebEngineProfilePrivate; - - QScopedPointer<QQuickWebEngineDownloadItemPrivate> d_ptr; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEDOWNLOADITEM_P_H diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h deleted file mode 100644 index acd7fe806..000000000 --- a/src/webengine/api/qquickwebenginedownloaditem_p_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 QQUICKWEBENGINEDOWNLOADITEM_P_P_H -#define QQUICKWEBENGINEDOWNLOADITEM_P_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 "qquickwebenginedownloaditem_p.h" -#include "qquickwebengineprofile.h" -#include <QString> -#include <QPointer> - -QT_BEGIN_NAMESPACE -class QQuickWebEngineProfilePrivate; -class QQuickWebEngineView; - -class QQuickWebEngineDownloadItemPrivate { - QQuickWebEngineDownloadItem *q_ptr; - QPointer<QQuickWebEngineProfile> profile; - friend class QQuickWebEngineProfilePrivate; -public: - Q_DECLARE_PUBLIC(QQuickWebEngineDownloadItem) - QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url); - ~QQuickWebEngineDownloadItemPrivate(); - - quint32 downloadId; - qint64 startTime; - QQuickWebEngineDownloadItem::DownloadState downloadState; - QQuickWebEngineDownloadItem::SavePageFormat savePageFormat; - QQuickWebEngineDownloadItem::DownloadType type; - QQuickWebEngineDownloadItem::DownloadInterruptReason interruptReason; - qint64 totalBytes; - qint64 receivedBytes; - QString mimeType; - QString downloadPath; - bool downloadFinished; - bool downloadPaused; - QQuickWebEngineView *view; - QUrl downloadUrl; - QString suggestedFileName; - QString downloadDirectory; - QString downloadFileName; - bool isCustomFileName; - - void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info); - void updateState(QQuickWebEngineDownloadItem::DownloadState newState); - void setFinished(); -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEDOWNLOADITEM_P_P_H diff --git a/src/webengine/api/qquickwebenginefaviconprovider.cpp b/src/webengine/api/qquickwebenginefaviconprovider.cpp deleted file mode 100644 index f817e4016..000000000 --- a/src/webengine/api/qquickwebenginefaviconprovider.cpp +++ /dev/null @@ -1,210 +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 "qquickwebenginefaviconprovider_p_p.h" - -#include "favicon_manager.h" -#include "qquickwebengineview_p.h" -#include "qquickwebengineview_p_p.h" -#include "web_contents_adapter.h" - -#include <QtGui/QIcon> -#include <QtGui/QPixmap> - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -#include <QtGui/qiconengine.h> -#include <QtGui/private/qicon_p.h> -#endif - -QT_BEGIN_NAMESPACE - -using QtWebEngineCore::FaviconInfo; -using QtWebEngineCore::FaviconManager; - -static inline unsigned area(const QSize &size) -{ - return size.width() * size.height(); -} - -QString QQuickWebEngineFaviconProvider::identifier() -{ - return QStringLiteral("favicon"); -} - -QUrl QQuickWebEngineFaviconProvider::faviconProviderUrl(const QUrl &url) -{ - if (url.isEmpty()) - return url; - - QUrl providerUrl; - providerUrl.setScheme(QStringLiteral("image")); - providerUrl.setHost(identifier()); - providerUrl.setPath(QStringLiteral("/%1").arg(url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment))); - if (url.hasQuery()) - providerUrl.setQuery(url.query(QUrl::FullyDecoded)); - if (url.hasFragment()) - providerUrl.setFragment(url.fragment(QUrl::FullyDecoded)); - - return providerUrl; -} - -QQuickWebEngineFaviconProvider::QQuickWebEngineFaviconProvider() - : QQuickImageProvider(QQuickImageProvider::Pixmap) - , m_latestView(0) -{ -} - -QQuickWebEngineFaviconProvider::~QQuickWebEngineFaviconProvider() -{ - qDeleteAll(m_iconUrlMap); -} - -QUrl QQuickWebEngineFaviconProvider::attach(QQuickWebEngineView *view, const QUrl &iconUrl) -{ - if (iconUrl.isEmpty()) - return QUrl(); - - m_latestView = view; - - if (!m_iconUrlMap.contains(view)) - m_iconUrlMap.insert(view, new QList<QUrl>()); - - QList<QUrl> *iconUrls = m_iconUrlMap[view]; - if (!iconUrls->contains(iconUrl)) - iconUrls->append(iconUrl); - - return faviconProviderUrl(iconUrl); -} - -void QQuickWebEngineFaviconProvider::detach(QQuickWebEngineView *view) -{ - QList<QUrl> *iconUrls = m_iconUrlMap.take(view); - delete iconUrls; -} - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -static QPixmap getUnscaledPixmap(QIcon icon, const QSize &size) -{ - QPixmap pixmap = icon.data_ptr()->engine->pixmap(size, QIcon::Normal, QIcon::Off); - pixmap.setDevicePixelRatio(1.0); - return pixmap; -} -#else -static QPixmap getUnscaledPixmap(const QIcon &icon, const QSize &size) -{ - return icon.pixmap(size, 1.0); -} -#endif - -QPixmap QQuickWebEngineFaviconProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) -{ - Q_UNUSED(size); - Q_UNUSED(requestedSize); - - QUrl iconUrl(id); - QQuickWebEngineView *view = viewForIconUrl(iconUrl); - - if (!view || iconUrl.isEmpty()) - return QPixmap(); - - FaviconManager *faviconManager = view->d_ptr->adapter->faviconManager(); - - Q_ASSERT(faviconManager); - const FaviconInfo &faviconInfo = faviconManager->getFaviconInfo(iconUrl); - const QIcon &icon = faviconManager->getIcon(faviconInfo.candidate ? QUrl() : iconUrl); - - Q_ASSERT(!icon.isNull()); - const QSize &bestSize = faviconInfo.size; - - // If source size is not specified, use the best quality - if (!requestedSize.isValid()) { - if (size) - *size = bestSize; - - return getUnscaledPixmap(icon, bestSize).copy(); - } - - const QSize &fitSize = findFitSize(icon.availableSizes(), requestedSize, bestSize); - const QPixmap &iconPixmap = getUnscaledPixmap(icon, fitSize); - - if (size) - *size = iconPixmap.size(); - - return iconPixmap.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation).copy(); -} - -QQuickWebEngineView *QQuickWebEngineFaviconProvider::viewForIconUrl(const QUrl &iconUrl) const -{ - // The most common use case is that the requested iconUrl belongs to the - // latest WebEngineView which was raised an iconChanged signal. - if (m_latestView) { - QList<QUrl> *iconUrls = m_iconUrlMap[m_latestView]; - if (iconUrls && iconUrls->contains(iconUrl)) - return m_latestView; - } - - for (auto it = m_iconUrlMap.cbegin(), end = m_iconUrlMap.cend(); it != end; ++it) { - if (it.value()->contains(iconUrl)) - return it.key(); - } - - return 0; -} - -QSize QQuickWebEngineFaviconProvider::findFitSize(const QList<QSize> &availableSizes, - const QSize &requestedSize, - const QSize &bestSize) const -{ - Q_ASSERT(availableSizes.count()); - if (availableSizes.count() == 1 || area(requestedSize) >= area(bestSize)) - return bestSize; - - QSize fitSize = bestSize; - for (const QSize &size : availableSizes) { - if (area(size) == area(requestedSize)) - return size; - - if (area(requestedSize) < area(size) && area(size) < area(fitSize)) - fitSize = size; - } - - return fitSize; -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginefaviconprovider_p_p.h b/src/webengine/api/qquickwebenginefaviconprovider_p_p.h deleted file mode 100644 index 4ccc4ba10..000000000 --- a/src/webengine/api/qquickwebenginefaviconprovider_p_p.h +++ /dev/null @@ -1,87 +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 QQUICKWEBENGINEFAVICONPROVIDER_P_P_H -#define QQUICKWEBENGINEFAVICONPROVIDER_P_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 <QtWebEngine/private/qtwebengineglobal_p.h> -#include <QtQuick/QQuickImageProvider> - -#include <QtCore/QMap> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineView; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFaviconProvider : public QQuickImageProvider { -public: - static QString identifier(); - static QUrl faviconProviderUrl(const QUrl &); - - QQuickWebEngineFaviconProvider(); - ~QQuickWebEngineFaviconProvider(); - - QUrl attach(QQuickWebEngineView *, const QUrl &); - void detach(QQuickWebEngineView *); - - - QPixmap requestPixmap(const QString &, QSize *, const QSize &) override; - -private: - QQuickWebEngineView *viewForIconUrl(const QUrl &) const; - QSize findFitSize(const QList<QSize> &, const QSize &, const QSize &) const; - - QMap<QQuickWebEngineView *, QList<QUrl> *> m_iconUrlMap; - QQuickWebEngineView *m_latestView; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEFAVICONPROVIDER_P_P_H diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webengine/api/qquickwebenginehistory.cpp deleted file mode 100644 index e77974a0f..000000000 --- a/src/webengine/api/qquickwebenginehistory.cpp +++ /dev/null @@ -1,356 +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 "qquickwebenginehistory_p.h" -#include "qquickwebenginehistory_p_p.h" - -#include "qquickwebenginefaviconprovider_p_p.h" -#include "qquickwebengineloadrequest_p.h" -#include "qquickwebengineview_p_p.h" -#include "web_contents_adapter.h" - -QT_BEGIN_NAMESPACE - -QQuickWebEngineHistoryListModelPrivate::QQuickWebEngineHistoryListModelPrivate(QQuickWebEngineViewPrivate *view) - : view(view) -{ -} - -QQuickWebEngineHistoryListModelPrivate::~QQuickWebEngineHistoryListModelPrivate() -{ -} - -int QQuickWebEngineHistoryListModelPrivate::count() const -{ - return adapter()->navigationEntryCount(); -} - -int QQuickWebEngineHistoryListModelPrivate::index(int index) const -{ - return index; -} - -int QQuickWebEngineHistoryListModelPrivate::offsetForIndex(int index) const -{ - return index - adapter()->currentNavigationEntryIndex(); -} - -QtWebEngineCore::WebContentsAdapter *QQuickWebEngineHistoryListModelPrivate::adapter() const -{ - return view->adapter.data(); -} - -QQuickWebEngineBackHistoryListModelPrivate::QQuickWebEngineBackHistoryListModelPrivate(QQuickWebEngineViewPrivate *view) - : QQuickWebEngineHistoryListModelPrivate(view) -{ -} - -int QQuickWebEngineBackHistoryListModelPrivate::count() const -{ - return adapter()->currentNavigationEntryIndex(); -} - -int QQuickWebEngineBackHistoryListModelPrivate::index(int i) const -{ - Q_ASSERT(i >= 0 && i < count()); - return count() - 1 - i; -} - -int QQuickWebEngineBackHistoryListModelPrivate::offsetForIndex(int index) const -{ - return - index - 1; -} - -QQuickWebEngineForwardHistoryListModelPrivate::QQuickWebEngineForwardHistoryListModelPrivate(QQuickWebEngineViewPrivate *view) - : QQuickWebEngineHistoryListModelPrivate(view) -{ -} - -int QQuickWebEngineForwardHistoryListModelPrivate::count() const -{ - if (!adapter()->isInitialized()) - return 0; - return adapter()->navigationEntryCount() - adapter()->currentNavigationEntryIndex() - 1; -} - -int QQuickWebEngineForwardHistoryListModelPrivate::index(int i) const -{ - return adapter()->currentNavigationEntryIndex() + i + 1; -} - -int QQuickWebEngineForwardHistoryListModelPrivate::offsetForIndex(int index) const -{ - return index + 1; -} - -/*! - \qmltype WebEngineHistoryListModel - \instantiates QQuickWebEngineHistoryListModel - \inqmlmodule QtWebEngine - \since QtWebEngine 1.1 - - \brief A data model that represents the history of a web engine page. - - The WebEngineHistoryListModel type exposes the \e title, \e url, \e icon, and \e offset roles. - The \e title, \e url and \e icon specify the title, URL, and favicon of the visited page. - The \e offset specifies - the position of the page in respect to the current page (0). A positive number indicates that - the page was visited after the current page, whereas a negative number indicates that the page - was visited before the current page. - - This type is uncreatable, but it can be accessed by using the - \l{WebEngineView::navigationHistory}{WebEngineView.navigationHistory} property. - - \sa WebEngineHistory -*/ - -QQuickWebEngineHistoryListModel::QQuickWebEngineHistoryListModel() - : QAbstractListModel() -{ -} - -QQuickWebEngineHistoryListModel::QQuickWebEngineHistoryListModel(QQuickWebEngineHistoryListModelPrivate *d) - : QAbstractListModel() - , d_ptr(d) -{ -} - -QQuickWebEngineHistoryListModel::~QQuickWebEngineHistoryListModel() -{ -} - -QHash<int, QByteArray> QQuickWebEngineHistoryListModel::roleNames() const -{ - QHash<int, QByteArray> roles; - roles[QQuickWebEngineHistory::UrlRole] = "url"; - roles[QQuickWebEngineHistory::TitleRole] = "title"; - roles[QQuickWebEngineHistory::OffsetRole] = "offset"; - roles[QQuickWebEngineHistory::IconUrlRole] = "icon"; - return roles; -} - -int QQuickWebEngineHistoryListModel::rowCount(const QModelIndex &index) const -{ - Q_UNUSED(index); - Q_D(const QQuickWebEngineHistoryListModel); - return d->count(); -} - -QVariant QQuickWebEngineHistoryListModel::data(const QModelIndex &index, int role) const -{ - Q_D(const QQuickWebEngineHistoryListModel); - - if (!index.isValid()) - return QVariant(); - - if (role < QQuickWebEngineHistory::UrlRole || role > QQuickWebEngineHistory::IconUrlRole) - return QVariant(); - - if (role == QQuickWebEngineHistory::UrlRole) - return QUrl(d->adapter()->getNavigationEntryUrl(d->index(index.row()))); - - if (role == QQuickWebEngineHistory::TitleRole) - return QString(d->adapter()->getNavigationEntryTitle(d->index(index.row()))); - - if (role == QQuickWebEngineHistory::OffsetRole) - return d->offsetForIndex(index.row()); - - if (role == QQuickWebEngineHistory::IconUrlRole) { - QUrl iconUrl = QUrl(d->adapter()->getNavigationEntryIconUrl(d->index(index.row()))); - return QQuickWebEngineFaviconProvider::faviconProviderUrl(iconUrl); - } - - return QVariant(); -} - -void QQuickWebEngineHistoryListModel::reset() -{ - beginResetModel(); - endResetModel(); -} - -QQuickWebEngineHistoryPrivate::QQuickWebEngineHistoryPrivate(QQuickWebEngineViewPrivate *view) - : m_view(view) -{ -} - -QQuickWebEngineHistoryPrivate::~QQuickWebEngineHistoryPrivate() -{ -} - -/*! - \qmltype WebEngineHistory - \instantiates QQuickWebEngineHistory - \inqmlmodule QtWebEngine - \since QtWebEngine 1.1 - - \brief Provides data models that represent the history of a web engine page. - - The WebEngineHistory type can be accessed by using the - \l{WebEngineView::navigationHistory}{WebEngineView.navigationHistory} property. - - The WebEngineHistory type provides the following WebEngineHistoryListModel data model objects: - - \list - \li \c backItems, which contains the URLs of visited pages. - \li \c forwardItems, which contains the URLs of the pages that were visited after visiting - the current page. - \li \c items, which contains the URLs of the back and forward items, as well as the URL of - the current page. - \endlist - - The easiest way to use these models is to use them in a ListView as illustrated by the - following code snippet: - - \code - ListView { - id: historyItemsList - anchors.fill: parent - model: webEngineView.navigationHistory.items - delegate: - Text { - color: "black" - text: model.title + " - " + model.url + " (" + model.offset + ")" - } - } - \endcode - - The ListView shows the content of the corresponding model. The delegate is responsible for the - format of the list items. The appearance of each item of the list in the delegate can be defined - separately (it is not web engine specific). - - The model roles \e title, \e url, and \e icon specify the title, URL, and favicon of the - visited page. The \e offset - role specifies the position of the page in respect to the current page (0). A positive number - indicates that the page was visited after the current page, whereas a negative number indicates - that the page was visited before the current page. - - The data models can also be used to create a menu, as illustrated by the following code - snippet: - - \quotefromfile webengine/quicknanobrowser/BrowserWindow.qml - \skipto ToolBar - \printuntil onObjectRemoved - \printuntil } - \printuntil } - \printuntil } - - For the complete example, see \l{WebEngine Quick Nano Browser}. - - \sa WebEngineHistoryListModel -*/ - -QQuickWebEngineHistory::QQuickWebEngineHistory(QQuickWebEngineViewPrivate *view) - : d_ptr(new QQuickWebEngineHistoryPrivate(view)) -{ -} - -QQuickWebEngineHistory::~QQuickWebEngineHistory() -{ -} - -/*! - \qmlproperty WebEngineHistoryListModel WebEngineHistory::items - \readonly - - URLs of back items, forward items, and the current item in the history. -*/ -QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::items() const -{ - Q_D(const QQuickWebEngineHistory); - if (!d->m_navigationModel) - d->m_navigationModel.reset(new QQuickWebEngineHistoryListModel(new QQuickWebEngineHistoryListModelPrivate(d->m_view))); - return d->m_navigationModel.data(); -} - -/*! - \qmlproperty WebEngineHistoryListModel WebEngineHistory::backItems - \readonly - - URLs of visited pages. -*/ -QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::backItems() const -{ - Q_D(const QQuickWebEngineHistory); - if (!d->m_backNavigationModel) - d->m_backNavigationModel.reset(new QQuickWebEngineHistoryListModel(new QQuickWebEngineBackHistoryListModelPrivate(d->m_view))); - return d->m_backNavigationModel.data(); -} - -/*! - \qmlproperty WebEngineHistoryListModel WebEngineHistory::forwardItems - \readonly - - URLs of the pages that were visited after visiting the current page. -*/ -QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::forwardItems() const -{ - Q_D(const QQuickWebEngineHistory); - if (!d->m_forwardNavigationModel) - d->m_forwardNavigationModel.reset(new QQuickWebEngineHistoryListModel(new QQuickWebEngineForwardHistoryListModelPrivate(d->m_view))); - return d->m_forwardNavigationModel.data(); -} - -/*! - \qmlmethod void WebEngineHistory::clear() - \since QtWebEngine 1.11 - - Clears the history. -*/ -void QQuickWebEngineHistory::clear() -{ - Q_D(QQuickWebEngineHistory); - d->m_view->adapter->clearNavigationHistory(); - d->m_view->updateNavigationActions(); - reset(); -} - -void QQuickWebEngineHistory::reset() -{ - Q_D(QQuickWebEngineHistory); - if (d->m_navigationModel) - d->m_navigationModel->reset(); - if (d->m_backNavigationModel) - d->m_backNavigationModel->reset(); - if (d->m_forwardNavigationModel) - d->m_forwardNavigationModel->reset(); -} - - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginehistory_p.h b/src/webengine/api/qquickwebenginehistory_p.h deleted file mode 100644 index db0be3bad..000000000 --- a/src/webengine/api/qquickwebenginehistory_p.h +++ /dev/null @@ -1,125 +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 QQUICKWEBENGINEHISTORY_P_H -#define QQUICKWEBENGINEHISTORY_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 <QtWebEngine/qtwebengineglobal.h> -#include <QAbstractListModel> -#include <QtCore/qshareddata.h> -#include <QQuickItem> -#include <QUrl> -#include <QVariant> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineHistory; -class QQuickWebEngineHistoryPrivate; -class QQuickWebEngineHistoryListModelPrivate; -class QQuickWebEngineLoadRequest; -class QQuickWebEngineViewPrivate; - -class Q_WEBENGINE_EXPORT QQuickWebEngineHistoryListModel : public QAbstractListModel { - Q_OBJECT - -public: - QQuickWebEngineHistoryListModel(QQuickWebEngineHistoryListModelPrivate*); - virtual ~QQuickWebEngineHistoryListModel(); - - int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex& index, int role) const override; - QHash<int, QByteArray> roleNames() const override; - void reset(); - -private: - QQuickWebEngineHistoryListModel(); - - Q_DECLARE_PRIVATE(QQuickWebEngineHistoryListModel) - QScopedPointer<QQuickWebEngineHistoryListModelPrivate> d_ptr; - - friend class QQuickWebEngineHistory; -}; - -class Q_WEBENGINE_EXPORT QQuickWebEngineHistory : public QQuickItem { - Q_OBJECT - Q_PROPERTY(QQuickWebEngineHistoryListModel *items READ items CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineHistoryListModel *backItems READ backItems CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineHistoryListModel *forwardItems READ forwardItems CONSTANT FINAL) - -public: - QQuickWebEngineHistory(QQuickWebEngineViewPrivate*); - virtual ~QQuickWebEngineHistory(); - - enum NavigationHistoryRoles { - UrlRole = Qt::UserRole + 1, - TitleRole = Qt::UserRole + 2, - OffsetRole = Qt::UserRole + 3, - IconUrlRole = Qt::UserRole + 4, - }; - - QQuickWebEngineHistoryListModel *items() const; - QQuickWebEngineHistoryListModel *backItems() const; - QQuickWebEngineHistoryListModel *forwardItems() const; - Q_REVISION(1) Q_INVOKABLE void clear(); - - void reset(); - -private: - QQuickWebEngineHistory(); - - Q_DECLARE_PRIVATE(QQuickWebEngineHistory) - QScopedPointer<QQuickWebEngineHistoryPrivate> d_ptr; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickWebEngineHistory) - -#endif // QQUICKWEBENGINEHISTORY_P_H diff --git a/src/webengine/api/qquickwebenginehistory_p_p.h b/src/webengine/api/qquickwebenginehistory_p_p.h deleted file mode 100644 index 019c6f0ad..000000000 --- a/src/webengine/api/qquickwebenginehistory_p_p.h +++ /dev/null @@ -1,107 +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 QQUICKWEBENGINEHISTORY_P_P_H -#define QQUICKWEBENGINEHISTORY_P_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. -// - -namespace QtWebEngineCore { -class WebContentsAdapter; -} - -QT_BEGIN_NAMESPACE -class QQuickWebEngineHistoryListModel; -class QQuickWebEngineViewPrivate; - -class QQuickWebEngineHistoryListModelPrivate { -public: - QQuickWebEngineHistoryListModelPrivate(QQuickWebEngineViewPrivate*); - virtual ~QQuickWebEngineHistoryListModelPrivate(); - - virtual int count() const; - virtual int index(int) const; - virtual int offsetForIndex(int) const; - - QtWebEngineCore::WebContentsAdapter *adapter() const; - - QQuickWebEngineViewPrivate *view; -}; - -class QQuickWebEngineBackHistoryListModelPrivate : public QQuickWebEngineHistoryListModelPrivate { -public: - QQuickWebEngineBackHistoryListModelPrivate(QQuickWebEngineViewPrivate*); - - int count() const override; - int index(int) const override; - int offsetForIndex(int) const override; -}; - -class QQuickWebEngineForwardHistoryListModelPrivate : public QQuickWebEngineHistoryListModelPrivate { -public: - QQuickWebEngineForwardHistoryListModelPrivate(QQuickWebEngineViewPrivate*); - - int count() const override; - int index(int) const override; - int offsetForIndex(int) const override; -}; - -class QQuickWebEngineHistoryPrivate { -public: - QQuickWebEngineHistoryPrivate(QQuickWebEngineViewPrivate*); - ~QQuickWebEngineHistoryPrivate(); - - QQuickWebEngineViewPrivate *m_view; - mutable QScopedPointer<QQuickWebEngineHistoryListModel> m_navigationModel; - mutable QScopedPointer<QQuickWebEngineHistoryListModel> m_backNavigationModel; - mutable QScopedPointer<QQuickWebEngineHistoryListModel> m_forwardNavigationModel; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEHISTORY_P_P_H diff --git a/src/webengine/api/qquickwebengineloadrequest.cpp b/src/webengine/api/qquickwebengineloadrequest.cpp deleted file mode 100644 index 5ad99ea2e..000000000 --- a/src/webengine/api/qquickwebengineloadrequest.cpp +++ /dev/null @@ -1,159 +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 <qquickwebengineloadrequest_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineLoadRequestPrivate { -public: - QQuickWebEngineLoadRequestPrivate(const QUrl& url, QQuickWebEngineView::LoadStatus status, const QString& errorString, int errorCode, QQuickWebEngineView::ErrorDomain errorDomain) - : url(url) - , status(status) - , errorString(errorString) - , errorCode(errorCode) - , errorDomain(errorDomain) - { - } - - QUrl url; - QQuickWebEngineView::LoadStatus status; - QString errorString; - int errorCode; - QQuickWebEngineView::ErrorDomain errorDomain; -}; - -/*! - \qmltype WebEngineLoadRequest - \instantiates QQuickWebEngineLoadRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.0 - - \brief A utility type for the WebEngineView::loadingChanged signal. - - Contains information about a request for loading a web page, such as the URL and - current loading status (started, succeeded, failed). - - \sa WebEngineView::loadingChanged -*/ -QQuickWebEngineLoadRequest::QQuickWebEngineLoadRequest(const QUrl& url, QQuickWebEngineView::LoadStatus status, const QString& errorString, int errorCode, QQuickWebEngineView::ErrorDomain errorDomain, QObject* parent) - : QObject(parent) - , d_ptr(new QQuickWebEngineLoadRequestPrivate(url, status, errorString, errorCode, errorDomain)) -{ -} - -QQuickWebEngineLoadRequest::~QQuickWebEngineLoadRequest() -{ -} - -/*! - \qmlproperty url WebEngineLoadRequest::url - \brief Holds the URL of the load request. - */ -QUrl QQuickWebEngineLoadRequest::url() const -{ - Q_D(const QQuickWebEngineLoadRequest); - return d->url; -} - -/*! - \qmlproperty enumeration WebEngineLoadRequest::status - - This enumeration represents the load status of a web page load request: - - \value WebEngineLoadRequest.LoadStartedStatus Page is currently loading. - \value WebEngineLoadRequest.LoadSucceededStatus - Page has been loaded with success. - \value WebEngineLoadRequest.LoadFailedStatus Page could not be loaded. - - \sa WebEngineView::loadingChanged -*/ -QQuickWebEngineView::LoadStatus QQuickWebEngineLoadRequest::status() const -{ - Q_D(const QQuickWebEngineLoadRequest); - return d->status; -} - -/*! - \qmlproperty string WebEngineLoadRequest::errorString - \brief Holds the error message. -*/ -QString QQuickWebEngineLoadRequest::errorString() const -{ - Q_D(const QQuickWebEngineLoadRequest); - return d->errorString; -} - -/*! - \qmlproperty enumeration WebEngineLoadRequest::errorDomain - This enumeration holds the type of a load request error: - - \value WebEngineView.NoErrorDomain - Error type is not known. - \value WebEngineView.InternalErrorDomain - Content cannot be interpreted by \QWE. - \value WebEngineView.ConnectionErrorDomain - Error results from a faulty network connection. - \value WebEngineView.CertificateErrorDomain - Error is related to the SSL/TLS certificate. - \value WebEngineView.HttpErrorDomain - Error is related to the HTTP connection. - \value WebEngineView.FtpErrorDomain - Error is related to the FTP connection. - \value WebEngineView.DnsErrorDomain - Error is related to the DNS connection. -*/ - -QQuickWebEngineView::ErrorDomain QQuickWebEngineLoadRequest::errorDomain() const -{ - Q_D(const QQuickWebEngineLoadRequest); - return d->errorDomain; -} - -/*! - \qmlproperty int WebEngineLoadRequest::errorCode - \brief Holds the error code. -*/ -int QQuickWebEngineLoadRequest::errorCode() const -{ - Q_D(const QQuickWebEngineLoadRequest); - return d->errorCode; -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebengineloadrequest_p.h b/src/webengine/api/qquickwebengineloadrequest_p.h deleted file mode 100644 index 6d8dd8061..000000000 --- a/src/webengine/api/qquickwebengineloadrequest_p.h +++ /dev/null @@ -1,87 +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 QQUICKWEBENGINELOADREQUEST_P_H -#define QQUICKWEBENGINELOADREQUEST_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 <QtWebEngine/private/qtwebengineglobal_p.h> -#include "qquickwebengineview_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineLoadRequestPrivate; - -class Q_WEBENGINE_EXPORT QQuickWebEngineLoadRequest : public QObject { - Q_OBJECT - Q_PROPERTY(QUrl url READ url CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineView::LoadStatus status READ status CONSTANT FINAL) - Q_PROPERTY(QString errorString READ errorString CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineView::ErrorDomain errorDomain READ errorDomain CONSTANT FINAL) - Q_PROPERTY(int errorCode READ errorCode CONSTANT FINAL) - -public: - QQuickWebEngineLoadRequest(const QUrl& url, QQuickWebEngineView::LoadStatus status, const QString& errorString = QString(), int errorCode = 0, QQuickWebEngineView::ErrorDomain errorDomain = QQuickWebEngineView::NoErrorDomain, QObject* parent = 0); - ~QQuickWebEngineLoadRequest(); - QUrl url() const; - QQuickWebEngineView::LoadStatus status() const; - QString errorString() const; - QQuickWebEngineView::ErrorDomain errorDomain() const; - int errorCode() const; - -private: - Q_DECLARE_PRIVATE(QQuickWebEngineLoadRequest) - QScopedPointer<QQuickWebEngineLoadRequestPrivate> d_ptr; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickWebEngineLoadRequest) - -#endif // QQUICKWEBENGINELOADREQUEST_P_H diff --git a/src/webengine/api/qquickwebenginenavigationrequest.cpp b/src/webengine/api/qquickwebenginenavigationrequest.cpp deleted file mode 100644 index 03c1d3d78..000000000 --- a/src/webengine/api/qquickwebenginenavigationrequest.cpp +++ /dev/null @@ -1,171 +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 "qquickwebenginenavigationrequest_p.h" - -#include "qquickwebengineview_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineNavigationRequestPrivate { -public: - QQuickWebEngineNavigationRequestPrivate(const QUrl& url, QQuickWebEngineView::NavigationType navigationType, bool mainFrame) - : url(url) - , action(QQuickWebEngineView::AcceptRequest) - , navigationType(navigationType) - , isMainFrame(mainFrame) - { - } - - ~QQuickWebEngineNavigationRequestPrivate() - { - } - - QUrl url; - QQuickWebEngineView::NavigationRequestAction action; - QQuickWebEngineView::NavigationType navigationType; - bool isMainFrame; -}; - -/*! - \qmltype WebEngineNavigationRequest - \instantiates QQuickWebEngineNavigationRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.0 - - \brief Represents a request for navigating to a web page as part of - \l{WebEngineView::navigationRequested()}. - - To accept or reject a request, set \l action to - \c WebEngineNavigationRequest.AcceptRequest or - \c WebEngineNavigationRequest.IgnoreRequest. -*/ - -QQuickWebEngineNavigationRequest::QQuickWebEngineNavigationRequest(const QUrl& url, QQuickWebEngineView::NavigationType navigationType, bool mainFrame, QObject* parent) - : QObject(parent) - , d_ptr(new QQuickWebEngineNavigationRequestPrivate(url, navigationType, mainFrame)) -{ -} - -QQuickWebEngineNavigationRequest::~QQuickWebEngineNavigationRequest() -{ -} - -/*! - \qmlproperty enumeration WebEngineNavigationRequest::action - - Whether to accept or ignore the navigation request. - - \value WebEngineNavigationRequest.AcceptRequest - Accepts a navigation request. - \value WebEngineNavigationRequest.IgnoreRequest - Ignores a navigation request. -*/ - -void QQuickWebEngineNavigationRequest::setAction(QQuickWebEngineView::NavigationRequestAction action) -{ - Q_D(QQuickWebEngineNavigationRequest); - if (d->action == action) - return; - - d->action = action; - emit actionChanged(); -} - -/*! - \qmlproperty url WebEngineNavigationRequest::url - \readonly - - The URL of the web page to go to. -*/ - -QUrl QQuickWebEngineNavigationRequest::url() const -{ - Q_D(const QQuickWebEngineNavigationRequest); - return d->url; -} - -QQuickWebEngineView::NavigationRequestAction QQuickWebEngineNavigationRequest::action() const -{ - Q_D(const QQuickWebEngineNavigationRequest); - return d->action; -} - -/*! - \qmlproperty enumeration WebEngineNavigationRequest::navigationType - \readonly - - The method used to navigate to a web page. - - \value WebEngineNavigationRequest.LinkClickedNavigation - Clicking a link. - \value WebEngineNavigationRequest.TypedNavigation - Entering an URL on the address bar. - \value WebEngineNavigationRequest.FormSubmittedNavigation - Submitting a form. - \value WebEngineNavigationRequest.BackForwardNavigation - Using navigation history to go to the previous or next page. - \value WebEngineNavigationRequest.ReloadNavigation - Reloading the page. - \value WebEngineNavigationRequest.RedirectNavigation - Page content or server triggered a redirection or page refresh. - \value WebEngineNavigationRequest.OtherNavigation - Using some other method to go to a page. -*/ - -QQuickWebEngineView::NavigationType QQuickWebEngineNavigationRequest::navigationType() const -{ - Q_D(const QQuickWebEngineNavigationRequest); - return d->navigationType; -} - -/*! - \qmlproperty bool WebEngineNavigationRequest::isMainFrame - \readonly - - Whether the navigation issue is requested for a top level page. -*/ - -bool QQuickWebEngineNavigationRequest::isMainFrame() const -{ - Q_D(const QQuickWebEngineNavigationRequest); - return d->isMainFrame; -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginenavigationrequest_p.h b/src/webengine/api/qquickwebenginenavigationrequest_p.h deleted file mode 100644 index 55e3ca673..000000000 --- a/src/webengine/api/qquickwebenginenavigationrequest_p.h +++ /dev/null @@ -1,93 +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 QQUICKWEBENGINENAVIGATIONREQUEST_P_H -#define QQUICKWEBENGINENAVIGATIONREQUEST_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 "qquickwebengineview_p.h" - -#include <QtCore/QObject> -#include <QtCore/QUrl> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineNavigationRequestPrivate; - -class Q_WEBENGINE_EXPORT QQuickWebEngineNavigationRequest : public QObject { - Q_OBJECT - Q_PROPERTY(QUrl url READ url CONSTANT FINAL) - Q_PROPERTY(bool isMainFrame READ isMainFrame CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineView::NavigationRequestAction action READ action WRITE setAction NOTIFY actionChanged FINAL) - Q_PROPERTY(QQuickWebEngineView::NavigationType navigationType READ navigationType CONSTANT FINAL) - -public: - QQuickWebEngineNavigationRequest(const QUrl& url, QQuickWebEngineView::NavigationType navigationType, bool mainFrame, QObject* parent = 0); - ~QQuickWebEngineNavigationRequest(); - - QUrl url() const; - bool isMainFrame() const; - QQuickWebEngineView::NavigationRequestAction action() const; - - void setAction(QQuickWebEngineView::NavigationRequestAction action); - QQuickWebEngineView::NavigationType navigationType() const; - -Q_SIGNALS: - void actionChanged(); - -private: - Q_DECLARE_PRIVATE(QQuickWebEngineNavigationRequest) - QScopedPointer<QQuickWebEngineNavigationRequestPrivate> d_ptr; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickWebEngineNavigationRequest) - -#endif // QQUICKWEBENGINENAVIGATIONREQUEST_P_H diff --git a/src/webengine/api/qquickwebenginenewviewrequest.cpp b/src/webengine/api/qquickwebenginenewviewrequest.cpp deleted file mode 100644 index 78ae1622a..000000000 --- a/src/webengine/api/qquickwebenginenewviewrequest.cpp +++ /dev/null @@ -1,122 +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 "qquickwebenginenewviewrequest_p.h" - -#include "qquickwebengineview_p_p.h" -#include "web_contents_adapter.h" - -/*! - \qmltype WebEngineNewViewRequest - \instantiates QQuickWebEngineNewViewRequest - \inqmlmodule QtWebEngine - \since QtWebEngine 1.1 - - \brief A utility type for the WebEngineView::newViewRequested signal. - - Contains information about a request to load a page in a separate web engine view. - - \sa WebEngineView::newViewRequested -*/ -QQuickWebEngineNewViewRequest::QQuickWebEngineNewViewRequest() -{ -} - -QQuickWebEngineNewViewRequest::~QQuickWebEngineNewViewRequest() -{ -} - -/*! - \qmlproperty WebEngineView::NewViewDestination WebEngineNewViewRequest::destination - The type of the view that is requested by the page. - */ -QQuickWebEngineView::NewViewDestination QQuickWebEngineNewViewRequest::destination() const -{ - return m_destination; -} - -/*! - \qmlproperty QUrl WebEngineNewViewRequest::requestedUrl - The URL that is requested by the page. - \since QtWebEngine 1.5 - */ -QUrl QQuickWebEngineNewViewRequest::requestedUrl() const -{ - return m_requestedUrl; -} - -/*! - \qmlproperty bool WebEngineNewViewRequest::userInitiated - Whether this window request was directly triggered as the result of a keyboard or mouse event. - - Use this property to block possibly unwanted \e popups. - */ -bool QQuickWebEngineNewViewRequest::isUserInitiated() const -{ - return m_isUserInitiated; -} - -/*! - \qmlmethod WebEngineNewViewRequest::openIn(WebEngineView view) - - Opens the requested page in the new web engine view \a view. State and history of the - view and the page possibly loaded in it will be lost. - - \sa WebEngineView::newViewRequested - */ -void QQuickWebEngineNewViewRequest::openIn(QQuickWebEngineView *view) -{ - if (!m_adapter && !m_requestedUrl.isValid()) { - qWarning("Trying to open an empty request, it was either already used or was invalidated." - "\nYou must complete the request synchronously within the newViewRequested signal handler." - " If a view hasn't been adopted before returning, the request will be invalidated."); - return; - } - - if (!view) { - qWarning("Trying to open a WebEngineNewViewRequest in an invalid WebEngineView."); - return; - } - if (m_adapter) - view->d_func()->adoptWebContents(m_adapter.data()); - else - view->setUrl(m_requestedUrl); - m_isRequestHandled = true; - m_adapter.reset(); -} diff --git a/src/webengine/api/qquickwebenginenewviewrequest_p.h b/src/webengine/api/qquickwebenginenewviewrequest_p.h deleted file mode 100644 index d4686b291..000000000 --- a/src/webengine/api/qquickwebenginenewviewrequest_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 QQUICKWEBENGINENEWVIEWREQUEST_P_H -#define QQUICKWEBENGINENEWVIEWREQUEST_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 <QtWebEngine/private/qtwebengineglobal_p.h> -#include "qquickwebengineview_p.h" - -namespace QtWebEngineCore { -class WebContentsAdapter; -} - -QT_BEGIN_NAMESPACE - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineNewViewRequest : public QObject { - Q_OBJECT - Q_PROPERTY(QQuickWebEngineView::NewViewDestination destination READ destination CONSTANT FINAL) - Q_PROPERTY(QUrl requestedUrl READ requestedUrl CONSTANT REVISION 1 FINAL) - Q_PROPERTY(bool userInitiated READ isUserInitiated CONSTANT FINAL) -public: - ~QQuickWebEngineNewViewRequest(); - - QQuickWebEngineView::NewViewDestination destination() const; - QUrl requestedUrl() const; - bool isUserInitiated() const; - Q_INVOKABLE void openIn(QQuickWebEngineView *view); - -private: - QQuickWebEngineNewViewRequest(); - QQuickWebEngineView::NewViewDestination m_destination; - bool m_isUserInitiated; - bool m_isRequestHandled = false; - QSharedPointer<QtWebEngineCore::WebContentsAdapter> m_adapter; - QUrl m_requestedUrl; - friend class QQuickWebEngineView; - friend class QQuickWebEngineViewPrivate; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickWebEngineNewViewRequest) - -#endif // QQUICKWEBENGINENEWVIEWREQUEST_P_H diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp deleted file mode 100644 index 834bb6a05..000000000 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ /dev/null @@ -1,1106 +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 "qquickwebengineprofile.h" - -#include "qquickwebenginedownloaditem_p.h" -#include "qquickwebenginedownloaditem_p_p.h" -#include "qquickwebengineprofile_p.h" -#include "qquickwebenginescript_p.h" -#include "qquickwebenginesettings_p.h" -#include "qquickwebengineview_p_p.h" -#include "qwebenginecookiestore.h" -#include "qwebenginenotification.h" - -#include <QFileInfo> -#include <QDir> -#include <QQmlEngine> - -#include "profile_adapter.h" -#include "renderer_host/user_resource_controller_host.h" -#include "web_engine_settings.h" - -#include <QtWebEngineCore/qwebengineurlscheme.h> - -using QtWebEngineCore::ProfileAdapter; - -QT_BEGIN_NAMESPACE - -ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::ProfileAdapterClient::UnknownSavePageFormat) -ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::SingleHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::SingleHtmlSaveFormat) -ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::CompleteHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::CompleteHtmlSaveFormat) -ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::MimeHtmlSaveFormat) - -/*! - \class QQuickWebEngineProfile - \brief The QQuickWebEngineProfile class provides a web engine profile shared by multiple pages. - \since 5.6 - - \inmodule QtWebEngine - - 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. - - Information about visited links is stored together with persistent cookies - and other persistent data in a storage determined by the storageName - property. Persistent data is stored in a subdirectory determined by the - persistentStoragePath property and the cache in a subdirectory determined by - the cachePath property. The httpCacheType property describes the type of the - cache: \e in-memory or \e on-disk. If only the storageName property is set, - the other values are generated automatically based on it. If you specify - any of the values manually, you should do it before creating any pages that - belong to the profile. - - 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. An off-the-record profile forces - cookies, the HTTP cache, and other normally persistent data to be stored only in memory. The - offTheRecord property holds 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. - - A WebEngineProfile instance can be created and accessed from C++ through the - QQuickWebEngineProfile class, which exposes further functionality in C++. This allows Qt Quick - applications to intercept URL requests (QQuickWebEngineProfile::setRequestInterceptor), or - register custom URL schemes (QQuickWebEngineProfile::installUrlSchemeHandler). - - Spellchecking HTML form fields can be enabled per profile by setting the \l spellCheckEnabled - property and the current languages used for spellchecking can be set by using the - \l spellCheckLanguages property. -*/ - -/*! - \enum QQuickWebEngineProfile::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 \c off-the-record - is not set. Falls back to \c MemoryHttpCache if \c off-the-record is set. - \value NoCache Disable both in-memory and disk caching. (Added in Qt 5.7) -*/ - -/*! - \enum QQuickWebEngineProfile::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. -*/ - -/*! - \fn QQuickWebEngineProfile::downloadRequested(QQuickWebEngineDownloadItem *download) - - 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 - \c{QQuickWebEngineDownloadItem::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. -*/ - -/*! - \fn QQuickWebEngineProfile::downloadFinished(QQuickWebEngineDownloadItem *download) - - This signal is emitted whenever downloading stops, because it finished successfully, was - cancelled, or was interrupted (for example, because connectivity was lost). - The \a download argument holds the state of the finished download instance. -*/ - -/*! - \fn QQuickWebEngineProfile::presentNotification(QWebEngineNotification *notification) - - This signal is emitted whenever there is a newly created user notification. - The \a notification argument holds the \l {QWebEngineNotification} instance - to query data and interact with. - - \sa WebEngineProfile::presentNotification -*/ - -QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(ProfileAdapter *profileAdapter) - : m_settings(new QQuickWebEngineSettings()) - , m_profileAdapter(profileAdapter) -{ - profileAdapter->addClient(this); - m_settings->d_ptr->initDefaults(); - // Fullscreen API was implemented before the supported setting, so we must - // make it default true to avoid change in default API behavior. - m_settings->d_ptr->setAttribute(QtWebEngineCore::WebEngineSettings::FullScreenSupportEnabled, true); -} - -QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() -{ - 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; -} - -void QQuickWebEngineProfilePrivate::addWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter) -{ - Q_ASSERT(m_profileAdapter); - m_profileAdapter->addWebContentsAdapterClient(adapter); -} - -void QQuickWebEngineProfilePrivate::removeWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient*adapter) -{ - Q_ASSERT(m_profileAdapter); - m_profileAdapter->removeWebContentsAdapterClient(adapter); -} - -QtWebEngineCore::ProfileAdapter *QQuickWebEngineProfilePrivate::profileAdapter() const -{ - return m_profileAdapter; -} - -QQuickWebEngineSettings *QQuickWebEngineProfilePrivate::settings() const -{ - return m_settings.data(); -} - -void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId) -{ - if (m_profileAdapter) - m_profileAdapter->cancelDownload(downloadId); -} - -void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) -{ - m_ongoingDownloads.remove(downloadId); - if (m_profileAdapter) - m_profileAdapter->removeDownload(downloadId); -} - -void QQuickWebEngineProfilePrivate::cleanDownloads() -{ - for (auto download : m_ongoingDownloads.values()) { - if (!download) - continue; - - if (!download->isFinished()) - download->cancel(); - - if (m_profileAdapter) - m_profileAdapter->removeDownload(download->id()); - } - m_ongoingDownloads.clear(); -} - -void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) -{ - Q_Q(QQuickWebEngineProfile); - - Q_ASSERT(!m_ongoingDownloads.contains(info.id)); - QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q, info.url); - itemPrivate->downloadId = info.id; - itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested; - itemPrivate->startTime = info.startTime; - itemPrivate->totalBytes = info.totalBytes; - itemPrivate->mimeType = info.mimeType; - itemPrivate->downloadDirectory = QFileInfo(info.path).path(); - itemPrivate->downloadFileName = QFileInfo(info.path).fileName(); - itemPrivate->suggestedFileName = info.suggestedFileName; - itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>( - info.savePageFormat); - itemPrivate->type = static_cast<QQuickWebEngineDownloadItem::DownloadType>(info.downloadType); - if (info.page && info.page->clientType() == QtWebEngineCore::WebContentsAdapterClient::QmlClient) - itemPrivate->view = static_cast<QQuickWebEngineViewPrivate *>(info.page)->q_ptr; - else - itemPrivate->view = nullptr; - - QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q); - - m_ongoingDownloads.insert(info.id, download); - QObject::connect(download, &QQuickWebEngineDownloadItem::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); }); - - QQmlEngine::setObjectOwnership(download, QQmlEngine::JavaScriptOwnership); - Q_EMIT q->downloadRequested(download); - - QQuickWebEngineDownloadItem::DownloadState state = download->state(); - info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName()); - info.savePageFormat = itemPrivate->savePageFormat; - info.accepted = state != QQuickWebEngineDownloadItem::DownloadCancelled - && state != QQuickWebEngineDownloadItem::DownloadRequested; - - if (state == QQuickWebEngineDownloadItem::DownloadRequested) { - // Delete unaccepted downloads. - info.accepted = false; - delete download; - } -} - -void QQuickWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info) -{ - if (!m_ongoingDownloads.contains(info.id)) - return; - - Q_Q(QQuickWebEngineProfile); - - QQuickWebEngineDownloadItem* download = m_ongoingDownloads.value(info.id).data(); - - if (!download) { - downloadDestroyed(info.id); - return; - } - - download->d_func()->update(info); - - if (info.state != ProfileAdapterClient::DownloadInProgress) { - Q_EMIT q->downloadFinished(download); - } -} - -void QQuickWebEngineProfilePrivate::useForGlobalCertificateVerificationChanged() -{ - Q_Q(QQuickWebEngineProfile); - Q_EMIT q->useForGlobalCertificateVerificationChanged(); -} - -void QQuickWebEngineProfilePrivate::showNotification(QSharedPointer<QtWebEngineCore::UserNotificationController> &controller) -{ - Q_Q(QQuickWebEngineProfile); - auto notification = new QWebEngineNotification(controller); - QQmlEngine::setObjectOwnership(notification, QQmlEngine::JavaScriptOwnership); - Q_EMIT q->presentNotification(notification); -} - -void QQuickWebEngineProfilePrivate::userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script) -{ - Q_ASSERT(p && p->data); - QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data); - QtWebEngineCore::UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController(); - d->m_userScripts.append(script); - script->d_func()->bind(resourceController); -} - -int QQuickWebEngineProfilePrivate::userScripts_count(QQmlListProperty<QQuickWebEngineScript> *p) -{ - Q_ASSERT(p && p->data); - QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data); - return d->m_userScripts.count(); -} - -QQuickWebEngineScript *QQuickWebEngineProfilePrivate::userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx) -{ - Q_ASSERT(p && p->data); - QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data); - return d->m_userScripts.at(idx); -} - -void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p) -{ - Q_ASSERT(p && p->data); - QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data); - QtWebEngineCore::UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController(); - resourceController->clearAllScripts(NULL); - d->m_userScripts.clear(); -} - -/*! - \qmltype WebEngineProfile - \instantiates QQuickWebEngineProfile - \inqmlmodule QtWebEngine - \since QtWebEngine 1.1 - \brief Contains settings, scripts, and visited links common to multiple web engine views. - - WebEngineProfile contains settings, scripts, and the list of visited links shared by all - views that belong to the profile. - - Information about visited links is stored together with persistent cookies - and other persistent data in a storage determined by the storageName - property. Persistent data is stored in a subdirectory determined by the - persistentStoragePath property and the cache in a subdirectory determined by - the cachePath property. The httpCacheType property describes the type of the - cache: \e in-memory or \e on-disk. If only the storageName property is set, - the other values are generated automatically based on it. If you specify - any of the values manually, you should do it before creating any pages that - belong to the profile. - - 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. An - off-the-record profile forces cookies, the HTTP cache, and other normally - persistent data to be stored only in memory. The offTheRecord property holds - whether a profile is off-the-record. - - Each web engine view has an associated profile. Views that do not have a specific profile set - share a common default one. -*/ - -/*! - \qmlsignal WebEngineProfile::downloadRequested(WebEngineDownloadItem download) - - 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 WebEngineDownloadItem::accept() or the - download will be cancelled by default. -*/ - -/*! - \qmlsignal WebEngineProfile::downloadFinished(WebEngineDownloadItem download) - - This signal is emitted whenever downloading stops, because it finished successfully, was - cancelled, or was interrupted (for example, because connectivity was lost). - The \a download argument holds the state of the finished download instance. -*/ - -/*! - \qmlsignal WebEngineProfile::presentNotification(WebEngineNotification notification) - \since QtWebEngine 1.9 - - This signal is emitted whenever there is a newly created user notification. - The \a notification argument holds the \l {WebEngineNotification} instance - to query data and interact with. -*/ - -/*! - Constructs a new profile with the parent \a parent. -*/ -QQuickWebEngineProfile::QQuickWebEngineProfile(QObject *parent) - : QObject(parent), - d_ptr(new QQuickWebEngineProfilePrivate(new QtWebEngineCore::ProfileAdapter())) -{ - d_ptr->q_ptr = this; -} - -QQuickWebEngineProfile::QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *privatePtr, QObject *parent) - : QObject(parent) - , d_ptr(privatePtr) -{ - d_ptr->q_ptr = this; -} - -/*! - \internal -*/ -QQuickWebEngineProfile::~QQuickWebEngineProfile() -{ - d_ptr->cleanDownloads(); -} - -/*! - \qmlproperty string WebEngineProfile::storageName - - The storage name that is used to create separate subdirectories for each profile that uses - the disk for storing persistent data and cache. - - \sa WebEngineProfile::persistentStoragePath, WebEngineProfile::cachePath -*/ - -/*! - \property QQuickWebEngineProfile::storageName - - The storage name that is used to create separate subdirectories for each profile that uses - the disk for storing persistent data and cache. - - \sa persistentStoragePath, cachePath -*/ - -QString QQuickWebEngineProfile::storageName() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->storageName(); -} - -void QQuickWebEngineProfile::setStorageName(const QString &name) -{ - Q_D(QQuickWebEngineProfile); - if (d->profileAdapter()->storageName() == name) - return; - ProfileAdapter::HttpCacheType oldCacheType = d->profileAdapter()->httpCacheType(); - ProfileAdapter::PersistentCookiesPolicy oldPolicy = d->profileAdapter()->persistentCookiesPolicy(); - d->profileAdapter()->setStorageName(name); - emit storageNameChanged(); - emit persistentStoragePathChanged(); - emit cachePathChanged(); - if (d->profileAdapter()->httpCacheType() != oldCacheType) - emit httpCacheTypeChanged(); - if (d->profileAdapter()->persistentCookiesPolicy() != oldPolicy) - emit persistentCookiesPolicyChanged(); -} - -/*! - \qmlproperty bool WebEngineProfile::offTheRecord - - Whether the web engine profile is \e off-the-record. - An off-the-record profile forces cookies, the HTTP cache, and other normally persistent data - to be stored only in memory. -*/ - - -/*! - \property QQuickWebEngineProfile::offTheRecord - - Whether the web engine profile is \e off-the-record. - An off-the-record profile forces cookies, the HTTP cache, and other normally persistent data - to be stored only in memory. -*/ - -bool QQuickWebEngineProfile::isOffTheRecord() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->isOffTheRecord(); -} - -void QQuickWebEngineProfile::setOffTheRecord(bool offTheRecord) -{ - Q_D(QQuickWebEngineProfile); - if (d->profileAdapter()->isOffTheRecord() == offTheRecord) - return; - ProfileAdapter::HttpCacheType oldCacheType = d->profileAdapter()->httpCacheType(); - ProfileAdapter::PersistentCookiesPolicy oldPolicy = d->profileAdapter()->persistentCookiesPolicy(); - d->profileAdapter()->setOffTheRecord(offTheRecord); - emit offTheRecordChanged(); - if (d->profileAdapter()->httpCacheType() != oldCacheType) - emit httpCacheTypeChanged(); - if (d->profileAdapter()->persistentCookiesPolicy() != oldPolicy) - emit persistentCookiesPolicyChanged(); -} - -/*! - \qmlproperty string WebEngineProfile::persistentStoragePath - - The path to the location where the persistent data for the browser and web content are - stored. Persistent data includes persistent cookies, HTML5 local storage, and visited links. - - By default, the storage is located below - QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a directory named using - storageName. -*/ - -/*! - \property QQuickWebEngineProfile::persistentStoragePath - - The path to the location where the persistent data for the browser and web content are - stored. Persistent data includes persistent cookies, HTML5 local storage, and visited links. - - By default, the storage is located below - QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a directory named using - storageName. -*/ - -QString QQuickWebEngineProfile::persistentStoragePath() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->dataPath(); -} - -void QQuickWebEngineProfile::setPersistentStoragePath(const QString &path) -{ - Q_D(QQuickWebEngineProfile); - if (persistentStoragePath() == path) - return; - d->profileAdapter()->setDataPath(path); - emit persistentStoragePathChanged(); -} - -/*! - \qmlproperty string WebEngineProfile::cachePath - - The path to the location where the profile's caches are stored, in particular the HTTP cache. - - By default, the caches are stored - below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a directory named using - storageName. -*/ - -/*! - \property QQuickWebEngineProfile::cachePath - - The path to the location where the profile's caches are stored, in particular the HTTP cache. - - By default, the caches are stored - below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a directory named using - storageName. -*/ - -QString QQuickWebEngineProfile::cachePath() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->cachePath(); -} - -void QQuickWebEngineProfile::setCachePath(const QString &path) -{ - Q_D(QQuickWebEngineProfile); - if (cachePath() == path) - return; - d->profileAdapter()->setCachePath(path); - emit cachePathChanged(); -} - -/*! - \qmlproperty string WebEngineProfile::httpUserAgent - - 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. -*/ - -/*! - \property QQuickWebEngineProfile::httpUserAgent - - The user-agent string sent with HTTP to identify the browser. -*/ - -QString QQuickWebEngineProfile::httpUserAgent() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->httpUserAgent(); -} - -void QQuickWebEngineProfile::setHttpUserAgent(const QString &userAgent) -{ - Q_D(QQuickWebEngineProfile); - if (d->profileAdapter()->httpUserAgent() == userAgent) - return; - d->profileAdapter()->setHttpUserAgent(userAgent); - emit httpUserAgentChanged(); -} - - -/*! - \qmlproperty enumeration WebEngineProfile::httpCacheType - - This enumeration describes the type of the HTTP cache: - - \value WebEngineProfile.MemoryHttpCache - Uses an in-memory cache. This is the only setting possible if offTheRecord is set or - no persistentStoragePath is available. - \value WebEngineProfile.DiskHttpCache - Uses a disk cache. This is the default value. - \value WebEngineProfile.NoCache - Disables caching. (Added in 5.7) -*/ - -/*! - \property QQuickWebEngineProfile::httpCacheType - - This enumeration describes the type of the HTTP cache. - - If the profile is off-the-record, MemoryHttpCache is returned. -*/ - -QQuickWebEngineProfile::HttpCacheType QQuickWebEngineProfile::httpCacheType() const -{ - const Q_D(QQuickWebEngineProfile); - return QQuickWebEngineProfile::HttpCacheType(d->profileAdapter()->httpCacheType()); -} - -void QQuickWebEngineProfile::setHttpCacheType(QQuickWebEngineProfile::HttpCacheType httpCacheType) -{ - Q_D(QQuickWebEngineProfile); - ProfileAdapter::HttpCacheType oldCacheType = d->profileAdapter()->httpCacheType(); - d->profileAdapter()->setHttpCacheType(ProfileAdapter::HttpCacheType(httpCacheType)); - if (d->profileAdapter()->httpCacheType() != oldCacheType) - emit httpCacheTypeChanged(); -} - -/*! - \qmlproperty enumeration WebEngineProfile::persistentCookiesPolicy - - This enumeration describes the policy of cookie persistency: - - \value WebEngineProfile.NoPersistentCookies - Both session and persistent cookies are stored in memory. This is the only setting - possible if offTheRecord is set or no persistentStoragePath is available. - \value WebEngineProfile.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 WebEngineProfile.ForcePersistentCookies - Both session and persistent cookies are saved to and restored from disk. -*/ - -/*! - \property QQuickWebEngineProfile::persistentCookiesPolicy - - This enumeration describes the policy of cookie persistency. - If the profile is off-the-record, NoPersistentCookies is returned. -*/ - -QQuickWebEngineProfile::PersistentCookiesPolicy QQuickWebEngineProfile::persistentCookiesPolicy() const -{ - const Q_D(QQuickWebEngineProfile); - return QQuickWebEngineProfile::PersistentCookiesPolicy(d->profileAdapter()->persistentCookiesPolicy()); -} - -void QQuickWebEngineProfile::setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy newPersistentCookiesPolicy) -{ - Q_D(QQuickWebEngineProfile); - ProfileAdapter::PersistentCookiesPolicy oldPolicy = d->profileAdapter()->persistentCookiesPolicy(); - d->profileAdapter()->setPersistentCookiesPolicy(ProfileAdapter::PersistentCookiesPolicy(newPersistentCookiesPolicy)); - if (d->profileAdapter()->persistentCookiesPolicy() != oldPolicy) - emit persistentCookiesPolicyChanged(); -} - -/*! - \qmlproperty int WebEngineProfile::httpCacheMaximumSize - - The maximum size of the HTTP cache. If \c 0, the size will be controlled automatically by - QtWebEngine. The default value is \c 0. - - \sa httpCacheType -*/ - -/*! - \property QQuickWebEngineProfile::httpCacheMaximumSize - - The maximum size of the HTTP cache. If \c 0, the size will be controlled automatically by - QtWebEngine. The default value is \c 0. - - \sa httpCacheType -*/ - -int QQuickWebEngineProfile::httpCacheMaximumSize() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->httpCacheMaxSize(); -} - -void QQuickWebEngineProfile::setHttpCacheMaximumSize(int maximumSize) -{ - Q_D(QQuickWebEngineProfile); - if (d->profileAdapter()->httpCacheMaxSize() == maximumSize) - return; - d->profileAdapter()->setHttpCacheMaxSize(maximumSize); - emit httpCacheMaximumSizeChanged(); -} - -/*! - \qmlproperty string WebEngineProfile::httpAcceptLanguage - - The value of the Accept-Language HTTP request-header field. - - \since QtWebEngine 1.2 -*/ - -/*! - \property QQuickWebEngineProfile::httpAcceptLanguage - - The value of the Accept-Language HTTP request-header field. -*/ - -QString QQuickWebEngineProfile::httpAcceptLanguage() const -{ - Q_D(const QQuickWebEngineProfile); - return d->profileAdapter()->httpAcceptLanguage(); -} - -void QQuickWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage) -{ - Q_D(QQuickWebEngineProfile); - if (d->profileAdapter()->httpAcceptLanguage() == httpAcceptLanguage) - return; - d->profileAdapter()->setHttpAcceptLanguage(httpAcceptLanguage); - emit httpAcceptLanguageChanged(); -} - -/*! - Returns the default profile. - - The default profile uses the storage name "Default". - - \sa storageName() -*/ -QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile() -{ - static QQuickWebEngineProfile *profile = new QQuickWebEngineProfile( - new QQuickWebEngineProfilePrivate(ProfileAdapter::createDefaultProfileAdapter()), - ProfileAdapter::globalQObjectRoot()); - return profile; -} - -/*! - \property QQuickWebEngineProfile::spellCheckLanguages - \brief The languages used by the spell checker. - - \since QtWebEngine 1.4 -*/ - -/*! - \qmlproperty list<string> WebEngineProfile::spellCheckLanguages - - This property holds the list of languages used by 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}. - - \since QtWebEngine 1.4 -*/ -void QQuickWebEngineProfile::setSpellCheckLanguages(const QStringList &languages) -{ - Q_D(QQuickWebEngineProfile); - if (languages != d->profileAdapter()->spellCheckLanguages()) { - d->profileAdapter()->setSpellCheckLanguages(languages); - emit spellCheckLanguagesChanged(); - } -} - -/*! - \since 5.8 - - Returns the list of languages used by the spell checker. -*/ -QStringList QQuickWebEngineProfile::spellCheckLanguages() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->spellCheckLanguages(); -} - -/*! - \property QQuickWebEngineProfile::spellCheckEnabled - \brief whether the web engine spell checker is enabled. - - \since QtWebEngine 1.4 -*/ - -/*! - \qmlproperty bool WebEngineProfile::spellCheckEnabled - - This property holds whether the web engine spell checker is enabled. - - \since QtWebEngine 1.4 -*/ -void QQuickWebEngineProfile::setSpellCheckEnabled(bool enable) -{ - Q_D(QQuickWebEngineProfile); - if (enable != isSpellCheckEnabled()) { - d->profileAdapter()->setSpellCheckEnabled(enable); - emit spellCheckEnabledChanged(); - } -} - -bool QQuickWebEngineProfile::isSpellCheckEnabled() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->isSpellCheckEnabled(); -} - -/*! - \property QQuickWebEngineProfile::useForGlobalCertificateVerification - \since 5.13 - - This property holds whether this profile is used for downloading and - caching during global certificate verification when using the online - certificate status protocol (OCSP), certificate revokation lists (CRLs), - and authority information access (AIA), for example. - - As long as one profile has this option enabled, all other profiles will be - able to use it for certificate verification. Only one profile at a time can - have this option enabled. It is recommended that the profile has a disk HTTP - cache to avoid needlessly re-downloading. - - By default, no profile has this property enabled. - - Currently, only affects Linux/NSS installations, where having a profile with - this role enables OCSP. -*/ - -/*! - \qmlproperty bool WebEngineProfile::useForGlobalCertificateVerification - \since QtWebEngine 1.9 - - This property holds whether this profile is used for downloading and - caching during global certificate verification when using the online - certificate status protocol (OCSP), certificate revokation lists (CRLs), - and authority information access (AIA), for example. - - As long as one profile has this option enabled, all other profiles will be - able to use it for certificate verification. Only one profile at a time can - have this option enabled. It is recommended that the profile has a disk HTTP - cache to avoid needlessly re-downloading. - - By default, no profile has this property enabled. - - Currently, only affects Linux/NSS installations, where having a profile with - this role enables OCSP. -*/ - -void QQuickWebEngineProfile::setUseForGlobalCertificateVerification(bool enable) -{ - Q_D(QQuickWebEngineProfile); - if (enable != d->profileAdapter()->isUsedForGlobalCertificateVerification()) { - d->profileAdapter()->setUseForGlobalCertificateVerification(enable); - emit useForGlobalCertificateVerificationChanged(); - } -} - -bool QQuickWebEngineProfile::isUsedForGlobalCertificateVerification() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->isUsedForGlobalCertificateVerification(); -} - -/*! - \qmlproperty string WebEngineProfile::downloadPath - \since QtWebEngine 1.9 - - The path to the location where the downloaded files are stored. - - Overrides the default path used for download location. - - If set to an empty string, the default path is restored. - - \note By default, the download path is QStandardPaths::DownloadLocation. -*/ - -/*! - \property QQuickWebEngineProfile::downloadPath - \since QtWebEngine 1.9 - - The path to the location where the downloaded files are stored. - - Overrides the default path used for download location, setting it to \a path. - - If set to an empty string, the default path is restored. - - \note By default, the download path is QStandardPaths::DownloadLocation. -*/ - -void QQuickWebEngineProfile::setDownloadPath(const QString &path) -{ - Q_D(QQuickWebEngineProfile); - if (downloadPath() == path) - return; - d->profileAdapter()->setDownloadPath(path); - emit downloadPathChanged(); -} - -QString QQuickWebEngineProfile::downloadPath() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->downloadPath(); -} - -/*! - - Returns the cookie store for this profile. -*/ -QWebEngineCookieStore *QQuickWebEngineProfile::cookieStore() const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->cookieStore(); -} - -/*! - \qmlmethod void WebEngineProfile::clearHttpCache() - \since QtWebEngine 1.3 - - Removes the profile's cache entries. - - \sa WebEngineProfile::cachePath -*/ - -/*! - \since 5.7 - - Removes the profile's cache entries. - - \sa WebEngineProfile::clearHttpCache -*/ -void QQuickWebEngineProfile::clearHttpCache() -{ - Q_D(QQuickWebEngineProfile); - d->profileAdapter()->clearHttpCache(); -} - -#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. - Use setUrlRequestInterceptor instead. - - \sa QWebEngineUrlRequestInterceptor - -*/ -void QQuickWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) -{ - Q_D(QQuickWebEngineProfile); - interceptor->setProperty("deprecated", true); - d->profileAdapter()->setRequestInterceptor(interceptor); - qWarning("Use of deprecated not tread-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. - - \sa QWebEngineUrlRequestInfo QWebEngineUrlRequestInterceptor -*/ -void QQuickWebEngineProfile::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) -{ - Q_D(QQuickWebEngineProfile); - d->profileAdapter()->setRequestInterceptor(interceptor); -} - - -/*! - Returns the custom URL scheme handler register for the URL scheme \a scheme. -*/ -const QWebEngineUrlSchemeHandler *QQuickWebEngineProfile::urlSchemeHandler(const QByteArray &scheme) const -{ - const Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->urlSchemeHandler(scheme); -} - -/*! - 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 QQuickWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler) -{ - Q_D(QQuickWebEngineProfile); - d->profileAdapter()->installUrlSchemeHandler(scheme, handler); -} - -/*! - Removes the custom URL scheme handler \a handler from the profile. - - \sa removeUrlScheme() -*/ -void QQuickWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) -{ - Q_D(QQuickWebEngineProfile); - d->profileAdapter()->removeUrlSchemeHandler(handler); -} - -/*! - Removes the custom URL scheme \a scheme from the profile. - - \sa removeUrlSchemeHandler() -*/ -void QQuickWebEngineProfile::removeUrlScheme(const QByteArray &scheme) -{ - Q_D(QQuickWebEngineProfile); - d->profileAdapter()->removeUrlScheme(scheme); -} - -/*! - Removes all custom URL scheme handlers installed in the profile. -*/ -void QQuickWebEngineProfile::removeAllUrlSchemeHandlers() -{ - Q_D(QQuickWebEngineProfile); - d->profileAdapter()->removeAllUrlSchemeHandlers(); -} - -QQuickWebEngineSettings *QQuickWebEngineProfile::settings() const -{ - const Q_D(QQuickWebEngineProfile); - return d->settings(); -} - -/*! - \qmlproperty list<WebEngineScript> WebEngineProfile::userScripts - \since 1.5 - - Returns the collection of WebEngineScripts that are injected into all pages that share - this profile. - - \sa WebEngineScript -*/ - -/*! - \property QQuickWebEngineProfile::userScripts - \since 5.9 - - \brief The collection of scripts that are injected into all pages that share - this profile. - - \sa QQuickWebEngineScript, QQmlListReference -*/ -QQmlListProperty<QQuickWebEngineScript> QQuickWebEngineProfile::userScripts() -{ - Q_D(QQuickWebEngineProfile); - return QQmlListProperty<QQuickWebEngineScript>(this, d, - d->userScripts_append, - d->userScripts_count, - d->userScripts_at, - d->userScripts_clear); -} - -/*! - \since 5.13 - - Returns the profile's client certificate store. -*/ -QWebEngineClientCertificateStore *QQuickWebEngineProfile::clientCertificateStore() -{ -#if QT_CONFIG(ssl) - Q_D(QQuickWebEngineProfile); - return d->profileAdapter()->clientCertificateStore(); -#else - return nullptr; -#endif -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h deleted file mode 100644 index e5f7ff713..000000000 --- a/src/webengine/api/qquickwebengineprofile.h +++ /dev/null @@ -1,197 +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 QQUICKWEBENGINEPROFILE_H -#define QQUICKWEBENGINEPROFILE_H - - -#include <QtWebEngine/qtwebengineglobal.h> - -#include <QtCore/QObject> -#include <QtCore/QScopedPointer> -#include <QtCore/QString> -#include <QtQml/QQmlListProperty> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineDownloadItem; -class QQuickWebEngineProfilePrivate; -class QQuickWebEngineScript; -class QQuickWebEngineSettings; -class QWebEngineClientCertificateStore; -class QWebEngineCookieStore; -class QWebEngineNotification; -class QWebEngineUrlRequestInterceptor; -class QWebEngineUrlSchemeHandler; - -class Q_WEBENGINE_EXPORT QQuickWebEngineProfile : public QObject { - Q_OBJECT - Q_PROPERTY(QString storageName READ storageName WRITE setStorageName NOTIFY storageNameChanged FINAL) - Q_PROPERTY(bool offTheRecord READ isOffTheRecord WRITE setOffTheRecord NOTIFY offTheRecordChanged FINAL) - Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged FINAL) - Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged FINAL) - Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged FINAL) - Q_PROPERTY(HttpCacheType httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY httpCacheTypeChanged FINAL) - Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL REVISION 1) - Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL) - Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL) - Q_PROPERTY(QStringList spellCheckLanguages READ spellCheckLanguages WRITE setSpellCheckLanguages NOTIFY spellCheckLanguagesChanged FINAL REVISION 3) - Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY spellCheckEnabledChanged FINAL REVISION 3) - Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL REVISION 4) - Q_PROPERTY(bool useForGlobalCertificateVerification - READ isUsedForGlobalCertificateVerification - WRITE setUseForGlobalCertificateVerification - NOTIFY useForGlobalCertificateVerificationChanged - FINAL REVISION 5) - Q_PROPERTY(QString downloadPath READ downloadPath WRITE setDownloadPath NOTIFY downloadPathChanged FINAL REVISION 5) - -public: - QQuickWebEngineProfile(QObject *parent = Q_NULLPTR); - ~QQuickWebEngineProfile(); - - enum HttpCacheType { - MemoryHttpCache, - DiskHttpCache, - NoCache - }; - Q_ENUM(HttpCacheType) - - enum PersistentCookiesPolicy { - NoPersistentCookies, - AllowPersistentCookies, - ForcePersistentCookies - }; - Q_ENUM(PersistentCookiesPolicy) - - QString storageName() const; - void setStorageName(const QString &name); - - bool isOffTheRecord() const; - void setOffTheRecord(bool offTheRecord); - - 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(QQuickWebEngineProfile::HttpCacheType); - - PersistentCookiesPolicy persistentCookiesPolicy() const; - void setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy); - - int httpCacheMaximumSize() const; - void setHttpCacheMaximumSize(int maxSize); - - QString httpAcceptLanguage() const; - void setHttpAcceptLanguage(const QString &httpAcceptLanguage); - - QWebEngineCookieStore *cookieStore() const; - -#if QT_DEPRECATED_SINCE(5, 13) - void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor); -#endif - void setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor); - - const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &) const; - void installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *); - void removeUrlScheme(const QByteArray &scheme); - void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *); - void removeAllUrlSchemeHandlers(); - - Q_REVISION(2) Q_INVOKABLE void clearHttpCache(); - - void setSpellCheckLanguages(const QStringList &languages); - QStringList spellCheckLanguages() const; - void setSpellCheckEnabled(bool enabled); - bool isSpellCheckEnabled() const; - - QQmlListProperty<QQuickWebEngineScript> userScripts(); - - void setUseForGlobalCertificateVerification(bool b); - bool isUsedForGlobalCertificateVerification() const; - - QString downloadPath() const; - void setDownloadPath(const QString &path); - - QWebEngineClientCertificateStore *clientCertificateStore(); - - static QQuickWebEngineProfile *defaultProfile(); - -Q_SIGNALS: - void storageNameChanged(); - void offTheRecordChanged(); - void persistentStoragePathChanged(); - void cachePathChanged(); - void httpUserAgentChanged(); - void httpCacheTypeChanged(); - void persistentCookiesPolicyChanged(); - void httpCacheMaximumSizeChanged(); - Q_REVISION(1) void httpAcceptLanguageChanged(); - Q_REVISION(3) void spellCheckLanguagesChanged(); - Q_REVISION(3) void spellCheckEnabledChanged(); - Q_REVISION(5) void useForGlobalCertificateVerificationChanged(); - Q_REVISION(5) void downloadPathChanged(); - - void downloadRequested(QQuickWebEngineDownloadItem *download); - void downloadFinished(QQuickWebEngineDownloadItem *download); - - Q_REVISION(5) void presentNotification(QWebEngineNotification *notification); - -private: - Q_DECLARE_PRIVATE(QQuickWebEngineProfile) - QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *, QObject *parent = Q_NULLPTR); - QQuickWebEngineSettings *settings() const; - - friend class QQuickWebEngineSettings; - friend class QQuickWebEngineSingleton; - friend class QQuickWebEngineViewPrivate; - friend class QQuickWebEngineDownloadItem; - friend class QQuickWebEngineDownloadItemPrivate; - friend class QQuickWebEngineView; - QScopedPointer<QQuickWebEngineProfilePrivate> d_ptr; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEPROFILE_H diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h deleted file mode 100644 index c6d412ab3..000000000 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ /dev/null @@ -1,109 +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 QQUICKWEBENGINEPROFILE_P_H -#define QQUICKWEBENGINEPROFILE_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 "profile_adapter.h" -#include "qquickwebengineprofile.h" - -#include <QExplicitlySharedDataPointer> -#include <QMap> -#include <QPointer> -#include <QSharedPointer> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineDownloadItem; -class QQuickWebEngineSettings; -class QQuickWebEngineViewPrivate; - -class QQuickWebEngineProfilePrivate : public QtWebEngineCore::ProfileAdapterClient { -public: - Q_DECLARE_PUBLIC(QQuickWebEngineProfile) - QQuickWebEngineProfilePrivate(QtWebEngineCore::ProfileAdapter *profileAdapter); - ~QQuickWebEngineProfilePrivate(); - void addWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter) override; - void removeWebContentsAdapterClient(QtWebEngineCore::WebContentsAdapterClient *adapter) override; - - QtWebEngineCore::ProfileAdapter* profileAdapter() const; - QQuickWebEngineSettings *settings() const; - - void cancelDownload(quint32 downloadId); - void downloadDestroyed(quint32 downloadId); - - void cleanDownloads(); - - void downloadRequested(DownloadItemInfo &info) override; - void downloadUpdated(const DownloadItemInfo &info) override; - - void useForGlobalCertificateVerificationChanged() override; - - void showNotification(QSharedPointer<QtWebEngineCore::UserNotificationController> &controller) override; - - // QQmlListPropertyHelpers - static void userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script); - static int userScripts_count(QQmlListProperty<QQuickWebEngineScript> *p); - static QQuickWebEngineScript *userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx); - static void userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p); - -private: - friend class QQuickWebEngineView; - QQuickWebEngineProfile *q_ptr; - QScopedPointer<QQuickWebEngineSettings> m_settings; - QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter; - QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads; - QList<QQuickWebEngineScript *> m_userScripts; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEPROFILE_P_H diff --git a/src/webengine/api/qquickwebenginescript.cpp b/src/webengine/api/qquickwebenginescript.cpp deleted file mode 100644 index ab7aee4cb..000000000 --- a/src/webengine/api/qquickwebenginescript.cpp +++ /dev/null @@ -1,446 +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 "qquickwebenginescript.h" -#include "qquickwebenginescript_p.h" - -#include <QQmlFile> -#include <QtCore/QDebug> -#include <QtCore/QFile> -#include <QtCore/QTimerEvent> -#include "renderer_host/user_resource_controller_host.h" - -using QtWebEngineCore::UserScript; - -QT_BEGIN_NAMESPACE - -/*! - \class QQuickWebEngineScript - \brief Enables the injection of scripts in the JavaScript engine. - \inmodule QtWebEngine - \since 5.9 - - The QQuickWebEngineScript type 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 content. - - 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. The worldId property provides some predefined IDs for this - purpose. -*/ - -/*! - \enum QQuickWebEngineScript::InjectionPoint - - The point in the loading process at which the script will be executed. - - \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 500 ms after the document is ready, - whichever comes first. -*/ - -/*! - \enum QQuickWebEngineScript::ScriptWorldId - - The world ID defining which isolated world the script is executed in. Besides these predefined - IDs custom IDs can be used, but must be integers between \c 0 and \c 256. - - \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. -*/ - -/*! - \qmltype WebEngineScript - \instantiates QQuickWebEngineScript - \inqmlmodule QtWebEngine - \since QtWebEngine 1.1 - \brief Enables the programmatic injection of scripts in the JavaScript engine. - - The WebEngineScript type 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 content. - - 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. The worldId property 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 \l{WebEngineView::userScripts}{WebEngineView.userScripts} to access a list of scripts - attached to the web view. -*/ - -/*! - Constructs a new QQuickWebEngineScript with the parent \a parent. -*/ -QQuickWebEngineScript::QQuickWebEngineScript(QObject *parent) - : QObject(parent) - , d_ptr(new QQuickWebEngineScriptPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - \internal -*/ -QQuickWebEngineScript::~QQuickWebEngineScript() -{ -} - -/*! - Returns the script object as string. -*/ -QString QQuickWebEngineScript::toString() const -{ - Q_D(const QQuickWebEngineScript); - if (d->coreScript.isNull()) - return QStringLiteral("QWebEngineScript()"); - QString ret = QStringLiteral("QWebEngineScript(") % d->coreScript.name() % QStringLiteral(", "); - switch (d->coreScript.injectionPoint()) { - case UserScript::DocumentElementCreation: - ret.append(QStringLiteral("WebEngineScript::DocumentCreation, ")); - break; - case UserScript::DocumentLoadFinished: - ret.append(QStringLiteral("WebEngineScript::DocumentReady, ")); - break; - case UserScript::AfterLoad: - ret.append(QStringLiteral("WebEngineScript::Deferred, ")); - break; - } - ret.append(QString::number(d->coreScript.worldId()) % QStringLiteral(", ") - % (d->coreScript.runsOnSubFrames() ? QStringLiteral("true") : QStringLiteral("false")) - % QStringLiteral(", ") % d->coreScript.sourceCode() % QLatin1Char(')')); - return ret; -} - -/*! - \property QQuickWebEngineScript::name - \brief The name of the script. - - Can be useful to retrieve a particular script from - QQuickWebEngineProfile::userScripts. -*/ - -/*! - \qmlproperty string WebEngineScript::name - - The name of the script. Can be useful to retrieve a particular script from - \l{WebEngineView::userScripts}{WebEngineView.userScripts}. -*/ -QString QQuickWebEngineScript::name() const -{ - Q_D(const QQuickWebEngineScript); - return d->coreScript.name(); -} - -/*! - \property QQuickWebEngineScript::sourceUrl - \brief The remote source location of the user script (if any). - - Unlike \l sourceCode, this property allows referring to user scripts that - are not already loaded in memory, for instance, when stored on disk. - - Setting this property will change the \l sourceCode of the script. - - \note At present, only file-based sources are supported. - - \sa QQuickWebEngineScript::sourceCode -*/ - -/*! - \qmlproperty url WebEngineScript::sourceUrl - - This property holds the remote source location of the user script (if any). - - Unlike \l sourceCode, this property allows referring to user scripts that - are not already loaded in memory, for instance, when stored on disk. - - Setting this property will change the \l sourceCode of the script. - - \note At present, only file-based sources are supported. - - \sa sourceCode -*/ -QUrl QQuickWebEngineScript::sourceUrl() const -{ - Q_D(const QQuickWebEngineScript); - return d->m_sourceUrl; -} - -/*! - \property QQuickWebEngineScript::sourceCode - \brief The JavaScript source code of the user script. - - \sa QQuickWebEngineScript::sourceUrl -*/ - -/*! - \qmlproperty string WebEngineScript::sourceCode - - This property holds the JavaScript source code of the user script. - - \sa sourceUrl -*/ -QString QQuickWebEngineScript::sourceCode() const -{ - Q_D(const QQuickWebEngineScript); - return d->coreScript.sourceCode(); -} - -ASSERT_ENUMS_MATCH(QQuickWebEngineScript::Deferred, UserScript::AfterLoad) -ASSERT_ENUMS_MATCH(QQuickWebEngineScript::DocumentReady, UserScript::DocumentLoadFinished) -ASSERT_ENUMS_MATCH(QQuickWebEngineScript::DocumentCreation, UserScript::DocumentElementCreation) - -/*! - \property QQuickWebEngineScript::injectionPoint - \brief The point in the loading process at which the script will be executed. - - The default value is \c Deferred. -*/ - -/*! - \qmlproperty enumeration WebEngineScript::injectionPoint - - The point in the loading process at which the script will be executed. - The default value is \c Deferred. - - \value WebEngineScript.DocumentCreation - The script will be executed as soon as the document is created. This is not suitable for - any DOM operation. - \value WebEngineScript.DocumentReady - The script will run as soon as the DOM is ready. This is equivalent to the - \c DOMContentLoaded event firing in JavaScript. - \value WebEngineScript.Deferred - The script will run when the page load finishes, or 500 ms after the document is ready, - whichever comes first. -*/ -QQuickWebEngineScript::InjectionPoint QQuickWebEngineScript::injectionPoint() const -{ - Q_D(const QQuickWebEngineScript); - return static_cast<QQuickWebEngineScript::InjectionPoint>(d->coreScript.injectionPoint()); -} - -/*! - \property QQuickWebEngineScript::worldId - \brief The world ID defining which isolated world the script is executed in. -*/ - -/*! - \qmlproperty enumeration WebEngineScript::worldId - - The world ID defining which isolated world the script is executed in. - - \value WebEngineScript.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 WebEngineScript.ApplicationWorld - The default isolated world used for application level functionality implemented in - JavaScript. - \value WebEngineScript.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. -*/ -QQuickWebEngineScript::ScriptWorldId QQuickWebEngineScript::worldId() const -{ - Q_D(const QQuickWebEngineScript); - return static_cast<QQuickWebEngineScript::ScriptWorldId>(d->coreScript.worldId()); -} - -/*! - \property QQuickWebEngineScript::runOnSubframes - \brief Whether the script is executed on every frame or only on the main frame. - - Set this property to \c true if the script is executed on every frame in the page, or \c false - if it is only run for the main frame. - The default value is \c{false}. -*/ - -/*! - \qmlproperty int WebEngineScript::runOnSubframes - - Set this property to \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. - The default value is \c{false}. - */ -bool QQuickWebEngineScript::runOnSubframes() const -{ - Q_D(const QQuickWebEngineScript); - return d->coreScript.runsOnSubFrames(); -} - -void QQuickWebEngineScript::setName(const QString &name) -{ - Q_D(QQuickWebEngineScript); - if (name == QQuickWebEngineScript::name()) - return; - d->aboutToUpdateUnderlyingScript(); - d->coreScript.setName(name); - Q_EMIT nameChanged(name); -} - -void QQuickWebEngineScript::setSourceCode(const QString &code) -{ - Q_D(QQuickWebEngineScript); - if (code == sourceCode()) - return; - - // setting the source directly resets the sourceUrl - if (d->m_sourceUrl != QUrl()) { - d->m_sourceUrl = QUrl(); - Q_EMIT sourceUrlChanged(d->m_sourceUrl); - } - - d->aboutToUpdateUnderlyingScript(); - d->coreScript.setSourceCode(code); - Q_EMIT sourceCodeChanged(code); -} - -void QQuickWebEngineScript::setSourceUrl(const QUrl &url) -{ - Q_D(QQuickWebEngineScript); - if (url == sourceUrl()) - return; - - d->m_sourceUrl = url; - Q_EMIT sourceUrlChanged(d->m_sourceUrl); - - QFile f(QQmlFile::urlToLocalFileOrQrc(url)); - if (!f.open(QIODevice::ReadOnly)) { - qWarning() << "Can't open user script " << url; - return; - } - - d->aboutToUpdateUnderlyingScript(); - QString source = QString::fromUtf8(f.readAll()); - d->coreScript.setSourceCode(source); - Q_EMIT sourceCodeChanged(source); -} - -void QQuickWebEngineScript::setInjectionPoint(QQuickWebEngineScript::InjectionPoint injectionPoint) -{ - Q_D(QQuickWebEngineScript); - if (injectionPoint == QQuickWebEngineScript::injectionPoint()) - return; - d->aboutToUpdateUnderlyingScript(); - d->coreScript.setInjectionPoint(static_cast<UserScript::InjectionPoint>(injectionPoint)); - Q_EMIT injectionPointChanged(injectionPoint); -} - - -void QQuickWebEngineScript::setWorldId(QQuickWebEngineScript::ScriptWorldId scriptWorldId) -{ - Q_D(QQuickWebEngineScript); - if (scriptWorldId == worldId()) - return; - d->aboutToUpdateUnderlyingScript(); - d->coreScript.setWorldId(scriptWorldId); - Q_EMIT worldIdChanged(scriptWorldId); -} - - -void QQuickWebEngineScript::setRunOnSubframes(bool on) -{ - Q_D(QQuickWebEngineScript); - if (on == runOnSubframes()) - return; - d->aboutToUpdateUnderlyingScript(); - d->coreScript.setRunsOnSubFrames(on); - Q_EMIT runOnSubframesChanged(on); -} - -/*! - \internal -*/ -void QQuickWebEngineScript::timerEvent(QTimerEvent *e) -{ - Q_D(QQuickWebEngineScript); - if (e->timerId() != d->m_basicTimer.timerId()) { - QObject::timerEvent(e); - return; - } - if (!d->m_controllerHost) - return; - d->m_basicTimer.stop(); - d->m_controllerHost->addUserScript(d->coreScript, d->m_adapter); -} - -void QQuickWebEngineScriptPrivate::bind(QtWebEngineCore::UserResourceControllerHost *resourceController, QtWebEngineCore::WebContentsAdapter *adapter) -{ - aboutToUpdateUnderlyingScript(); - m_adapter = adapter; - m_controllerHost = resourceController; -} - -QQuickWebEngineScriptPrivate::QQuickWebEngineScriptPrivate() - :m_controllerHost(0) - , m_adapter(0) - -{ -} - -void QQuickWebEngineScriptPrivate::aboutToUpdateUnderlyingScript() -{ - Q_Q(QQuickWebEngineScript); - if (m_controllerHost) - m_controllerHost->removeUserScript(coreScript, m_adapter); - // Defer updates to the next event loop - m_basicTimer.start(0, q); -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginescript.h b/src/webengine/api/qquickwebenginescript.h deleted file mode 100644 index d5c4310db..000000000 --- a/src/webengine/api/qquickwebenginescript.h +++ /dev/null @@ -1,114 +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$ -** -****************************************************************************/ - -#ifndef QQUICKWEBENGINESCRIPT_H -#define QQUICKWEBENGINESCRIPT_H - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include <QtWebEngine/qtwebengineglobal.h> - -QT_BEGIN_NAMESPACE -class QQuickWebEngineScriptPrivate; -class QQuickWebEngineView; - -class Q_WEBENGINE_EXPORT QQuickWebEngineScript : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL) - Q_PROPERTY(QUrl sourceUrl READ sourceUrl WRITE setSourceUrl NOTIFY sourceUrlChanged FINAL) - Q_PROPERTY(QString sourceCode READ sourceCode WRITE setSourceCode NOTIFY sourceCodeChanged FINAL) - Q_PROPERTY(InjectionPoint injectionPoint READ injectionPoint WRITE setInjectionPoint NOTIFY injectionPointChanged FINAL) - Q_PROPERTY(ScriptWorldId worldId READ worldId WRITE setWorldId NOTIFY worldIdChanged FINAL) - Q_PROPERTY(bool runOnSubframes READ runOnSubframes WRITE setRunOnSubframes NOTIFY runOnSubframesChanged FINAL) - - -public: - enum InjectionPoint { - Deferred, - DocumentReady, - DocumentCreation - }; - Q_ENUM(InjectionPoint) - - enum ScriptWorldId { - MainWorld = 0, - ApplicationWorld, - UserWorld - }; - Q_ENUM(ScriptWorldId) - - explicit QQuickWebEngineScript(QObject *parent = Q_NULLPTR); - ~QQuickWebEngineScript(); - Q_INVOKABLE QString toString() const; - - QString name() const; - QUrl sourceUrl() const; - QString sourceCode() const; - InjectionPoint injectionPoint() const; - ScriptWorldId worldId() const; - bool runOnSubframes() const; - - Q_INVOKABLE void setName(const QString &name); - Q_INVOKABLE void setSourceUrl(const QUrl &url); - Q_INVOKABLE void setSourceCode(const QString &code); - Q_INVOKABLE void setInjectionPoint(InjectionPoint injectionPoint); - Q_INVOKABLE void setWorldId(ScriptWorldId scriptWorldId); - Q_INVOKABLE void setRunOnSubframes(bool on); - -Q_SIGNALS: - void nameChanged(const QString &name); - void sourceUrlChanged(const QUrl &url); - void sourceCodeChanged(const QString &code); - void injectionPointChanged(InjectionPoint injectionPoint); - void worldIdChanged(ScriptWorldId scriptWorldId); - void runOnSubframesChanged(bool on); - -protected: - void timerEvent(QTimerEvent *e) override; - -private: - friend class QQuickWebEngineProfilePrivate; - friend class QQuickWebEngineViewPrivate; - Q_DECLARE_PRIVATE(QQuickWebEngineScript) - QScopedPointer<QQuickWebEngineScriptPrivate> d_ptr; -}; -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINESCRIPT_H diff --git a/src/webengine/api/qquickwebenginescript_p.h b/src/webengine/api/qquickwebenginescript_p.h deleted file mode 100644 index 30b47a654..000000000 --- a/src/webengine/api/qquickwebenginescript_p.h +++ /dev/null @@ -1,87 +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 QQUICKWEBENGINESCRIPT_P_H -#define QQUICKWEBENGINESCRIPT_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 "qquickwebenginescript.h" - -#include <QtCore/QBasicTimer> -#include "user_script.h" -#include "web_contents_adapter.h" - -namespace QtWebEngineCore { -class UserResourceControllerHost; -class WebContentsAdapter; -} // namespace - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineScriptPrivate { -public: - Q_DECLARE_PUBLIC(QQuickWebEngineScript) - QQuickWebEngineScriptPrivate(); - void aboutToUpdateUnderlyingScript(); - void bind(QtWebEngineCore::UserResourceControllerHost *, QtWebEngineCore::WebContentsAdapter * = 0); - - QtWebEngineCore::UserScript coreScript; - QBasicTimer m_basicTimer; - QtWebEngineCore::UserResourceControllerHost *m_controllerHost; - QtWebEngineCore::WebContentsAdapter *m_adapter; - QUrl m_sourceUrl; - -private: - QQuickWebEngineScript *q_ptr; - -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINESCRIPT_P_H diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp deleted file mode 100644 index 78fbe16e8..000000000 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ /dev/null @@ -1,766 +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 "qquickwebenginesettings_p.h" - -#include "web_engine_settings.h" - -#include <QtWebEngine/QQuickWebEngineProfile> -#include <QtCore/QList> - -QT_BEGIN_NAMESPACE - -using QtWebEngineCore::WebEngineSettings; - -QQuickWebEngineSettings::QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings) - : d_ptr(new WebEngineSettings(parentSettings ? parentSettings->d_ptr.data() : 0)) -{ } - -/*! - \qmltype WebEngineSettings - \instantiates QQuickWebEngineSettings - \inqmlmodule QtWebEngine - \since QtWebEngine 1.1 - \brief Allows configuration of browser properties and attributes. - - The WebEngineSettings type can be used to configure browser properties and generic - attributes, such as JavaScript support, focus behavior, and access to remote content. This type - is uncreatable, but the default settings for all web engine views can be accessed by using - the \l [QML] {WebEngine::settings}{WebEngine.settings} property. - - Each web engine view can have individual settings that can be accessed by using the - \l{WebEngineView::settings}{WebEngineView.settings} property. -*/ - - -QQuickWebEngineSettings::~QQuickWebEngineSettings() -{ } - -/*! - \enum QQuickWebEngineSettings::UnknownUrlSchemePolicy - \since WebEngine 1.7 - - 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. -*/ - -/*! - \qmlproperty bool WebEngineSettings::autoLoadImages - - Automatically loads images on web pages. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::autoLoadImages() const -{ - return d_ptr->testAttribute(WebEngineSettings::AutoLoadImages); -} - -/*! - \qmlproperty bool WebEngineSettings::javascriptEnabled - - Enables the running of JavaScript programs. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::javascriptEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::JavascriptEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::javascriptCanOpenWindows - - Allows JavaScript programs to open popup windows without user interaction. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::javascriptCanOpenWindows() const -{ - return d_ptr->testAttribute(WebEngineSettings::JavascriptCanOpenWindows); -} - -/*! - \qmlproperty bool WebEngineSettings::javascriptCanAccessClipboard - - Allows JavaScript programs to read from or write to the clipboard. - Writing to the clipboard is always allowed if it is specifically requested by the user. - - To enable also the pasting of clipboard content from JavaScript, - use javascriptCanPaste. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::javascriptCanAccessClipboard() const -{ - return d_ptr->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard); -} - -/*! - \qmlproperty bool WebEngineSettings::linksIncludedInFocusChain - - Includes hyperlinks in the keyboard focus chain. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::linksIncludedInFocusChain() const -{ - return d_ptr->testAttribute(WebEngineSettings::LinksIncludedInFocusChain); -} - -/*! - \qmlproperty bool WebEngineSettings::localStorageEnabled - - Enables support for the HTML 5 local storage feature. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::localStorageEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::LocalStorageEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::localContentCanAccessRemoteUrls - - Allows locally loaded documents to access remote URLs. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::localContentCanAccessRemoteUrls() const -{ - return d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls); -} - -/*! - \qmlproperty bool WebEngineSettings::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. - -*/ -bool QQuickWebEngineSettings::spatialNavigationEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::SpatialNavigationEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::localContentCanAccessFileUrls - - Allows locally loaded documents to access other local URLs. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::localContentCanAccessFileUrls() const -{ - return d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls); -} - -/*! - \qmlproperty bool WebEngineSettings::hyperlinkAuditingEnabled - - Enables support for the \c ping attribute for hyperlinks. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::hyperlinkAuditingEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::errorPageEnabled - - Enables displaying the built-in error pages of Chromium. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::errorPageEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::ErrorPageEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::pluginsEnabled - - Enables support for Pepper plugins, such as the Flash player. - - Disabled by default. - - \sa {Pepper Plugin API} -*/ -bool QQuickWebEngineSettings::pluginsEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::PluginsEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::fullscreenSupportEnabled - \since QtWebEngine 1.2 - - Tells the web engine whether fullscreen is supported in this application or not. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::fullScreenSupportEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::FullScreenSupportEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::screenCaptureEnabled - \since QtWebEngine 1.3 - - Tells the web engine whether screen capture is supported in this application or not. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::screenCaptureEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::ScreenCaptureEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::webGLEnabled - \since QtWebEngine 1.3 - - Enables support for HTML 5 WebGL. - - Enabled by default if available. -*/ -bool QQuickWebEngineSettings::webGLEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::WebGLEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::accelerated2dCanvasEnabled - \since QtWebEngine 1.3 - - Specifies whether the HTML 5 2D canvas should be an OpenGL framebuffer. - This makes many painting operations faster, but slows down pixel access. - - Enabled by default if available. -*/ -bool QQuickWebEngineSettings::accelerated2dCanvasEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::Accelerated2dCanvasEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::autoLoadIconsForPage - \since QtWebEngine 1.3 - - Automatically downloads icons for web pages. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::autoLoadIconsForPage() const -{ - return d_ptr->testAttribute(WebEngineSettings::AutoLoadIconsForPage); -} - -/*! - \qmlproperty bool WebEngineSettings::touchIconsEnabled - \since QtWebEngine 1.3 - - Enables support for touch icons and precomposed touch icons. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::touchIconsEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::TouchIconsEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::focusOnNavigationEnabled - \since QtWebEngine 1.4 - - Focus is given to the view whenever a navigation operation occurs - (load, stop, reload, reload and bypass cache, forward, backward, set content, and so on). - - Disabled by default. -*/ -bool QQuickWebEngineSettings::focusOnNavigationEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::FocusOnNavigationEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::printElementBackgrounds - \since QtWebEngine 1.4 - - Turns on printing of CSS backgrounds when printing a web page. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::printElementBackgrounds() const -{ - return d_ptr->testAttribute(WebEngineSettings::PrintElementBackgrounds); -} - -/*! - \qmlproperty bool WebEngineSettings::allowRunningInsecureContent - \since QtWebEngine 1.4 - - By default, HTTPS pages cannot run JavaScript, CSS, plugins or - web-sockets from HTTP URLs. This used to be possible and this - provides an override to get the old behavior. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::allowRunningInsecureContent() const -{ - return d_ptr->testAttribute(WebEngineSettings::AllowRunningInsecureContent); -} - -/*! - \qmlproperty bool WebEngineSettings::allowGeolocationOnInsecureOrigins - \since QtWebEngine 1.5 - - 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. -*/ -bool QQuickWebEngineSettings::allowGeolocationOnInsecureOrigins() const -{ - return d_ptr->testAttribute(WebEngineSettings::AllowGeolocationOnInsecureOrigins); -} - -/*! - \qmlproperty bool WebEngineSettings::allowWindowActivationFromJavaScript - \since QtWebEngine 1.6 - Allows the window.focus() method in JavaScript. Disallowed by default. -*/ -bool QQuickWebEngineSettings::allowWindowActivationFromJavaScript() const -{ - return d_ptr->testAttribute(WebEngineSettings::AllowWindowActivationFromJavaScript); -} - -/*! - \qmlproperty bool WebEngineSettings::showScrollBars - \since QtWebEngine 1.6 - Shows scroll bars. Enabled by default. -*/ -bool QQuickWebEngineSettings::showScrollBars() const -{ - return d_ptr->testAttribute(WebEngineSettings::ShowScrollBars); -} - -/*! - \qmlproperty bool WebEngineSettings::playbackRequiresUserGesture - \since QtWebEngine 1.7 - Inhibits playback of media content until the user interacts with - the page. - - By default, Qt WebEngine uses Chromium settings, as described in - \l {Autoplay Policy Changes}. To overwrite the default behavior, - this property must be set to \c false. - - \note The behavior is similar to Chrome on Android when enabled, - and similar to Chrome on desktops when disabled. -*/ -bool QQuickWebEngineSettings::playbackRequiresUserGesture() const -{ - return d_ptr->testAttribute(WebEngineSettings::PlaybackRequiresUserGesture); -} - -/*! - \qmlproperty bool WebEngineSettings::webRTCPublicInterfacesOnly - \since QtWebEngine 1.7 - 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. -*/ -bool QQuickWebEngineSettings::webRTCPublicInterfacesOnly() const -{ - return d_ptr->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly); -} - -/*! - \qmlproperty bool WebEngineSettings::javascriptCanPaste - \since QtWebEngine 1.7 - - Enables JavaScript \c{execCommand("paste")}. - This also requires enabling javascriptCanAccessClipboard. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::javascriptCanPaste() const -{ - return d_ptr->testAttribute(WebEngineSettings::JavascriptCanPaste); -} - -/*! - \qmlproperty bool WebEngineSettings::dnsPrefetchEnabled - \since QtWebEngine 1.8 - - Enables speculative prefetching of DNS records for HTML links before - they are activated. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::dnsPrefetchEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::DnsPrefetchEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::pdfViewerEnabled - \since QtWebEngine 1.9 - - Specifies that PDF documents will be opened in the internal PDF viewer - instead of being downloaded. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::pdfViewerEnabled() const -{ - return d_ptr->testAttribute(WebEngineSettings::PdfViewerEnabled); -} - -/*! - \qmlproperty string WebEngineSettings::defaultTextEncoding - \since QtWebEngine 1.2 - - Sets the default encoding. The value must be a string describing an encoding such as "utf-8" or - "iso-8859-1". - - If left empty, a default value will be used. -*/ -QString QQuickWebEngineSettings::defaultTextEncoding() const -{ - return d_ptr->defaultTextEncoding(); -} - -ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::DisallowUnknownUrlSchemes, WebEngineSettings::DisallowUnknownUrlSchemes) -ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction) -ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowAllUnknownUrlSchemes, WebEngineSettings::AllowAllUnknownUrlSchemes) - -/*! - \qmlproperty WebEngineSettings::UnknownUrlSchemePolicy WebEngineSettings::unknownUrlSchemePolicy - \since QtWebEngine 1.7 - Specifies how navigation requests to URLs with unknown schemes are handled. - - Default is \l{QWebEngineSettings::UnknownUrlSchemePolicy}{WebEngineSettings.AllowUnknownUrlSchemesFromUserInteraction}. -*/ -QQuickWebEngineSettings::UnknownUrlSchemePolicy QQuickWebEngineSettings::unknownUrlSchemePolicy() const -{ - return static_cast<QQuickWebEngineSettings::UnknownUrlSchemePolicy>(d_ptr->unknownUrlSchemePolicy()); -} - -void QQuickWebEngineSettings::setAutoLoadImages(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::AutoLoadImages); - // Set unconditionally as it sets the override for the current settings while the current setting - // could be from the fallback and is prone to changing later on. - d_ptr->setAttribute(WebEngineSettings::AutoLoadImages, on); - if (wasOn != on) - Q_EMIT autoLoadImagesChanged(); -} - -void QQuickWebEngineSettings::setJavascriptEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptEnabled); - d_ptr->setAttribute(WebEngineSettings::JavascriptEnabled, on); - if (wasOn != on) - Q_EMIT javascriptEnabledChanged(); -} - -void QQuickWebEngineSettings::setJavascriptCanOpenWindows(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptCanOpenWindows); - d_ptr->setAttribute(WebEngineSettings::JavascriptCanOpenWindows, on); - if (wasOn != on) - Q_EMIT javascriptCanOpenWindowsChanged(); -} - -void QQuickWebEngineSettings::setJavascriptCanAccessClipboard(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard); - d_ptr->setAttribute(WebEngineSettings::JavascriptCanAccessClipboard, on); - if (wasOn != on) - Q_EMIT javascriptCanAccessClipboardChanged(); -} - -void QQuickWebEngineSettings::setLinksIncludedInFocusChain(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::LinksIncludedInFocusChain); - d_ptr->setAttribute(WebEngineSettings::LinksIncludedInFocusChain, on); - if (wasOn != on) - Q_EMIT linksIncludedInFocusChainChanged(); -} - -void QQuickWebEngineSettings::setLocalStorageEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::LocalStorageEnabled); - d_ptr->setAttribute(WebEngineSettings::LocalStorageEnabled, on); - if (wasOn != on) - Q_EMIT localStorageEnabledChanged(); -} - -void QQuickWebEngineSettings::setLocalContentCanAccessRemoteUrls(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls); - d_ptr->setAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls, on); - if (wasOn != on) - Q_EMIT localContentCanAccessRemoteUrlsChanged(); -} - - -void QQuickWebEngineSettings::setSpatialNavigationEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::SpatialNavigationEnabled); - d_ptr->setAttribute(WebEngineSettings::SpatialNavigationEnabled, on); - if (wasOn != on) - Q_EMIT spatialNavigationEnabledChanged(); -} - -void QQuickWebEngineSettings::setLocalContentCanAccessFileUrls(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls); - d_ptr->setAttribute(WebEngineSettings::LocalContentCanAccessFileUrls, on); - if (wasOn != on) - Q_EMIT localContentCanAccessFileUrlsChanged(); -} - -void QQuickWebEngineSettings::setHyperlinkAuditingEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled); - d_ptr->setAttribute(WebEngineSettings::HyperlinkAuditingEnabled, on); - if (wasOn != on) - Q_EMIT hyperlinkAuditingEnabledChanged(); -} - -void QQuickWebEngineSettings::setErrorPageEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::ErrorPageEnabled); - d_ptr->setAttribute(WebEngineSettings::ErrorPageEnabled, on); - if (wasOn != on) - Q_EMIT errorPageEnabledChanged(); -} - -void QQuickWebEngineSettings::setPluginsEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::PluginsEnabled); - d_ptr->setAttribute(WebEngineSettings::PluginsEnabled, on); - if (wasOn != on) - Q_EMIT pluginsEnabledChanged(); -} - -void QQuickWebEngineSettings::setFullScreenSupportEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::FullScreenSupportEnabled); - d_ptr->setAttribute(WebEngineSettings::FullScreenSupportEnabled, on); - if (wasOn != on) - Q_EMIT fullScreenSupportEnabledChanged(); -} - -void QQuickWebEngineSettings::setScreenCaptureEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::ScreenCaptureEnabled); - d_ptr->setAttribute(WebEngineSettings::ScreenCaptureEnabled, on); - if (wasOn != on) - Q_EMIT screenCaptureEnabledChanged(); -} - -void QQuickWebEngineSettings::setWebGLEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::WebGLEnabled); - d_ptr->setAttribute(WebEngineSettings::WebGLEnabled, on); - if (wasOn != on) - Q_EMIT webGLEnabledChanged(); -} - -void QQuickWebEngineSettings::setAccelerated2dCanvasEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::Accelerated2dCanvasEnabled); - d_ptr->setAttribute(WebEngineSettings::Accelerated2dCanvasEnabled, on); - if (wasOn != on) - Q_EMIT accelerated2dCanvasEnabledChanged(); -} - -void QQuickWebEngineSettings::setAutoLoadIconsForPage(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::AutoLoadIconsForPage); - d_ptr->setAttribute(WebEngineSettings::AutoLoadIconsForPage, on); - if (wasOn != on) - Q_EMIT autoLoadIconsForPageChanged(); -} - -void QQuickWebEngineSettings::setTouchIconsEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::TouchIconsEnabled); - d_ptr->setAttribute(WebEngineSettings::TouchIconsEnabled, on); - if (wasOn != on) - Q_EMIT touchIconsEnabledChanged(); -} - -void QQuickWebEngineSettings::setPrintElementBackgrounds(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::PrintElementBackgrounds); - d_ptr->setAttribute(WebEngineSettings::PrintElementBackgrounds, on); - if (wasOn != on) - Q_EMIT printElementBackgroundsChanged(); -} - -void QQuickWebEngineSettings::setDefaultTextEncoding(QString encoding) -{ - const QString oldDefaultTextEncoding = d_ptr->defaultTextEncoding(); - d_ptr->setDefaultTextEncoding(encoding); - if (oldDefaultTextEncoding.compare(encoding)) - Q_EMIT defaultTextEncodingChanged(); -} - -void QQuickWebEngineSettings::setFocusOnNavigationEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::FocusOnNavigationEnabled); - d_ptr->setAttribute(WebEngineSettings::FocusOnNavigationEnabled, on); - if (wasOn != on) - Q_EMIT focusOnNavigationEnabledChanged(); -} - - -void QQuickWebEngineSettings::setAllowRunningInsecureContent(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::AllowRunningInsecureContent); - d_ptr->setAttribute(WebEngineSettings::AllowRunningInsecureContent, on); - if (wasOn != on) - Q_EMIT allowRunningInsecureContentChanged(); -} - -void QQuickWebEngineSettings::setAllowGeolocationOnInsecureOrigins(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::AllowGeolocationOnInsecureOrigins); - d_ptr->setAttribute(WebEngineSettings::AllowGeolocationOnInsecureOrigins, on); - if (wasOn != on) - Q_EMIT allowGeolocationOnInsecureOriginsChanged(); -} - -void QQuickWebEngineSettings::setAllowWindowActivationFromJavaScript(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::AllowWindowActivationFromJavaScript); - d_ptr->setAttribute(WebEngineSettings::AllowWindowActivationFromJavaScript, on); - if (wasOn != on) - Q_EMIT allowWindowActivationFromJavaScriptChanged(); -} - -void QQuickWebEngineSettings::setShowScrollBars(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::ShowScrollBars); - d_ptr->setAttribute(WebEngineSettings::ShowScrollBars, on); - if (wasOn != on) - Q_EMIT showScrollBarsChanged(); -} - -void QQuickWebEngineSettings::setPlaybackRequiresUserGesture(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::PlaybackRequiresUserGesture); - d_ptr->setAttribute(WebEngineSettings::PlaybackRequiresUserGesture, on); - if (wasOn != on) - Q_EMIT playbackRequiresUserGestureChanged(); -} - -void QQuickWebEngineSettings::setJavascriptCanPaste(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptCanPaste); - d_ptr->setAttribute(WebEngineSettings::JavascriptCanPaste, on); - if (wasOn != on) - Q_EMIT javascriptCanPasteChanged(); -} - -void QQuickWebEngineSettings::setDnsPrefetchEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::DnsPrefetchEnabled); - d_ptr->setAttribute(WebEngineSettings::DnsPrefetchEnabled, on); - if (wasOn != on) - Q_EMIT dnsPrefetchEnabledChanged(); -} - -void QQuickWebEngineSettings::setPdfViewerEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::PdfViewerEnabled); - d_ptr->setAttribute(WebEngineSettings::PdfViewerEnabled, on); - if (wasOn != on) - Q_EMIT pdfViewerEnabledChanged(); -} - -void QQuickWebEngineSettings::setUnknownUrlSchemePolicy(QQuickWebEngineSettings::UnknownUrlSchemePolicy policy) -{ - WebEngineSettings::UnknownUrlSchemePolicy oldPolicy = d_ptr->unknownUrlSchemePolicy(); - WebEngineSettings::UnknownUrlSchemePolicy newPolicy = static_cast<WebEngineSettings::UnknownUrlSchemePolicy>(policy); - d_ptr->setUnknownUrlSchemePolicy(newPolicy); - if (oldPolicy != newPolicy) - Q_EMIT unknownUrlSchemePolicyChanged(); -} - -void QQuickWebEngineSettings::setWebRTCPublicInterfacesOnly(bool on) -{ - bool wasOn = d_ptr->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly); - d_ptr->setAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly, on); - if (wasOn != on) - Q_EMIT webRTCPublicInterfacesOnlyChanged(); -} - -void QQuickWebEngineSettings::setParentSettings(QQuickWebEngineSettings *parentSettings) -{ - d_ptr->setParentSettings(parentSettings->d_ptr.data()); - d_ptr->scheduleApplyRecursively(); -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h deleted file mode 100644 index ce43e0e9c..000000000 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ /dev/null @@ -1,219 +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 QQUICKWEBENGINESETTINGS_P_H -#define QQUICKWEBENGINESETTINGS_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 <QtWebEngine/private/qtwebengineglobal_p.h> -#include <QObject> -#include <QScopedPointer> - -namespace QtWebEngineCore { -class WebEngineSettings; -} - -QT_BEGIN_NAMESPACE - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject { - Q_OBJECT - Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages NOTIFY autoLoadImagesChanged FINAL) - Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled NOTIFY javascriptEnabledChanged FINAL) - Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows NOTIFY javascriptCanOpenWindowsChanged FINAL) - Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard NOTIFY javascriptCanAccessClipboardChanged FINAL) - Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain NOTIFY linksIncludedInFocusChainChanged FINAL) - Q_PROPERTY(bool localStorageEnabled READ localStorageEnabled WRITE setLocalStorageEnabled NOTIFY localStorageEnabledChanged FINAL) - Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls NOTIFY localContentCanAccessRemoteUrlsChanged FINAL) - Q_PROPERTY(bool spatialNavigationEnabled READ spatialNavigationEnabled WRITE setSpatialNavigationEnabled NOTIFY spatialNavigationEnabledChanged FINAL) - Q_PROPERTY(bool localContentCanAccessFileUrls READ localContentCanAccessFileUrls WRITE setLocalContentCanAccessFileUrls NOTIFY localContentCanAccessFileUrlsChanged FINAL) - Q_PROPERTY(bool hyperlinkAuditingEnabled READ hyperlinkAuditingEnabled WRITE setHyperlinkAuditingEnabled NOTIFY hyperlinkAuditingEnabledChanged FINAL) - Q_PROPERTY(bool errorPageEnabled READ errorPageEnabled WRITE setErrorPageEnabled NOTIFY errorPageEnabledChanged FINAL) - Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled NOTIFY pluginsEnabledChanged FINAL) - Q_PROPERTY(bool fullScreenSupportEnabled READ fullScreenSupportEnabled WRITE setFullScreenSupportEnabled NOTIFY fullScreenSupportEnabledChanged REVISION 1 FINAL) - Q_PROPERTY(QString defaultTextEncoding READ defaultTextEncoding WRITE setDefaultTextEncoding NOTIFY defaultTextEncodingChanged FINAL) - Q_PROPERTY(bool screenCaptureEnabled READ screenCaptureEnabled WRITE setScreenCaptureEnabled NOTIFY screenCaptureEnabledChanged REVISION 2 FINAL) - Q_PROPERTY(bool webGLEnabled READ webGLEnabled WRITE setWebGLEnabled NOTIFY webGLEnabledChanged REVISION 2 FINAL) - Q_PROPERTY(bool accelerated2dCanvasEnabled READ accelerated2dCanvasEnabled WRITE setAccelerated2dCanvasEnabled NOTIFY accelerated2dCanvasEnabledChanged REVISION 2 FINAL) - Q_PROPERTY(bool autoLoadIconsForPage READ autoLoadIconsForPage WRITE setAutoLoadIconsForPage NOTIFY autoLoadIconsForPageChanged REVISION 2 FINAL) - Q_PROPERTY(bool touchIconsEnabled READ touchIconsEnabled WRITE setTouchIconsEnabled NOTIFY touchIconsEnabledChanged REVISION 2 FINAL) - Q_PROPERTY(bool focusOnNavigationEnabled READ focusOnNavigationEnabled WRITE setFocusOnNavigationEnabled NOTIFY focusOnNavigationEnabledChanged REVISION 3 FINAL) - Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds NOTIFY printElementBackgroundsChanged REVISION 3 FINAL) - Q_PROPERTY(bool allowRunningInsecureContent READ allowRunningInsecureContent WRITE setAllowRunningInsecureContent NOTIFY allowRunningInsecureContentChanged REVISION 3 FINAL) - Q_PROPERTY(bool allowGeolocationOnInsecureOrigins READ allowGeolocationOnInsecureOrigins WRITE setAllowGeolocationOnInsecureOrigins NOTIFY allowGeolocationOnInsecureOriginsChanged REVISION 4 FINAL) - Q_PROPERTY(bool allowWindowActivationFromJavaScript READ allowWindowActivationFromJavaScript WRITE setAllowWindowActivationFromJavaScript NOTIFY allowWindowActivationFromJavaScriptChanged REVISION 5 FINAL) - Q_PROPERTY(bool showScrollBars READ showScrollBars WRITE setShowScrollBars NOTIFY showScrollBarsChanged REVISION 5 FINAL) - Q_PROPERTY(UnknownUrlSchemePolicy unknownUrlSchemePolicy READ unknownUrlSchemePolicy WRITE setUnknownUrlSchemePolicy NOTIFY unknownUrlSchemePolicyChanged REVISION 6 FINAL) - Q_PROPERTY(bool playbackRequiresUserGesture READ playbackRequiresUserGesture WRITE setPlaybackRequiresUserGesture NOTIFY playbackRequiresUserGestureChanged REVISION 6 FINAL) - Q_PROPERTY(bool webRTCPublicInterfacesOnly READ webRTCPublicInterfacesOnly WRITE setWebRTCPublicInterfacesOnly NOTIFY webRTCPublicInterfacesOnlyChanged REVISION 6 FINAL) - Q_PROPERTY(bool javascriptCanPaste READ javascriptCanPaste WRITE setJavascriptCanPaste NOTIFY javascriptCanPasteChanged REVISION 6 FINAL) - Q_PROPERTY(bool dnsPrefetchEnabled READ dnsPrefetchEnabled WRITE setDnsPrefetchEnabled NOTIFY dnsPrefetchEnabledChanged REVISION 7 FINAL) - Q_PROPERTY(bool pdfViewerEnabled READ pdfViewerEnabled WRITE setPdfViewerEnabled NOTIFY pdfViewerEnabledChanged REVISION 8 FINAL) - -public: - enum UnknownUrlSchemePolicy { - DisallowUnknownUrlSchemes = 1, - AllowUnknownUrlSchemesFromUserInteraction, - AllowAllUnknownUrlSchemes - }; - - Q_ENUM(UnknownUrlSchemePolicy) - - ~QQuickWebEngineSettings(); - - bool autoLoadImages() const; - bool javascriptEnabled() const; - bool javascriptCanOpenWindows() const; - bool javascriptCanAccessClipboard() const; - bool linksIncludedInFocusChain() const; - bool localStorageEnabled() const; - bool localContentCanAccessRemoteUrls() const; - bool spatialNavigationEnabled() const; - bool localContentCanAccessFileUrls() const; - bool hyperlinkAuditingEnabled() const; - bool errorPageEnabled() const; - bool pluginsEnabled() const; - bool fullScreenSupportEnabled() const; - QString defaultTextEncoding() const; - bool screenCaptureEnabled() const; - bool webGLEnabled() const; - bool accelerated2dCanvasEnabled() const; - bool autoLoadIconsForPage() const; - bool touchIconsEnabled() const; - bool focusOnNavigationEnabled() const; - bool printElementBackgrounds() const; - bool allowRunningInsecureContent() const; - bool allowGeolocationOnInsecureOrigins() const; - bool allowWindowActivationFromJavaScript() const; - bool showScrollBars() const; - UnknownUrlSchemePolicy unknownUrlSchemePolicy() const; - bool playbackRequiresUserGesture() const; - bool webRTCPublicInterfacesOnly() const; - bool javascriptCanPaste() const; - bool dnsPrefetchEnabled() const; - bool pdfViewerEnabled() const; - - void setAutoLoadImages(bool on); - void setJavascriptEnabled(bool on); - void setJavascriptCanOpenWindows(bool on); - void setJavascriptCanAccessClipboard(bool on); - void setLinksIncludedInFocusChain(bool on); - void setLocalStorageEnabled(bool on); - void setLocalContentCanAccessRemoteUrls(bool on); - void setSpatialNavigationEnabled(bool on); - void setLocalContentCanAccessFileUrls(bool on); - void setHyperlinkAuditingEnabled(bool on); - void setErrorPageEnabled(bool on); - void setPluginsEnabled(bool on); - void setFullScreenSupportEnabled(bool on); - void setDefaultTextEncoding(QString encoding); - void setScreenCaptureEnabled(bool on); - void setWebGLEnabled(bool on); - void setAccelerated2dCanvasEnabled(bool on); - void setAutoLoadIconsForPage(bool on); - void setTouchIconsEnabled(bool on); - void setFocusOnNavigationEnabled(bool on); - void setPrintElementBackgrounds(bool on); - void setAllowRunningInsecureContent(bool on); - void setAllowGeolocationOnInsecureOrigins(bool on); - void setAllowWindowActivationFromJavaScript(bool on); - void setShowScrollBars(bool on); - void setUnknownUrlSchemePolicy(UnknownUrlSchemePolicy policy); - void setPlaybackRequiresUserGesture(bool on); - void setWebRTCPublicInterfacesOnly(bool on); - void setJavascriptCanPaste(bool on); - void setDnsPrefetchEnabled(bool on); - void setPdfViewerEnabled(bool on); - -signals: - void autoLoadImagesChanged(); - void javascriptEnabledChanged(); - void javascriptCanOpenWindowsChanged(); - void javascriptCanAccessClipboardChanged(); - void linksIncludedInFocusChainChanged(); - void localStorageEnabledChanged(); - void localContentCanAccessRemoteUrlsChanged(); - void spatialNavigationEnabledChanged(); - void localContentCanAccessFileUrlsChanged(); - void hyperlinkAuditingEnabledChanged(); - void errorPageEnabledChanged(); - void pluginsEnabledChanged(); - Q_REVISION(1) void fullScreenSupportEnabledChanged(); - void defaultTextEncodingChanged(); - Q_REVISION(2) void screenCaptureEnabledChanged(); - Q_REVISION(2) void webGLEnabledChanged(); - Q_REVISION(2) void accelerated2dCanvasEnabledChanged(); - Q_REVISION(2) void autoLoadIconsForPageChanged(); - Q_REVISION(2) void touchIconsEnabledChanged(); - Q_REVISION(3) void focusOnNavigationEnabledChanged(); - Q_REVISION(3) void printElementBackgroundsChanged(); - Q_REVISION(3) void allowRunningInsecureContentChanged(); - Q_REVISION(4) void allowGeolocationOnInsecureOriginsChanged(); - Q_REVISION(5) void allowWindowActivationFromJavaScriptChanged(); - Q_REVISION(5) void showScrollBarsChanged(); - Q_REVISION(6) void unknownUrlSchemePolicyChanged(); - Q_REVISION(6) void playbackRequiresUserGestureChanged(); - Q_REVISION(6) void webRTCPublicInterfacesOnlyChanged(); - Q_REVISION(6) void javascriptCanPasteChanged(); - Q_REVISION(7) void dnsPrefetchEnabledChanged(); - Q_REVISION(8) void pdfViewerEnabledChanged(); - -private: - explicit QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings = 0); - Q_DISABLE_COPY(QQuickWebEngineSettings) - friend class QQuickWebEngineProfilePrivate; - friend class QQuickWebEngineViewPrivate; - friend class QQuickWebEngineView; - void setParentSettings(QQuickWebEngineSettings *parentSettings); - - QScopedPointer<QtWebEngineCore::WebEngineSettings> d_ptr; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINESETTINGS_P_H diff --git a/src/webengine/api/qquickwebenginesingleton.cpp b/src/webengine/api/qquickwebenginesingleton.cpp deleted file mode 100644 index 3e84f5cf0..000000000 --- a/src/webengine/api/qquickwebenginesingleton.cpp +++ /dev/null @@ -1,93 +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 "qquickwebenginesingleton_p.h" - -#include "qquickwebenginesettings_p.h" -#include <QtWebEngine/QQuickWebEngineProfile> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype WebEngine - \instantiates QQuickWebEngineSingleton - \inqmlmodule QtWebEngine - \since QtWebEngine 1.1 - \brief Provides access to the default settings and profiles shared by all web engine views. - - The WebEngine singleton type provides access to the default profile and the default settings - shared by all web engine views. It can be used to change settings globally, as illustrated by - the following code snippet: - - \code - Component.onCompleted: { - WebEngine.settings.pluginsEnabled = true; - } - \endcode -*/ - -/*! - \qmlproperty WebEngineSettings WebEngine::settings - \readonly - \since QtWebEngine 1.1 - - Default settings for all web engine views. - - \sa WebEngineSettings -*/ -QQuickWebEngineSettings *QQuickWebEngineSingleton::settings() const -{ - return defaultProfile()->settings(); -} - -/*! - \qmlproperty WebEngineProfile WebEngine::defaultProfile - \readonly - \since QtWebEngine 1.1 - - Default profile for all web engine views. - - \sa WebEngineProfile -*/ -QQuickWebEngineProfile *QQuickWebEngineSingleton::defaultProfile() const -{ - return QQuickWebEngineProfile::defaultProfile(); -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginesingleton_p.h b/src/webengine/api/qquickwebenginesingleton_p.h deleted file mode 100644 index ba63382e5..000000000 --- a/src/webengine/api/qquickwebenginesingleton_p.h +++ /dev/null @@ -1,72 +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 QQUICKWEBENGINESINGLETON_P_H -#define QQUICKWEBENGINESINGLETON_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 <QtWebEngine/private/qtwebengineglobal_p.h> -#include <QObject> - -QT_BEGIN_NAMESPACE -class QQuickWebEngineProfile; -class QQuickWebEngineSettings; -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSingleton : public QObject { - Q_OBJECT - Q_PROPERTY(QQuickWebEngineSettings* settings READ settings CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineProfile* defaultProfile READ defaultProfile CONSTANT FINAL REVISION 1) - -public: - QQuickWebEngineSettings *settings() const; - QQuickWebEngineProfile *defaultProfile() const; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINESINGLETON_P_H diff --git a/src/webengine/api/qquickwebenginetestsupport.cpp b/src/webengine/api/qquickwebenginetestsupport.cpp deleted file mode 100644 index bef87160e..000000000 --- a/src/webengine/api/qquickwebenginetestsupport.cpp +++ /dev/null @@ -1,193 +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 "qquickwebenginetestsupport_p.h" - -#include "qquickwebengineloadrequest_p.h" -#include <QQuickWindow> -#include <QtTest/qtest.h> -#include <QtCore/QTimer> - -QT_BEGIN_NAMESPACE - -namespace QTest { - int Q_TESTLIB_EXPORT defaultMouseDelay(); -} - -QQuickWebEngineErrorPage::QQuickWebEngineErrorPage() -{ -} - -void QQuickWebEngineErrorPage::loadFinished(bool success, const QUrl &url) -{ - Q_UNUSED(success); - QTimer::singleShot(0, this, [this, url]() { - QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadSucceededStatus); - emit loadingChanged(&loadRequest); - }); -} - -void QQuickWebEngineErrorPage::loadStarted(const QUrl &provisionalUrl) -{ - QTimer::singleShot(0, this, [this, provisionalUrl]() { - QQuickWebEngineLoadRequest loadRequest(provisionalUrl, QQuickWebEngineView::LoadStartedStatus); - emit loadingChanged(&loadRequest); - }); -} - -QQuickWebEngineTestInputContext::QQuickWebEngineTestInputContext() - : m_visible(false) -{ -} - -QQuickWebEngineTestInputContext::~QQuickWebEngineTestInputContext() -{ - release(); -} - -void QQuickWebEngineTestInputContext::create() -{ - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = this; -} - -void QQuickWebEngineTestInputContext::release() -{ - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = 0; -} - -void QQuickWebEngineTestInputContext::showInputPanel() -{ - m_visible = true; -} - -void QQuickWebEngineTestInputContext::hideInputPanel() -{ - m_visible = false; -} - -bool QQuickWebEngineTestInputContext::isInputPanelVisible() const -{ - return m_visible; -} - - -QQuickWebEngineTestEvent::QQuickWebEngineTestEvent() -{ -} - -bool QQuickWebEngineTestEvent::mouseMultiClick(QObject *item, qreal x, qreal y, int clickCount) -{ - QTEST_ASSERT(item); - - QWindow *view = eventWindow(item); - if (!view) - return false; - - for (int i = 0; i < clickCount; ++i) { - mouseEvent(QMouseEvent::MouseButtonPress, view, item, QPointF(x, y)); - mouseEvent(QMouseEvent::MouseButtonRelease, view, item, QPointF(x, y)); - } - QTest::lastMouseTimestamp += QTest::mouseDoubleClickInterval; - - return true; -} - -QWindow *QQuickWebEngineTestEvent::eventWindow(QObject *item) -{ - QWindow *window = qobject_cast<QWindow *>(item); - if (window) - return window; - - QQuickItem *quickItem = qobject_cast<QQuickItem *>(item); - if (quickItem) - return quickItem->window(); - - QQuickItem *testParentItem = qobject_cast<QQuickItem *>(parent()); - if (testParentItem) - return testParentItem->window(); - - return nullptr; -} - -void QQuickWebEngineTestEvent::mouseEvent(QEvent::Type type, QWindow *window, QObject *item, const QPointF &_pos) -{ - QTest::qWait(QTest::defaultMouseDelay()); - QTest::lastMouseTimestamp += QTest::defaultMouseDelay(); - - QPoint pos; - QQuickItem *sgitem = qobject_cast<QQuickItem *>(item); - if (sgitem) - pos = sgitem->mapToScene(_pos).toPoint(); - - QMouseEvent me(type, pos, window->mapFromGlobal(pos), Qt::LeftButton, Qt::LeftButton, {}); - me.setTimestamp(++QTest::lastMouseTimestamp); - - QSpontaneKeyEvent::setSpontaneous(&me); - if (!qApp->notify(window, &me)) - QTest::qWarn("Mouse click event not accepted by receiving window"); -} - - -QQuickWebEngineTestSupport::QQuickWebEngineTestSupport() - : m_errorPage(new QQuickWebEngineErrorPage) - , m_testInputContext(new QQuickWebEngineTestInputContext) - , m_testEvent(new QQuickWebEngineTestEvent) -{ -} - -QQuickWebEngineErrorPage *QQuickWebEngineTestSupport::errorPage() const -{ - return m_errorPage.data(); -} - -QQuickWebEngineTestInputContext *QQuickWebEngineTestSupport::testInputContext() const -{ - return m_testInputContext.data(); -} - -QQuickWebEngineTestEvent * QQuickWebEngineTestSupport::testEvent() const -{ - return m_testEvent.data(); -} - -QT_END_NAMESPACE - -#include "moc_qquickwebenginetestsupport_p.cpp" diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webengine/api/qquickwebenginetestsupport_p.h deleted file mode 100644 index 89a997b29..000000000 --- a/src/webengine/api/qquickwebenginetestsupport_p.h +++ /dev/null @@ -1,135 +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 QQUICKWEBENGINETESTSUPPORT_P_H -#define QQUICKWEBENGINETESTSUPPORT_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 <QtGui/private/qinputmethod_p.h> -#include <QtWebEngine/private/qtwebengineglobal_p.h> - -#include <QEvent> -#include <QObject> -#include <QUrl> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineLoadRequest; -class QWindow; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineErrorPage : public QObject { - Q_OBJECT - -public: - QQuickWebEngineErrorPage(); - - void loadFinished(bool success, const QUrl &url); - void loadStarted(const QUrl &provisionalUrl); - -Q_SIGNALS: - void loadingChanged(QQuickWebEngineLoadRequest *loadRequest); -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTestInputContext : public QPlatformInputContext { - Q_OBJECT - -public: - QQuickWebEngineTestInputContext(); - ~QQuickWebEngineTestInputContext(); - - Q_INVOKABLE void create(); - Q_INVOKABLE void release(); - - void showInputPanel() override; - void hideInputPanel() override; - bool isInputPanelVisible() const override; - -private: - bool m_visible; -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTestEvent : public QObject { - Q_OBJECT - -public: - QQuickWebEngineTestEvent(); - -public Q_SLOTS: - bool mouseMultiClick(QObject *item, qreal x, qreal y, int clickCount); - -private: - QWindow *eventWindow(QObject *item = 0); - void mouseEvent(QEvent::Type type, QWindow *window, QObject *item, const QPointF &_pos); -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTestSupport : public QObject { - Q_OBJECT - Q_PROPERTY(QQuickWebEngineErrorPage *errorPage READ errorPage CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineTestInputContext *testInputContext READ testInputContext CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineTestEvent *testEvent READ testEvent CONSTANT FINAL) - -public: - QQuickWebEngineTestSupport(); - QQuickWebEngineErrorPage *errorPage() const; - QQuickWebEngineTestInputContext *testInputContext() const; - QQuickWebEngineTestEvent *testEvent() const; - -Q_SIGNALS: - void windowCloseRejected(); - void loadVisuallyCommitted(); - -private: - QScopedPointer<QQuickWebEngineErrorPage> m_errorPage; - QScopedPointer<QQuickWebEngineTestInputContext> m_testInputContext; - QScopedPointer<QQuickWebEngineTestEvent> m_testEvent; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINETESTSUPPORT_P_H diff --git a/src/webengine/api/qquickwebenginetouchhandleprovider.cpp b/src/webengine/api/qquickwebenginetouchhandleprovider.cpp deleted file mode 100644 index 80f4727b6..000000000 --- a/src/webengine/api/qquickwebenginetouchhandleprovider.cpp +++ /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$ -** -****************************************************************************/ - -#include "qquickwebenginetouchhandleprovider_p_p.h" - -// static -QString QQuickWebEngineTouchHandleProvider::identifier() -{ - return QStringLiteral("touchhandle"); -} - -// static -QUrl QQuickWebEngineTouchHandleProvider::url(int orientation) -{ - return QUrl(QStringLiteral("image://%1/%2").arg(identifier(), QString::number(orientation))); -} - -QQuickWebEngineTouchHandleProvider::QQuickWebEngineTouchHandleProvider() - : QQuickImageProvider(QQuickImageProvider::Image) -{ -} - -QQuickWebEngineTouchHandleProvider::~QQuickWebEngineTouchHandleProvider() -{ -} - -void QQuickWebEngineTouchHandleProvider::init(const QMap<int, QImage> &images) -{ - if (!m_touchHandleMap.empty()) { - Q_ASSERT(images.size() == m_touchHandleMap.size()); - return; - } - - m_touchHandleMap.unite(images); -} - -QImage QQuickWebEngineTouchHandleProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) -{ - Q_UNUSED(size); - Q_UNUSED(requestedSize); - - Q_ASSERT(m_touchHandleMap.contains(id.toInt())); - return m_touchHandleMap.value(id.toInt()); -} diff --git a/src/webengine/api/qquickwebenginetouchhandleprovider_p_p.h b/src/webengine/api/qquickwebenginetouchhandleprovider_p_p.h deleted file mode 100644 index 5379a5729..000000000 --- a/src/webengine/api/qquickwebenginetouchhandleprovider_p_p.h +++ /dev/null @@ -1,77 +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 QQUICKWEBENGINETOUCHHANDLEPROVIDER_P_P_H -#define QQUICKWEBENGINETOUCHHANDLEPROVIDER_P_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 <QtQuick/QQuickImageProvider> -#include <QtWebEngine/private/qtwebengineglobal_p.h> - -QT_BEGIN_NAMESPACE - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTouchHandleProvider : public QQuickImageProvider { -public: - static QString identifier(); - static QUrl url(int orientation); - - QQuickWebEngineTouchHandleProvider(); - ~QQuickWebEngineTouchHandleProvider(); - - void init(const QMap<int, QImage> &images); - QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override; - -private: - QMap<int, QImage> m_touchHandleMap; -}; - - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINETOUCHHANDLEPROVIDER_P_P_H diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp deleted file mode 100644 index 7b875bf55..000000000 --- a/src/webengine/api/qquickwebengineview.cpp +++ /dev/null @@ -1,2500 +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 "qquickwebengineview_p.h" -#include "qquickwebengineview_p_p.h" -#include "authentication_dialog_controller.h" -#include "profile_adapter.h" -#include "certificate_error_controller.h" -#include "file_picker_controller.h" -#include "find_text_helper.h" -#include "javascript_dialog_controller.h" -#include "touch_selection_menu_controller.h" - -#include "qquickwebengineaction_p.h" -#include "qquickwebengineaction_p_p.h" -#include "qquickwebenginehistory_p.h" -#include "qquickwebenginecertificateerror_p.h" -#include "qquickwebengineclientcertificateselection_p.h" -#include "qquickwebenginecontextmenurequest_p.h" -#include "qquickwebenginedialogrequests_p.h" -#include "qquickwebenginefaviconprovider_p_p.h" -#include "qquickwebengineloadrequest_p.h" -#include "qquickwebenginenavigationrequest_p.h" -#include "qquickwebenginenewviewrequest_p.h" -#include "qquickwebengineprofile_p.h" -#include "qquickwebenginesettings_p.h" -#include "qquickwebenginescript_p.h" -#include "qquickwebenginetouchhandleprovider_p_p.h" -#include "qwebenginefindtextresult.h" -#include "qwebenginequotarequest.h" -#include "qwebengineregisterprotocolhandlerrequest.h" - -#if QT_CONFIG(webengine_testsupport) -#include "qquickwebenginetestsupport_p.h" -#endif - -#include "render_widget_host_view_qt_delegate_quick.h" -#include "render_widget_host_view_qt_delegate_quickwindow.h" -#include "renderer_host/user_resource_controller_host.h" -#include "ui_delegates_manager.h" -#include "web_contents_adapter.h" -#include "web_engine_error.h" -#include "web_engine_settings.h" - -#include <QClipboard> -#include <QGuiApplication> -#include <QLoggingCategory> -#include <QMarginsF> -#include <QMimeData> -#include <QPageLayout> -#include <QPageSize> -#include <QQmlComponent> -#include <QQmlContext> -#include <QQmlEngine> -#include <QQmlProperty> -#if QT_CONFIG(webengine_webchannel) -#include <QQmlWebChannel> -#endif -#include <QQuickWebEngineProfile> -#include <QScreen> -#include <QUrl> -#include <QTimer> -#include <QtGui/private/qguiapplication_p.h> -#include <QtGui/qpa/qplatformintegration.h> - -QT_BEGIN_NAMESPACE -using namespace QtWebEngineCore; - -#ifndef QT_NO_ACCESSIBILITY -static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object) -{ - if (QQuickWebEngineView *v = qobject_cast<QQuickWebEngineView*>(object)) - return new QQuickWebEngineViewAccessible(v); - return 0; -} -#endif // QT_NO_ACCESSIBILITY - -static QLatin1String defaultMimeType("text/html;charset=UTF-8"); - -QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate() - : m_profile(nullptr) - , adapter(QSharedPointer<WebContentsAdapter>::create()) - , m_history(new QQuickWebEngineHistory(this)) -#if QT_CONFIG(webengine_testsupport) - , m_testSupport(0) -#endif - , contextMenuExtraItems(0) - , faviconProvider(0) - , loadProgress(0) - , m_fullscreenMode(false) - , isLoading(false) - , m_activeFocusOnPress(true) - , devicePixelRatio(QGuiApplication::primaryScreen()->devicePixelRatio()) - , m_webChannel(0) - , m_webChannelWorld(0) - , m_defaultAudioMuted(false) - , m_isBeingAdopted(false) - , m_backgroundColor(Qt::white) - , m_zoomFactor(1.0) - , m_ui2Enabled(false) - , m_profileInitialized(false) -{ - memset(actions, 0, sizeof(actions)); - - QString platform = qApp->platformName().toLower(); - if (platform == QLatin1String("eglfs")) - m_ui2Enabled = true; - - const QByteArray dialogSet = qgetenv("QTWEBENGINE_DIALOG_SET"); - - if (!dialogSet.isEmpty()) { - if (dialogSet == QByteArrayLiteral("QtQuickControls2")) { - m_ui2Enabled = true; - } else if (dialogSet == QByteArrayLiteral("QtQuickControls1") - && m_ui2Enabled) { - m_ui2Enabled = false; - qWarning("QTWEBENGINE_DIALOG_SET=QtQuickControls1 forces use of Qt Quick Controls 1 " - "on an eglfs backend. This can crash your application!"); - } else { - qWarning("Ignoring QTWEBENGINE_DIALOG_SET environment variable set to %s. Accepted " - "values are \"QtQuickControls1\" and \"QtQuickControls2\"", dialogSet.data()); - } - } - -#ifndef QT_NO_ACCESSIBILITY - QAccessible::installFactory(&webAccessibleFactory); -#endif // QT_NO_ACCESSIBILITY -} - -QQuickWebEngineViewPrivate::~QQuickWebEngineViewPrivate() -{ - Q_ASSERT(m_profileInitialized); - m_profile->d_ptr->removeWebContentsAdapterClient(this); - if (faviconProvider) - faviconProvider->detach(q_ptr); - // q_ptr->d_ptr might be null due to destroy() - if (q_ptr->d_ptr) - bindViewAndWidget(q_ptr, nullptr); -} - -void QQuickWebEngineViewPrivate::initializeProfile() -{ - if (!m_profileInitialized) { - Q_ASSERT(!adapter->isInitialized()); - m_profileInitialized = true; - if (!m_profile) - m_profile = QQuickWebEngineProfile::defaultProfile(); - m_profile->d_ptr->addWebContentsAdapterClient(this); - m_settings.reset(new QQuickWebEngineSettings(m_profile->settings())); - adapter->setClient(this); - } -} - -bool QQuickWebEngineViewPrivate::profileInitialized() const -{ - return m_profileInitialized; -} - -void QQuickWebEngineViewPrivate::releaseProfile() -{ - // The profile for this web contents is about to be - // garbage collected, delete WebContents first and - // let the QQuickWebEngineView be collected later by gc. - bindViewAndWidget(q_ptr, nullptr); - delete q_ptr->d_ptr.take(); -} - -UIDelegatesManager *QQuickWebEngineViewPrivate::ui() -{ - Q_Q(QQuickWebEngineView); - if (m_uIDelegatesManager.isNull()) - m_uIDelegatesManager.reset(m_ui2Enabled ? new UI2DelegatesManager(q) : new UIDelegatesManager(q)); - return m_uIDelegatesManager.data(); -} - -RenderWidgetHostViewQtDelegate *QQuickWebEngineViewPrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client) -{ - return new RenderWidgetHostViewQtDelegateQuick(client, /*isPopup = */ false); -} - -RenderWidgetHostViewQtDelegate *QQuickWebEngineViewPrivate::CreateRenderWidgetHostViewQtDelegateForPopup(RenderWidgetHostViewQtDelegateClient *client) -{ - Q_Q(QQuickWebEngineView); - const bool hasWindowCapability = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MultipleWindows); - RenderWidgetHostViewQtDelegateQuick *quickDelegate = new RenderWidgetHostViewQtDelegateQuick(client, /*isPopup = */ true); - if (hasWindowCapability) { - RenderWidgetHostViewQtDelegateQuickWindow *wrapperWindow = new RenderWidgetHostViewQtDelegateQuickWindow(quickDelegate); - wrapperWindow->setVirtualParent(q); - quickDelegate->setParentItem(wrapperWindow->contentItem()); - return wrapperWindow; - } - quickDelegate->setParentItem(q); - return quickDelegate; -} - -void QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenuData &data) -{ - Q_Q(QQuickWebEngineView); - - m_contextMenuData = data; - - QQuickWebEngineContextMenuRequest *request = new QQuickWebEngineContextMenuRequest(data); - QQmlEngine *engine = qmlEngine(q); - - // TODO: this is a workaround for QTBUG-65044 - if (!engine) - return; - - // mark the object for gc by creating temporary jsvalue - engine->newQObject(request); - Q_EMIT q->contextMenuRequested(request); - - if (request->isAccepted()) - return; - - // Assign the WebEngineView as the parent of the menu, so mouse events are properly propagated - // on OSX. - QObject *menu = ui()->addMenu(q, QString(), data.position()); - if (!menu) - return; - - QQuickContextMenuBuilder contextMenuBuilder(data, q, menu); - - // Populate our menu - contextMenuBuilder.initMenu(); - - // FIXME: expose the context menu data as an attached property to make this more useful - if (contextMenuExtraItems) - contextMenuBuilder.appendExtraItems(engine); - - // Now fire the popup() method on the top level menu - ui()->showMenu(menu); -} - -void QQuickWebEngineViewPrivate::navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) -{ - Q_Q(QQuickWebEngineView); - QQuickWebEngineNavigationRequest navigationRequest(url, static_cast<QQuickWebEngineView::NavigationType>(navigationType), isMainFrame); - Q_EMIT q->navigationRequested(&navigationRequest); - - navigationRequestAction = navigationRequest.action(); - if ((navigationRequestAction == WebContentsAdapterClient::AcceptRequest) && adapter->findTextHelper()->isFindTextInProgress()) - adapter->findTextHelper()->stopFinding(); -} - -void QQuickWebEngineViewPrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> dialog) -{ - Q_Q(QQuickWebEngineView); - QQuickWebEngineJavaScriptDialogRequest *request = new QQuickWebEngineJavaScriptDialogRequest(dialog); - // mark the object for gc by creating temporary jsvalue - qmlEngine(q)->newQObject(request); - Q_EMIT q->javaScriptDialogRequested(request); - if (!request->isAccepted()) - ui()->showDialog(dialog); -} - -void QQuickWebEngineViewPrivate::allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) -{ - Q_Q(QQuickWebEngineView); - - QQuickWebEngineCertificateError *quickController = new QQuickWebEngineCertificateError(errorController); - // mark the object for gc by creating temporary jsvalue - qmlEngine(q)->newQObject(quickController); - Q_EMIT q->certificateError(quickController); - if (!quickController->overridable() || (!quickController->deferred() && !quickController->answered())) - quickController->rejectCertificate(); - else - m_certificateErrorControllers.append(errorController); -} - -void QQuickWebEngineViewPrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller) -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) - Q_Q(QQuickWebEngineView); - QQuickWebEngineClientCertificateSelection *certSelection = new QQuickWebEngineClientCertificateSelection(controller); - // mark the object for gc by creating temporary jsvalue - qmlEngine(q)->newQObject(certSelection); - Q_EMIT q->selectClientCertificate(certSelection); -#else - Q_UNUSED(controller); -#endif -} - -static QQuickWebEngineView::Feature toFeature(QtWebEngineCore::ProfileAdapter::PermissionType type) -{ - switch (type) { - case QtWebEngineCore::ProfileAdapter::NotificationPermission: - return QQuickWebEngineView::Notifications; - case QtWebEngineCore::ProfileAdapter::GeolocationPermission: - return QQuickWebEngineView::Geolocation; - default: - break; - } - Q_UNREACHABLE(); - return QQuickWebEngineView::Feature(-1); -} - - -void QQuickWebEngineViewPrivate::runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &url) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->featurePermissionRequested(url, toFeature(permission)); -} - -void QQuickWebEngineViewPrivate::showColorDialog(QSharedPointer<ColorChooserController> controller) -{ - Q_Q(QQuickWebEngineView); - QQuickWebEngineColorDialogRequest *request = new QQuickWebEngineColorDialogRequest(controller); - // mark the object for gc by creating temporary jsvalue - qmlEngine(q)->newQObject(request); - Q_EMIT q->colorDialogRequested(request); - if (!request->isAccepted()) - ui()->showColorDialog(controller); -} - -void QQuickWebEngineViewPrivate::runFileChooser(QSharedPointer<FilePickerController> controller) -{ - Q_Q(QQuickWebEngineView); - QQuickWebEngineFileDialogRequest *request = new QQuickWebEngineFileDialogRequest(controller); - // mark the object for gc by creating temporary jsvalue - qmlEngine(q)->newQObject(request); - Q_EMIT q->fileDialogRequested(request); - if (!request->isAccepted()) - ui()->showFilePicker(controller); -} - -bool QQuickWebEngineViewPrivate::passOnFocus(bool reverse) -{ - Q_Q(QQuickWebEngineView); - // The child delegate currently has focus, find the next one from there and give it focus. - QQuickItem *next = q->scopedFocusItem()->nextItemInFocusChain(!reverse); - if (next) { - next->forceActiveFocus(reverse ? Qt::BacktabFocusReason : Qt::TabFocusReason); - return true; - } - return false; -} - -void QQuickWebEngineViewPrivate::titleChanged(const QString &title) -{ - Q_Q(QQuickWebEngineView); - Q_UNUSED(title); - Q_EMIT q->titleChanged(); -} - -void QQuickWebEngineViewPrivate::urlChanged() -{ - Q_Q(QQuickWebEngineView); - QUrl url = adapter->activeUrl(); - if (m_url != url) { - m_url = url; - Q_EMIT q->urlChanged(); - } -} - -void QQuickWebEngineViewPrivate::iconChanged(const QUrl &url) -{ - Q_Q(QQuickWebEngineView); - - if (iconUrl == QQuickWebEngineFaviconProvider::faviconProviderUrl(url)) - return; - - if (!faviconProvider) { - QQmlEngine *engine = qmlEngine(q); - - // TODO: this is a workaround for QTBUG-65044 - if (!engine) - return; - - Q_ASSERT(engine); - faviconProvider = static_cast<QQuickWebEngineFaviconProvider *>( - engine->imageProvider(QQuickWebEngineFaviconProvider::identifier())); - Q_ASSERT(faviconProvider); - } - - iconUrl = faviconProvider->attach(q, url); - m_history->reset(); - QTimer::singleShot(0, q, &QQuickWebEngineView::iconChanged); -} - -void QQuickWebEngineViewPrivate::loadProgressChanged(int progress) -{ - Q_Q(QQuickWebEngineView); - loadProgress = progress; - QTimer::singleShot(0, q, &QQuickWebEngineView::loadProgressChanged); -} - -void QQuickWebEngineViewPrivate::didUpdateTargetURL(const QUrl &hoveredUrl) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->linkHovered(hoveredUrl); -} - -void QQuickWebEngineViewPrivate::selectionChanged() -{ - updateEditActions(); -} - -void QQuickWebEngineViewPrivate::recentlyAudibleChanged(bool recentlyAudible) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->recentlyAudibleChanged(recentlyAudible); -} - -void QQuickWebEngineViewPrivate::renderProcessPidChanged(qint64 pid) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->renderProcessPidChanged(pid); -} - -QRectF QQuickWebEngineViewPrivate::viewportRect() const -{ - Q_Q(const QQuickWebEngineView); - return QRectF(q->x(), q->y(), q->width(), q->height()); -} - -QColor QQuickWebEngineViewPrivate::backgroundColor() const -{ - return m_backgroundColor; -} - -void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl, bool isErrorPage) -{ - Q_Q(QQuickWebEngineView); - if (isErrorPage) { -#if QT_CONFIG(webengine_testsupport) - if (m_testSupport) - m_testSupport->errorPage()->loadStarted(provisionalUrl); -#endif - return; - } - - isLoading = true; - m_history->reset(); - m_certificateErrorControllers.clear(); - - QTimer::singleShot(0, q, [q, provisionalUrl]() { - QQuickWebEngineLoadRequest loadRequest(provisionalUrl, QQuickWebEngineView::LoadStartedStatus); - - emit q->loadingChanged(&loadRequest); - }); -} - -void QQuickWebEngineViewPrivate::loadCommitted() -{ - m_history->reset(); -} - -void QQuickWebEngineViewPrivate::loadVisuallyCommitted() -{ -#if QT_CONFIG(webengine_testsupport) - if (m_testSupport) - Q_EMIT m_testSupport->loadVisuallyCommitted(); -#endif -} - -Q_STATIC_ASSERT(static_cast<int>(WebEngineError::NoErrorDomain) == static_cast<int>(QQuickWebEngineView::NoErrorDomain)); -Q_STATIC_ASSERT(static_cast<int>(WebEngineError::CertificateErrorDomain) == static_cast<int>(QQuickWebEngineView::CertificateErrorDomain)); -Q_STATIC_ASSERT(static_cast<int>(WebEngineError::DnsErrorDomain) == static_cast<int>(QQuickWebEngineView::DnsErrorDomain)); - -void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription) -{ - Q_Q(QQuickWebEngineView); - - if (isErrorPage) { -#if QT_CONFIG(webengine_testsupport) - if (m_testSupport) - m_testSupport->errorPage()->loadFinished(success, url); -#endif - return; - } - - isLoading = false; - m_history->reset(); - if (errorCode == WebEngineError::UserAbortedError) { - QTimer::singleShot(0, q, [q, url]() { - QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadStoppedStatus); - emit q->loadingChanged(&loadRequest); - }); - return; - } - if (success) { - QTimer::singleShot(0, q, [q, url, errorDescription, errorCode]() { - QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadSucceededStatus, errorDescription, errorCode); - emit q->loadingChanged(&loadRequest); - }); - return; - } - - Q_ASSERT(errorCode); - QQuickWebEngineView::ErrorDomain errorDomain = static_cast<QQuickWebEngineView::ErrorDomain>(WebEngineError::toQtErrorDomain(errorCode)); - QTimer::singleShot(0, q, [q, url, errorDescription, errorCode, errorDomain]() { - QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadFailedStatus,errorDescription, errorCode, errorDomain); - emit q->loadingChanged(&loadRequest); - }); - return; -} - -void QQuickWebEngineViewPrivate::focusContainer() -{ - Q_Q(QQuickWebEngineView); - QQuickWindow *window = q->window(); - if (window) - window->requestActivate(); - q->forceActiveFocus(); -} - -void QQuickWebEngineViewPrivate::unhandledKeyEvent(QKeyEvent *event) -{ - Q_Q(QQuickWebEngineView); - if (q->parentItem()) - QCoreApplication::sendEvent(q->parentItem(), event); -} - -QSharedPointer<WebContentsAdapter> -QQuickWebEngineViewPrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, - WindowOpenDisposition disposition, bool userGesture, - const QRect &, const QUrl &targetUrl) -{ - Q_Q(QQuickWebEngineView); - Q_ASSERT(newWebContents); - QQuickWebEngineNewViewRequest request; - request.m_adapter = newWebContents; - request.m_isUserInitiated = userGesture; - request.m_requestedUrl = targetUrl; - - switch (disposition) { - case WebContentsAdapterClient::NewForegroundTabDisposition: - request.m_destination = QQuickWebEngineView::NewViewInTab; - break; - case WebContentsAdapterClient::NewBackgroundTabDisposition: - request.m_destination = QQuickWebEngineView::NewViewInBackgroundTab; - break; - case WebContentsAdapterClient::NewPopupDisposition: - request.m_destination = QQuickWebEngineView::NewViewInDialog; - break; - case WebContentsAdapterClient::NewWindowDisposition: - request.m_destination = QQuickWebEngineView::NewViewInWindow; - break; - default: - Q_UNREACHABLE(); - } - - Q_EMIT q->newViewRequested(&request); - - if (!request.m_isRequestHandled) - return nullptr; - - return newWebContents; -} - -bool QQuickWebEngineViewPrivate::isBeingAdopted() -{ - return false; -} - -void QQuickWebEngineViewPrivate::close() -{ - Q_Q(QQuickWebEngineView); - emit q->windowCloseRequested(); -} - -void QQuickWebEngineViewPrivate::windowCloseRejected() -{ -#if QT_CONFIG(webengine_testsupport) - if (m_testSupport) - Q_EMIT m_testSupport->windowCloseRejected(); -#endif -} - -void QQuickWebEngineViewPrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen) -{ - Q_Q(QQuickWebEngineView); - QQuickWebEngineFullScreenRequest request(this, origin, fullscreen); - Q_EMIT q->fullScreenRequested(request); -} - -bool QQuickWebEngineViewPrivate::isFullScreenMode() const -{ - return m_fullscreenMode; -} - -void QQuickWebEngineViewPrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) -{ - Q_Q(QQuickWebEngineView); - if (q->receivers(SIGNAL(javaScriptConsoleMessage(JavaScriptConsoleMessageLevel,QString,int,QString))) > 0) { - Q_EMIT q->javaScriptConsoleMessage(static_cast<QQuickWebEngineView::JavaScriptConsoleMessageLevel>(level), message, lineNumber, sourceID); - return; - } - - static QLoggingCategory loggingCategory("js", QtWarningMsg); - const QByteArray file = sourceID.toUtf8(); - QMessageLogger logger(file.constData(), lineNumber, nullptr, loggingCategory.categoryName()); - - switch (level) { - case JavaScriptConsoleMessageLevel::Info: - if (loggingCategory.isInfoEnabled()) - logger.info().noquote() << message; - break; - case JavaScriptConsoleMessageLevel::Warning: - if (loggingCategory.isWarningEnabled()) - logger.warning().noquote() << message; - break; - case JavaScriptConsoleMessageLevel::Error: - if (loggingCategory.isCriticalEnabled()) - logger.critical().noquote() << message; - break; - } -} - -void QQuickWebEngineViewPrivate::authenticationRequired(QSharedPointer<AuthenticationDialogController> controller) -{ - Q_Q(QQuickWebEngineView); - QQuickWebEngineAuthenticationDialogRequest *request = new QQuickWebEngineAuthenticationDialogRequest(controller); - // mark the object for gc by creating temporary jsvalue - qmlEngine(q)->newQObject(request); - Q_EMIT q->authenticationDialogRequested(request); - if (!request->isAccepted()) - ui()->showDialog(controller); -} - -void QQuickWebEngineViewPrivate::runMediaAccessPermissionRequest(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags requestFlags) -{ - Q_Q(QQuickWebEngineView); - if (!requestFlags) - return; - QQuickWebEngineView::Feature feature; - if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture) && requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture)) - feature = QQuickWebEngineView::MediaAudioVideoCapture; - else if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture)) - feature = QQuickWebEngineView::MediaAudioCapture; - else if (requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture)) - feature = QQuickWebEngineView::MediaVideoCapture; - else if (requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopAudioCapture) && - requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture)) - feature = QQuickWebEngineView::DesktopAudioVideoCapture; - else // if (requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture)) - feature = QQuickWebEngineView::DesktopVideoCapture; - Q_EMIT q->featurePermissionRequested(securityOrigin, feature); -} - -void QQuickWebEngineViewPrivate::runMouseLockPermissionRequest(const QUrl &securityOrigin) -{ - // TODO: Add mouse lock support - adapter->grantMouseLockPermission(securityOrigin, false); -} - -void QQuickWebEngineViewPrivate::runQuotaRequest(QWebEngineQuotaRequest request) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->quotaRequested(request); -} - -void QQuickWebEngineViewPrivate::runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest request) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->registerProtocolHandlerRequested(request); -} - -QObject *QQuickWebEngineViewPrivate::accessibilityParentObject() -{ - Q_Q(QQuickWebEngineView); - return q; -} - -ProfileAdapter *QQuickWebEngineViewPrivate::profileAdapter() -{ - return m_profile->d_ptr->profileAdapter(); -} - -WebContentsAdapter *QQuickWebEngineViewPrivate::webContentsAdapter() -{ - return adapter.data(); -} - -void QQuickWebEngineViewPrivate::printRequested() -{ - Q_Q(QQuickWebEngineView); - QTimer::singleShot(0, q, [q]() { - Q_EMIT q->printRequested(); - }); -} - -void QQuickWebEngineViewPrivate::widgetChanged(RenderWidgetHostViewQtDelegate *newWidgetBase) -{ - Q_Q(QQuickWebEngineView); - bindViewAndWidget(q, static_cast<RenderWidgetHostViewQtDelegateQuick *>(newWidgetBase)); -} - -void QQuickWebEngineViewPrivate::findTextFinished(const QWebEngineFindTextResult &result) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->findTextFinished(result); -} - -WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const -{ - return m_settings->d_ptr.data(); -} - -const QObject *QQuickWebEngineViewPrivate::holdingQObject() const -{ - Q_Q(const QQuickWebEngineView); - return q; -} - -void QQuickWebEngineViewPrivate::lifecycleStateChanged(LifecycleState state) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->lifecycleStateChanged(static_cast<QQuickWebEngineView::LifecycleState>(state)); -} - -void QQuickWebEngineViewPrivate::recommendedStateChanged(LifecycleState state) -{ - Q_Q(QQuickWebEngineView); - QTimer::singleShot(0, q, [q, state]() { - Q_EMIT q->recommendedStateChanged(static_cast<QQuickWebEngineView::LifecycleState>(state)); - }); -} - -void QQuickWebEngineViewPrivate::visibleChanged(bool visible) -{ - Q_UNUSED(visible); -} - -#ifndef QT_NO_ACCESSIBILITY -QQuickWebEngineViewAccessible::QQuickWebEngineViewAccessible(QQuickWebEngineView *o) - : QAccessibleObject(o) -{} - -bool QQuickWebEngineViewAccessible::isValid() const -{ - if (!QAccessibleObject::isValid()) - return false; - - if (!engineView() || !engineView()->d_func()) - return false; - - return true; -} - -QAccessibleInterface *QQuickWebEngineViewAccessible::parent() const -{ - QQuickItem *parent = engineView()->parentItem(); - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parent); - if (!iface) - return QAccessible::queryAccessibleInterface(engineView()->window()); - return iface; -} - -QAccessibleInterface *QQuickWebEngineViewAccessible::focusChild() const -{ - if (child(0) && child(0)->focusChild()) - return child(0)->focusChild(); - return const_cast<QQuickWebEngineViewAccessible *>(this); -} - -int QQuickWebEngineViewAccessible::childCount() const -{ - return child(0) ? 1 : 0; -} - -QAccessibleInterface *QQuickWebEngineViewAccessible::child(int index) const -{ - if (index == 0 && isValid()) - return engineView()->d_func()->adapter->browserAccessible(); - return nullptr; -} - -int QQuickWebEngineViewAccessible::indexOfChild(const QAccessibleInterface *c) const -{ - if (child(0) && c == child(0)) - return 0; - return -1; -} - -QString QQuickWebEngineViewAccessible::text(QAccessible::Text) const -{ - return QString(); -} - -QAccessible::Role QQuickWebEngineViewAccessible::role() const -{ - return QAccessible::Client; -} - -QAccessible::State QQuickWebEngineViewAccessible::state() const -{ - QAccessible::State s; - return s; -} -#endif // QT_NO_ACCESSIBILITY - -class WebContentsAdapterOwner : public QObject -{ -public: - typedef QSharedPointer<QtWebEngineCore::WebContentsAdapter> AdapterPtr; - WebContentsAdapterOwner(const AdapterPtr &ptr) - : adapter(ptr) - {} - -private: - AdapterPtr adapter; -}; - -void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContents) -{ - if (!webContents) { - qWarning("Trying to open an empty request, it was either already used or was invalidated." - "\nYou must complete the request synchronously within the newViewRequested signal handler." - " If a view hasn't been adopted before returning, the request will be invalidated."); - return; - } - - if (webContents->profileAdapter() && profileAdapter() != webContents->profileAdapter()) { - qWarning("Can not adopt content from a different WebEngineProfile."); - return; - } - - m_isBeingAdopted = true; - - // This throws away the WebContentsAdapter that has been used until now. - // All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter. - WebContentsAdapterOwner *adapterOwner = new WebContentsAdapterOwner(adapter->sharedFromThis()); - adapterOwner->deleteLater(); - - adapter = webContents->sharedFromThis(); - adapter->setClient(this); -} - -QQuickWebEngineView::QQuickWebEngineView(QQuickItem *parent) - : QQuickItem(parent) - , d_ptr(new QQuickWebEngineViewPrivate) -{ - Q_D(QQuickWebEngineView); - d->q_ptr = this; - this->setActiveFocusOnTab(true); - this->setFlags(QQuickItem::ItemIsFocusScope | QQuickItem::ItemAcceptsDrops); -} - -QQuickWebEngineView::~QQuickWebEngineView() -{ -} - -void QQuickWebEngineViewPrivate::ensureContentsAdapter() -{ - initializeProfile(); - if (!adapter->isInitialized()) { - if (!m_html.isEmpty()) - adapter->setContent(m_html.toUtf8(), defaultMimeType, m_url); - else if (m_url.isValid()) - adapter->load(m_url); - else - adapter->loadDefault(); - } -} - -void QQuickWebEngineViewPrivate::initializationFinished() -{ - Q_Q(QQuickWebEngineView); - - Q_ASSERT(m_profileInitialized); - if (m_backgroundColor != Qt::white) { - adapter->setBackgroundColor(m_backgroundColor); - emit q->backgroundColorChanged(); - } - - if (!qFuzzyCompare(adapter->currentZoomFactor(), m_zoomFactor)) { - adapter->setZoomFactor(m_zoomFactor); - emit q->zoomFactorChanged(m_zoomFactor); - } - -#if QT_CONFIG(webengine_webchannel) - if (m_webChannel) - adapter->setWebChannel(m_webChannel, m_webChannelWorld); -#endif - - if (m_defaultAudioMuted != adapter->isAudioMuted()) - adapter->setAudioMuted(m_defaultAudioMuted); - - if (devToolsView && devToolsView->d_ptr->adapter) - adapter->openDevToolsFrontend(devToolsView->d_ptr->adapter); - - for (QQuickWebEngineScript *script : qAsConst(m_userScripts)) - script->d_func()->bind(profileAdapter()->userResourceController(), adapter.data()); - - if (q->window()) - adapter->setVisible(q->isVisible()); - - if (!m_isBeingAdopted) - return; - - // Ideally these would only be emitted if something actually changed. - emit q->titleChanged(); - emit q->urlChanged(); - emit q->iconChanged(); - QQuickWebEngineLoadRequest loadRequest(m_url, QQuickWebEngineView::LoadSucceededStatus); - emit q->loadingChanged(&loadRequest); - emit q->loadProgressChanged(); - - m_isBeingAdopted = false; -} - -void QQuickWebEngineViewPrivate::setFullScreenMode(bool fullscreen) -{ - Q_Q(QQuickWebEngineView); - if (m_fullscreenMode != fullscreen) { - m_fullscreenMode = fullscreen; - adapter->changedFullScreen(); - Q_EMIT q->isFullScreenChanged(); - } -} - -void QQuickWebEngineViewPrivate::bindViewAndWidget(QQuickWebEngineView *view, - RenderWidgetHostViewQtDelegateQuick *widget) -{ - auto oldWidget = view ? view->d_func()->widget : nullptr; - auto oldView = widget ? widget->m_view : nullptr; - - // Change pointers first. - - if (widget && oldView != view) { - if (oldView) - oldView->d_func()->widget = nullptr; - widget->m_view = view; - } - - if (view && oldWidget != widget) { - if (oldWidget) - oldWidget->m_view = nullptr; - view->d_func()->widget = widget; - } - - // Then notify. - - if (widget && oldView != view && oldView) - oldView->d_func()->widgetChanged(widget, nullptr); - - if (view && oldWidget != widget) - view->d_func()->widgetChanged(oldWidget, widget); -} - -void QQuickWebEngineViewPrivate::widgetChanged(RenderWidgetHostViewQtDelegateQuick *oldWidget, - RenderWidgetHostViewQtDelegateQuick *newWidget) -{ - Q_Q(QQuickWebEngineView); - - if (oldWidget) { - oldWidget->setParentItem(nullptr); -#if QT_CONFIG(accessibility) - QAccessible::deleteAccessibleInterface(QAccessible::uniqueId(QAccessible::queryAccessibleInterface(oldWidget))); -#endif - } - - if (newWidget) { -#if QT_CONFIG(accessibility) - QAccessible::registerAccessibleInterface(new QtWebEngineCore::RenderWidgetHostViewQtDelegateQuickAccessible(newWidget, q)); -#endif - newWidget->setParentItem(q); - newWidget->setSize(q->boundingRect().size()); - // Focus on creation if the view accepts it - if (q->activeFocusOnPress()) - newWidget->setFocus(true); - } -} - -void QQuickWebEngineViewPrivate::updateAction(QQuickWebEngineView::WebAction action) const -{ - QQuickWebEngineAction *a = actions[action]; - if (!a) - return; - - bool enabled = true; - - switch (action) { - case QQuickWebEngineView::Back: - enabled = adapter->canGoBack(); - break; - case QQuickWebEngineView::Forward: - enabled = adapter->canGoForward(); - break; - case QQuickWebEngineView::Stop: - enabled = isLoading; - break; - case QQuickWebEngineView::Reload: - case QQuickWebEngineView::ReloadAndBypassCache: - enabled = !isLoading; - break; - case QQuickWebEngineView::ViewSource: - enabled = adapter->canViewSource(); - break; - case QQuickWebEngineView::Cut: - case QQuickWebEngineView::Copy: - case QQuickWebEngineView::Unselect: - enabled = adapter->hasFocusedFrame() && !adapter->selectedText().isEmpty(); - break; - case QQuickWebEngineView::Paste: - case QQuickWebEngineView::Undo: - case QQuickWebEngineView::Redo: - case QQuickWebEngineView::SelectAll: - case QQuickWebEngineView::PasteAndMatchStyle: - enabled = adapter->hasFocusedFrame(); - break; - default: - break; - } - - a->d_ptr->setEnabled(enabled); -} - -void QQuickWebEngineViewPrivate::updateNavigationActions() -{ - updateAction(QQuickWebEngineView::Back); - updateAction(QQuickWebEngineView::Forward); - updateAction(QQuickWebEngineView::Stop); - updateAction(QQuickWebEngineView::Reload); - updateAction(QQuickWebEngineView::ReloadAndBypassCache); - updateAction(QQuickWebEngineView::ViewSource); -} - -void QQuickWebEngineViewPrivate::updateEditActions() -{ - updateAction(QQuickWebEngineView::Cut); - updateAction(QQuickWebEngineView::Copy); - updateAction(QQuickWebEngineView::Paste); - updateAction(QQuickWebEngineView::Undo); - updateAction(QQuickWebEngineView::Redo); - updateAction(QQuickWebEngineView::SelectAll); - updateAction(QQuickWebEngineView::PasteAndMatchStyle); - updateAction(QQuickWebEngineView::Unselect); -} - -QUrl QQuickWebEngineView::url() const -{ - Q_D(const QQuickWebEngineView); - return d->m_url; -} - -void QQuickWebEngineView::setUrl(const QUrl& url) -{ - Q_D(QQuickWebEngineView); - if (url.isEmpty()) - return; - - if (d->m_url != url) { - d->m_url = url; - d->m_html.clear(); - emit urlChanged(); - } - - if (d->adapter->isInitialized()) { - d->adapter->load(url); - } -} - -QUrl QQuickWebEngineView::icon() const -{ - Q_D(const QQuickWebEngineView); - return d->iconUrl; -} - -void QQuickWebEngineView::loadHtml(const QString &html, const QUrl &baseUrl) -{ - Q_D(QQuickWebEngineView); - d->m_url = baseUrl; - d->m_html = html; - if (d->adapter->isInitialized()) { - d->adapter->setContent(html.toUtf8(), defaultMimeType, baseUrl); - return; - } -} - -void QQuickWebEngineView::goBack() -{ - Q_D(QQuickWebEngineView); - d->adapter->navigateBack(); -} - -void QQuickWebEngineView::goForward() -{ - Q_D(QQuickWebEngineView); - d->adapter->navigateForward(); -} - -void QQuickWebEngineView::reload() -{ - Q_D(QQuickWebEngineView); - d->adapter->reload(); -} - -void QQuickWebEngineView::reloadAndBypassCache() -{ - Q_D(QQuickWebEngineView); - d->adapter->reloadAndBypassCache(); -} - -void QQuickWebEngineView::stop() -{ - Q_D(QQuickWebEngineView); - d->adapter->stop(); -} - -void QQuickWebEngineView::setZoomFactor(qreal arg) -{ - Q_D(QQuickWebEngineView); - if (d->adapter->isInitialized() && !qFuzzyCompare(d->m_zoomFactor, d->adapter->currentZoomFactor())) { - d->adapter->setZoomFactor(arg); - emit zoomFactorChanged(arg); - } else { - d->m_zoomFactor = arg; - } -} - -QQuickWebEngineProfile *QQuickWebEngineView::profile() -{ - Q_D(QQuickWebEngineView); - d->initializeProfile(); - return d->m_profile; -} - -void QQuickWebEngineView::setProfile(QQuickWebEngineProfile *profile) -{ - Q_D(QQuickWebEngineView); - - if (d->m_profile == profile) - return; - - if (!d->profileInitialized()) { - d->m_profile = profile; - return; - } - - if (d->m_profile) - d->m_profile->d_ptr->removeWebContentsAdapterClient(d); - - d->m_profile = profile; - d->m_profile->d_ptr->addWebContentsAdapterClient(d); - d->m_settings->setParentSettings(profile->settings()); - - d->updateAdapter(); - Q_EMIT profileChanged(); -} - -QQuickWebEngineSettings *QQuickWebEngineView::settings() -{ - Q_D(QQuickWebEngineView); - d->initializeProfile(); - return d->m_settings.data(); -} - -QQmlListProperty<QQuickWebEngineScript> QQuickWebEngineView::userScripts() -{ - Q_D(QQuickWebEngineView); - return QQmlListProperty<QQuickWebEngineScript>(this, d, - d->userScripts_append, - d->userScripts_count, - d->userScripts_at, - d->userScripts_clear); -} - -void QQuickWebEngineViewPrivate::updateAdapter() -{ - // When the profile changes we need to create a new WebContentAdapter and reload the active URL. - bool wasInitialized = adapter->isInitialized(); - adapter = QSharedPointer<WebContentsAdapter>::create(); - adapter->setClient(this); - if (wasInitialized) { - if (!m_html.isEmpty()) - adapter->setContent(m_html.toUtf8(), defaultMimeType, m_url); - else if (m_url.isValid()) - adapter->load(m_url); - else - adapter->loadDefault(); - } -} - -#if QT_CONFIG(webengine_testsupport) -QQuickWebEngineTestSupport *QQuickWebEngineView::testSupport() const -{ - Q_D(const QQuickWebEngineView); - return d->m_testSupport; -} - -void QQuickWebEngineView::setTestSupport(QQuickWebEngineTestSupport *testSupport) -{ - Q_D(QQuickWebEngineView); - d->m_testSupport = testSupport; - Q_EMIT testSupportChanged(); -} -#endif - -bool QQuickWebEngineView::activeFocusOnPress() const -{ - Q_D(const QQuickWebEngineView); - return d->m_activeFocusOnPress; -} - -void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVariant &result) -{ - Q_Q(QQuickWebEngineView); - QJSValue callback = m_callbacks.take(requestId); - QJSValueList args; - args.append(qmlEngine(q)->toScriptValue(result)); - callback.call(args); -} - -void QQuickWebEngineViewPrivate::didPrintPage(quint64 requestId, QSharedPointer<QByteArray> result) -{ - Q_Q(QQuickWebEngineView); - QJSValue callback = m_callbacks.take(requestId); - QJSValueList args; - args.append(qmlEngine(q)->toScriptValue(*(result.data()))); - callback.call(args); -} - -void QQuickWebEngineViewPrivate::didPrintPageToPdf(const QString &filePath, bool success) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->pdfPrintingFinished(filePath, success); -} - -void QQuickWebEngineViewPrivate::updateScrollPosition(const QPointF &position) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->scrollPositionChanged(position); -} - -void QQuickWebEngineViewPrivate::updateContentsSize(const QSizeF &size) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->contentsSizeChanged(size); -} - -void QQuickWebEngineViewPrivate::renderProcessTerminated( - RenderProcessTerminationStatus terminationStatus, int exitCode) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->renderProcessTerminated(static_cast<QQuickWebEngineView::RenderProcessTerminationStatus>( - renderProcessExitStatus(terminationStatus)), exitCode); -} - -void QQuickWebEngineViewPrivate::requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->geometryChangeRequested(geometry, frameGeometry); -} - -void QQuickWebEngineViewPrivate::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(q_ptr->window(), dropData, allowedActions, pixmap, offset); -#endif // QT_CONFIG(draganddrop) -} - -bool QQuickWebEngineViewPrivate::supportsDragging() const -{ - // QTBUG-57516 - // Fixme: This is just a band-aid workaround. - return QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MultipleWindows); -} - -bool QQuickWebEngineViewPrivate::isEnabled() const -{ - const Q_Q(QQuickWebEngineView); - return q->isEnabled(); -} - -void QQuickWebEngineViewPrivate::setToolTip(const QString &toolTipText) -{ - Q_Q(QQuickWebEngineView); - QQuickWebEngineTooltipRequest *request = new QQuickWebEngineTooltipRequest(toolTipText, q); - // mark the object for gc by creating temporary jsvalue - qmlEngine(q)->newQObject(request); - Q_EMIT q->tooltipRequested(request); - if (!request->isAccepted()) - ui()->showToolTip(toolTipText); -} - -QtWebEngineCore::TouchHandleDrawableClient *QQuickWebEngineViewPrivate::createTouchHandle(const QMap<int, QImage> &images) -{ - return new QQuickWebEngineTouchHandle(ui(), images); -} - -void QQuickWebEngineViewPrivate::showTouchSelectionMenu(QtWebEngineCore::TouchSelectionMenuController *menuController, const QRect &selectionBounds, const QSize &handleSize) -{ - Q_UNUSED(handleSize); - - const int kSpacingBetweenButtons = 2; - const int kMenuButtonMinWidth = 63; - const int kMenuButtonMinHeight = 38; - - int buttonCount = menuController->buttonCount(); - if (buttonCount == 1) { - menuController->runContextMenu(); - return; - } - - int width = (kSpacingBetweenButtons * (buttonCount + 1)) + (kMenuButtonMinWidth * buttonCount); - int height = kMenuButtonMinHeight + kSpacingBetweenButtons; - int x = (selectionBounds.x() + selectionBounds.x() + selectionBounds.width() - width) / 2; - int y = selectionBounds.y() - height - 2; - - QRect bounds(x, y, width, height); - ui()->showTouchSelectionMenu(menuController, bounds, kSpacingBetweenButtons); -} - -void QQuickWebEngineViewPrivate::hideTouchSelectionMenu() -{ - ui()->hideTouchSelectionMenu(); -} - -bool QQuickWebEngineView::isLoading() const -{ - Q_D(const QQuickWebEngineView); - return d->isLoading; -} - -int QQuickWebEngineView::loadProgress() const -{ - Q_D(const QQuickWebEngineView); - return d->loadProgress; -} - -QString QQuickWebEngineView::title() const -{ - Q_D(const QQuickWebEngineView); - return d->adapter->pageTitle(); -} - -bool QQuickWebEngineView::canGoBack() const -{ - Q_D(const QQuickWebEngineView); - return d->adapter->canGoBack(); -} - -bool QQuickWebEngineView::canGoForward() const -{ - Q_D(const QQuickWebEngineView); - return d->adapter->canGoForward(); -} - -void QQuickWebEngineView::runJavaScript(const QString &script, const QJSValue &callback) -{ - runJavaScript(script, QQuickWebEngineScript::MainWorld, callback); -} - -void QQuickWebEngineView::runJavaScript(const QString &script, quint32 worldId, const QJSValue &callback) -{ - Q_D(QQuickWebEngineView); - d->ensureContentsAdapter(); - if (!callback.isUndefined()) { - quint64 requestId = d_ptr->adapter->runJavaScriptCallbackResult(script, worldId); - d->m_callbacks.insert(requestId, callback); - } else - d->adapter->runJavaScript(script, worldId); -} - -qreal QQuickWebEngineView::zoomFactor() const -{ - Q_D(const QQuickWebEngineView); - if (!d->adapter->isInitialized()) - return d->m_zoomFactor; - return d->adapter->currentZoomFactor(); -} - -QColor QQuickWebEngineView::backgroundColor() const -{ - Q_D(const QQuickWebEngineView); - return d->m_backgroundColor; -} - -void QQuickWebEngineView::setBackgroundColor(const QColor &color) -{ - Q_D(QQuickWebEngineView); - if (color == d->m_backgroundColor) - return; - d->m_backgroundColor = color; - if (d->adapter->isInitialized()) { - d->adapter->setBackgroundColor(color); - emit backgroundColorChanged(); - } -} - -/*! - \property QQuickWebEngineView::audioMuted - \brief The state of whether the current page audio is muted. - \since 5.7 - - The default value is false. -*/ -bool QQuickWebEngineView::isAudioMuted() const -{ - const Q_D(QQuickWebEngineView); - if (d->adapter->isInitialized()) - return d->adapter->isAudioMuted(); - return d->m_defaultAudioMuted; -} - -void QQuickWebEngineView::setAudioMuted(bool muted) -{ - Q_D(QQuickWebEngineView); - bool wasAudioMuted = isAudioMuted(); - d->m_defaultAudioMuted = muted; - d->adapter->setAudioMuted(muted); - if (wasAudioMuted != isAudioMuted()) - Q_EMIT audioMutedChanged(muted); -} - -bool QQuickWebEngineView::recentlyAudible() const -{ - const Q_D(QQuickWebEngineView); - return d->adapter->recentlyAudible(); -} - -qint64 QQuickWebEngineView::renderProcessPid() const -{ - const Q_D(QQuickWebEngineView); - return d->adapter->renderProcessPid(); -} - -void QQuickWebEngineView::printToPdf(const QString& filePath, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation) -{ -#if QT_CONFIG(webengine_printing_and_pdf) - Q_D(QQuickWebEngineView); - QPageSize layoutSize(static_cast<QPageSize::PageSizeId>(pageSizeId)); - QPageLayout::Orientation layoutOrientation = static_cast<QPageLayout::Orientation>(orientation); - QPageLayout pageLayout(layoutSize, layoutOrientation, QMarginsF(0.0, 0.0, 0.0, 0.0)); - d->ensureContentsAdapter(); - d->adapter->printToPDF(pageLayout, filePath); -#else - Q_UNUSED(filePath); - Q_UNUSED(pageSizeId); - Q_UNUSED(orientation); -#endif -} - -void QQuickWebEngineView::printToPdf(const QJSValue &callback, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation) -{ -#if QT_CONFIG(webengine_printing_and_pdf) - Q_D(QQuickWebEngineView); - QPageSize layoutSize(static_cast<QPageSize::PageSizeId>(pageSizeId)); - QPageLayout::Orientation layoutOrientation = static_cast<QPageLayout::Orientation>(orientation); - QPageLayout pageLayout(layoutSize, layoutOrientation, QMarginsF(0.0, 0.0, 0.0, 0.0)); - - if (callback.isUndefined()) - return; - - d->ensureContentsAdapter(); - quint64 requestId = d->adapter->printToPDFCallbackResult(pageLayout); - d->m_callbacks.insert(requestId, callback); -#else - Q_UNUSED(pageSizeId); - Q_UNUSED(orientation); - - // Call back with null result. - QJSValueList args; - args.append(QJSValue(QByteArray().data())); - QJSValue callbackCopy = callback; - callbackCopy.call(args); -#endif -} - -void QQuickWebEngineView::replaceMisspelledWord(const QString &replacement) -{ - Q_D(QQuickWebEngineView); - d->adapter->replaceMisspelling(replacement); -} - -bool QQuickWebEngineView::isFullScreen() const -{ - Q_D(const QQuickWebEngineView); - return d->m_fullscreenMode; -} - -void QQuickWebEngineView::findText(const QString &subString, FindFlags options, const QJSValue &callback) -{ - Q_D(QQuickWebEngineView); - if (!d->adapter->isInitialized()) - return; - - d->adapter->findTextHelper()->startFinding(subString, options & FindCaseSensitively, options & FindBackward, callback); -} - -QQuickWebEngineHistory *QQuickWebEngineView::navigationHistory() const -{ - Q_D(const QQuickWebEngineView); - return d->m_history.data(); -} - -QQmlWebChannel *QQuickWebEngineView::webChannel() -{ -#if QT_CONFIG(webengine_webchannel) - Q_D(QQuickWebEngineView); - if (!d->m_webChannel) { - d->m_webChannel = new QQmlWebChannel(this); - } - return d->m_webChannel; -#endif - qWarning("WebEngine compiled without webchannel support"); - return nullptr; -} - -void QQuickWebEngineView::setWebChannel(QQmlWebChannel *webChannel) -{ -#if QT_CONFIG(webengine_webchannel) - Q_D(QQuickWebEngineView); - if (d->m_webChannel == webChannel) - return; - d->m_webChannel = webChannel; - if (d->profileInitialized()) - d->adapter->setWebChannel(webChannel, d->m_webChannelWorld); - Q_EMIT webChannelChanged(); -#else - Q_UNUSED(webChannel) - qWarning("WebEngine compiled without webchannel support"); -#endif -} - -uint QQuickWebEngineView::webChannelWorld() const -{ - Q_D(const QQuickWebEngineView); - return d->m_webChannelWorld; -} - -void QQuickWebEngineView::setWebChannelWorld(uint webChannelWorld) -{ -#if QT_CONFIG(webengine_webchannel) - Q_D(QQuickWebEngineView); - if (d->m_webChannelWorld == webChannelWorld) - return; - d->m_webChannelWorld = webChannelWorld; - if (d->profileInitialized()) - d->adapter->setWebChannel(d->m_webChannel, d->m_webChannelWorld); - Q_EMIT webChannelWorldChanged(webChannelWorld); -#else - Q_UNUSED(webChannelWorld) - qWarning("WebEngine compiled without webchannel support"); -#endif -} - -QQuickWebEngineView *QQuickWebEngineView::inspectedView() const -{ - Q_D(const QQuickWebEngineView); - return d->inspectedView; -} - -void QQuickWebEngineView::setInspectedView(QQuickWebEngineView *view) -{ - Q_D(QQuickWebEngineView); - if (d->inspectedView == view) - return; - QQuickWebEngineView *oldView = d->inspectedView; - d->inspectedView = nullptr; - if (oldView) - oldView->setDevToolsView(nullptr); - d->inspectedView = view; - if (view) - view->setDevToolsView(this); - Q_EMIT inspectedViewChanged(); -} - -QQuickWebEngineView *QQuickWebEngineView::devToolsView() const -{ - Q_D(const QQuickWebEngineView); - return d->devToolsView; -} - - -void QQuickWebEngineView::setDevToolsView(QQuickWebEngineView *devToolsView) -{ - Q_D(QQuickWebEngineView); - if (d->devToolsView == devToolsView) - return; - QQuickWebEngineView *oldView = d->devToolsView; - d->devToolsView = nullptr; - if (oldView) - oldView->setInspectedView(nullptr); - d->devToolsView = devToolsView; - if (devToolsView) - devToolsView->setInspectedView(this); - if (d->profileInitialized() && d->adapter->isInitialized()) { - if (devToolsView) - d->adapter->openDevToolsFrontend(devToolsView->d_ptr->adapter); - else - d->adapter->closeDevToolsFrontend(); - } - Q_EMIT devToolsViewChanged(); -} - -void QQuickWebEngineView::grantFeaturePermission(const QUrl &securityOrigin, QQuickWebEngineView::Feature feature, bool granted) -{ - if (!granted && ((feature >= MediaAudioCapture && feature <= MediaAudioVideoCapture) || - (feature >= DesktopVideoCapture && feature <= DesktopAudioVideoCapture))) { - d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaNone); - return; - } - - switch (feature) { - case MediaAudioCapture: - d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaAudioCapture); - break; - case MediaVideoCapture: - d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaVideoCapture); - break; - case MediaAudioVideoCapture: - d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaRequestFlags(WebContentsAdapterClient::MediaAudioCapture | WebContentsAdapterClient::MediaVideoCapture)); - break; - case DesktopVideoCapture: - d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaDesktopVideoCapture); - break; - case DesktopAudioVideoCapture: - d_ptr->adapter->grantMediaAccessPermission( - securityOrigin, - WebContentsAdapterClient::MediaRequestFlags( - WebContentsAdapterClient::MediaDesktopAudioCapture | - WebContentsAdapterClient::MediaDesktopVideoCapture)); - break; - case Geolocation: - d_ptr->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::GeolocationPermission, - granted ? ProfileAdapter::AllowedPermission : ProfileAdapter::DeniedPermission); - break; - case Notifications: - d_ptr->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::NotificationPermission, - granted ? ProfileAdapter::AllowedPermission : ProfileAdapter::DeniedPermission); - break; - default: - Q_UNREACHABLE(); - } -} - -void QQuickWebEngineView::setActiveFocusOnPress(bool arg) -{ - Q_D(QQuickWebEngineView); - if (d->m_activeFocusOnPress == arg) - return; - - d->m_activeFocusOnPress = arg; - emit activeFocusOnPressChanged(arg); -} - -void QQuickWebEngineView::goBackOrForward(int offset) -{ - Q_D(QQuickWebEngineView); - const int current = d->adapter->currentNavigationEntryIndex(); - const int count = d->adapter->navigationEntryCount(); - const int index = current + offset; - - if (index < 0 || index >= count) - return; - - d->adapter->navigateToIndex(index); -} - -void QQuickWebEngineView::fullScreenCancelled() -{ - Q_D(QQuickWebEngineView); - d->adapter->exitFullScreen(); -} - -void QQuickWebEngineView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - QQuickItem::geometryChanged(newGeometry, oldGeometry); - Q_D(QQuickWebEngineView); - if (d->widget) - d->widget->setSize(newGeometry.size()); -} - -void QQuickWebEngineView::itemChange(ItemChange change, const ItemChangeData &value) -{ - Q_D(QQuickWebEngineView); - if (d && d->profileInitialized() && d->adapter->isInitialized() - && (change == ItemSceneChange || change == ItemVisibleHasChanged)) { - if (window()) - d->adapter->setVisible(isVisible()); - } - QQuickItem::itemChange(change, value); -} - -#if QT_CONFIG(draganddrop) -static QPoint mapToScreen(const QQuickItem *item, const QPoint &clientPos) -{ - return item->window()->position() + item->mapToScene(clientPos).toPoint(); -} - -void QQuickWebEngineView::dragEnterEvent(QDragEnterEvent *e) -{ - Q_D(QQuickWebEngineView); - e->accept(); - d->adapter->enterDrag(e, mapToScreen(this, e->pos())); -} - -void QQuickWebEngineView::dragLeaveEvent(QDragLeaveEvent *e) -{ - Q_D(QQuickWebEngineView); - e->accept(); - d->adapter->leaveDrag(); -} - -void QQuickWebEngineView::dragMoveEvent(QDragMoveEvent *e) -{ - Q_D(QQuickWebEngineView); - Qt::DropAction dropAction = d->adapter->updateDragPosition(e, mapToScreen(this, e->pos())); - if (Qt::IgnoreAction == dropAction) { - e->ignore(); - } else { - e->setDropAction(dropAction); - e->accept(); - } -} - -void QQuickWebEngineView::dropEvent(QDropEvent *e) -{ - Q_D(QQuickWebEngineView); - e->accept(); - d->adapter->endDragging(e, mapToScreen(this, e->pos())); -} -#endif // QT_CONFIG(draganddrop) - -void QQuickWebEngineView::triggerWebAction(WebAction action) -{ - Q_D(QQuickWebEngineView); - 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 (d->m_contextMenuData.linkUrl().isValid()) - setUrl(d->m_contextMenuData.linkUrl()); - break; - case OpenLinkInNewWindow: - if (d->m_contextMenuData.linkUrl().isValid()) { - QQuickWebEngineNewViewRequest request; - request.m_requestedUrl = d->m_contextMenuData.linkUrl(); - request.m_isUserInitiated = true; - request.m_destination = NewViewInWindow; - Q_EMIT newViewRequested(&request); - } - break; - case OpenLinkInNewTab: - if (d->m_contextMenuData.linkUrl().isValid()) { - QQuickWebEngineNewViewRequest request; - request.m_requestedUrl = d->m_contextMenuData.linkUrl(); - request.m_isUserInitiated = true; - request.m_destination = NewViewInBackgroundTab; - Q_EMIT newViewRequested(&request); - } - break; - case CopyLinkToClipboard: - if (!d->m_contextMenuData.unfilteredLinkUrl().isEmpty()) { - QString urlString = d->m_contextMenuData.unfilteredLinkUrl().toString(QUrl::FullyEncoded); - QString linkText = d->m_contextMenuData.linkText().toHtmlEscaped(); - QString title = d->m_contextMenuData.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>() << d->m_contextMenuData.unfilteredLinkUrl()); - qApp->clipboard()->setMimeData(data); - } - break; - case DownloadLinkToDisk: - if (d->m_contextMenuData.linkUrl().isValid()) - d->adapter->download(d->m_contextMenuData.linkUrl(), d->m_contextMenuData.suggestedFileName(), - d->m_contextMenuData.referrerUrl(), d->m_contextMenuData.referrerPolicy()); - break; - case CopyImageToClipboard: - if (d->m_contextMenuData.hasImageContent() && - (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeImage || - d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeCanvas)) - { - d->adapter->copyImageAt(d->m_contextMenuData.position()); - } - break; - case CopyImageUrlToClipboard: - if (d->m_contextMenuData.mediaUrl().isValid() && d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeImage) { - QString urlString = d->m_contextMenuData.mediaUrl().toString(QUrl::FullyEncoded); - QString alt = d->m_contextMenuData.altText(); - if (!alt.isEmpty()) - alt = QStringLiteral(" alt=\"%1\"").arg(alt.toHtmlEscaped()); - QString title = d->m_contextMenuData.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>() << d->m_contextMenuData.mediaUrl()); - qApp->clipboard()->setMimeData(data); - } - break; - case DownloadImageToDisk: - case DownloadMediaToDisk: - if (d->m_contextMenuData.mediaUrl().isValid()) - d->adapter->download(d->m_contextMenuData.mediaUrl(), d->m_contextMenuData.suggestedFileName(), - d->m_contextMenuData.referrerUrl(), d->m_contextMenuData.referrerPolicy()); - break; - case CopyMediaUrlToClipboard: - if (d->m_contextMenuData.mediaUrl().isValid() && - (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeAudio || - d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeVideo)) - { - QString urlString = d->m_contextMenuData.mediaUrl().toString(QUrl::FullyEncoded); - QString title = d->m_contextMenuData.titleText(); - if (!title.isEmpty()) - title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped()); - QMimeData *data = new QMimeData(); - data->setText(urlString); - if (d->m_contextMenuData.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>() << d->m_contextMenuData.mediaUrl()); - qApp->clipboard()->setMimeData(data); - } - break; - case ToggleMediaControls: - if (d->m_contextMenuData.mediaUrl().isValid() && d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaCanToggleControls) { - bool enable = !(d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaControls); - d->adapter->executeMediaPlayerActionAt(d->m_contextMenuData.position(), WebContentsAdapter::MediaPlayerControls, enable); - } - break; - case ToggleMediaLoop: - if (d->m_contextMenuData.mediaUrl().isValid() && - (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeAudio || - d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeVideo)) - { - bool enable = !(d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaLoop); - d->adapter->executeMediaPlayerActionAt(d->m_contextMenuData.position(), WebContentsAdapter::MediaPlayerLoop, enable); - } - break; - case ToggleMediaPlayPause: - if (d->m_contextMenuData.mediaUrl().isValid() && - (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeAudio || - d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeVideo)) - { - bool enable = (d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaPaused); - d->adapter->executeMediaPlayerActionAt(d->m_contextMenuData.position(), WebContentsAdapter::MediaPlayerPlay, enable); - } - break; - case ToggleMediaMute: - if (d->m_contextMenuData.mediaUrl().isValid() && d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaHasAudio) { - bool enable = !(d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaMuted); - d->adapter->executeMediaPlayerActionAt(d->m_contextMenuData.position(), WebContentsAdapter::MediaPlayerMute, enable); - } - break; - case InspectElement: - d->adapter->inspectElementAt(d->m_contextMenuData.position()); - break; - case ExitFullScreen: - d->adapter->exitFullScreen(); - break; - case RequestClose: - d->adapter->requestClose(); - break; - case SavePage: - d->adapter->save(); - break; - case ViewSource: - d->adapter->viewSource(); - break; - case ToggleBold: - runJavaScript(QStringLiteral("document.execCommand('bold');"), QQuickWebEngineScript::ApplicationWorld); - break; - case ToggleItalic: - runJavaScript(QStringLiteral("document.execCommand('italic');"), QQuickWebEngineScript::ApplicationWorld); - break; - case ToggleUnderline: - runJavaScript(QStringLiteral("document.execCommand('underline');"), QQuickWebEngineScript::ApplicationWorld); - break; - case ToggleStrikethrough: - runJavaScript(QStringLiteral("document.execCommand('strikethrough');"), QQuickWebEngineScript::ApplicationWorld); - break; - case AlignLeft: - runJavaScript(QStringLiteral("document.execCommand('justifyLeft');"), QQuickWebEngineScript::ApplicationWorld); - break; - case AlignCenter: - runJavaScript(QStringLiteral("document.execCommand('justifyCenter');"), QQuickWebEngineScript::ApplicationWorld); - break; - case AlignRight: - runJavaScript(QStringLiteral("document.execCommand('justifyRight');"), QQuickWebEngineScript::ApplicationWorld); - break; - case AlignJustified: - runJavaScript(QStringLiteral("document.execCommand('justifyFull');"), QQuickWebEngineScript::ApplicationWorld); - break; - case Indent: - runJavaScript(QStringLiteral("document.execCommand('indent');"), QQuickWebEngineScript::ApplicationWorld); - break; - case Outdent: - runJavaScript(QStringLiteral("document.execCommand('outdent');"), QQuickWebEngineScript::ApplicationWorld); - break; - case InsertOrderedList: - runJavaScript(QStringLiteral("document.execCommand('insertOrderedList');"), QQuickWebEngineScript::ApplicationWorld); - break; - case InsertUnorderedList: - runJavaScript(QStringLiteral("document.execCommand('insertUnorderedList');"), QQuickWebEngineScript::ApplicationWorld); - break; - default: - Q_UNREACHABLE(); - } -} - -QQuickWebEngineAction *QQuickWebEngineView::action(WebAction action) -{ - Q_D(QQuickWebEngineView); - if (action == QQuickWebEngineView::NoWebAction) - return nullptr; - if (d->actions[action]) { - d->updateAction(action); - return d->actions[action]; - } - - QString text; - QString iconName; - - switch (action) { - case Back: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Back); - iconName = QStringLiteral("go-previous"); - break; - case Forward: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Forward); - iconName = QStringLiteral("go-next"); - break; - case Stop: - text = tr("Stop"); - iconName = QStringLiteral("process-stop"); - break; - case Reload: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Reload); - iconName = QStringLiteral("view-refresh"); - break; - case ReloadAndBypassCache: - text = tr("Reload and Bypass Cache"); - iconName = QStringLiteral("view-refresh"); - break; - case Cut: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Cut); - iconName = QStringLiteral("edit-cut"); - break; - case Copy: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Copy); - iconName = QStringLiteral("edit-copy"); - break; - case Paste: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Paste); - iconName = QStringLiteral("edit-paste"); - break; - case Undo: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Undo); - iconName = QStringLiteral("edit-undo"); - break; - case Redo: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Redo); - iconName = QStringLiteral("edit-redo"); - break; - case SelectAll: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::SelectAll); - iconName = QStringLiteral("edit-select-all"); - break; - case PasteAndMatchStyle: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::PasteAndMatchStyle); - iconName = QStringLiteral("edit-paste"); - 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 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"); - iconName = QStringLiteral("media-playback-start"); - break; - case ToggleMediaMute: - text = tr("Toggle Mute"); - iconName = QStringLiteral("audio-volume-muted"); - 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); - iconName = QStringLiteral("view-fullscreen"); - break; - case RequestClose: - text = tr("Close Page"); - iconName = QStringLiteral("window-close"); - break; - case Unselect: - text = tr("Unselect"); - iconName = QStringLiteral("edit-select-none"); - break; - case SavePage: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::SavePage); - iconName = QStringLiteral("document-save"); - break; - case ViewSource: - text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::ViewSource); - break; - case ToggleBold: - text = tr("&Bold"); - iconName = QStringLiteral("format-text-bold"); - break; - case ToggleItalic: - text = tr("&Italic"); - iconName = QStringLiteral("format-text-italic"); - break; - case ToggleUnderline: - text = tr("&Underline"); - iconName = QStringLiteral("format-text-underline"); - break; - case ToggleStrikethrough: - text = tr("&Strikethrough"); - iconName = QStringLiteral("format-text-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"); - iconName = QStringLiteral("format-indent-more"); - break; - case Outdent: - text = tr("&Outdent"); - iconName = QStringLiteral("format-indent-less"); - break; - case InsertOrderedList: - text = tr("Insert &Ordered List"); - break; - case InsertUnorderedList: - text = tr("Insert &Unordered List"); - break; - case NoWebAction: - case WebActionCount: - Q_UNREACHABLE(); - break; - } - - QQuickWebEngineAction *retVal = new QQuickWebEngineAction(action, text, iconName, false, this); - - d->actions[action] = retVal; - d->updateAction(action); - return retVal; -} - -QSizeF QQuickWebEngineView::contentsSize() const -{ - Q_D(const QQuickWebEngineView); - return d->adapter->lastContentsSize(); -} - -QPointF QQuickWebEngineView::scrollPosition() const -{ - Q_D(const QQuickWebEngineView); - return d->adapter->lastScrollOffset(); -} - -void QQuickWebEngineViewPrivate::userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script) -{ - Q_ASSERT(p && p->data); - QQuickWebEngineViewPrivate *d = static_cast<QQuickWebEngineViewPrivate*>(p->data); - d->m_userScripts.append(script); - // If the adapter hasn't been initialized, we'll bind the scripts in initializationFinished() - if (!d->adapter->isInitialized()) - return; - UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController(); - script->d_func()->bind(resourceController, d->adapter.data()); -} - -int QQuickWebEngineViewPrivate::userScripts_count(QQmlListProperty<QQuickWebEngineScript> *p) -{ - Q_ASSERT(p && p->data); - QQuickWebEngineViewPrivate *d = static_cast<QQuickWebEngineViewPrivate*>(p->data); - return d->m_userScripts.count(); -} - -QQuickWebEngineScript *QQuickWebEngineViewPrivate::userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx) -{ - Q_ASSERT(p && p->data); - QQuickWebEngineViewPrivate *d = static_cast<QQuickWebEngineViewPrivate*>(p->data); - return d->m_userScripts.at(idx); -} - -void QQuickWebEngineViewPrivate::userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p) -{ - Q_ASSERT(p && p->data); - QQuickWebEngineViewPrivate *d = static_cast<QQuickWebEngineViewPrivate*>(p->data); - d->m_userScripts.clear(); - if (!d->adapter->isInitialized()) - return; - UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController(); - resourceController->clearAllScripts(d->adapter.data()); -} - -void QQuickWebEngineView::componentComplete() -{ - QQuickItem::componentComplete(); - Q_D(QQuickWebEngineView); - d->initializeProfile(); -#ifndef QT_NO_ACCESSIBILITY - // Enable accessibility via a dynamic QQmlProperty, instead of using private API call - // QQuickAccessibleAttached::qmlAttachedProperties(this). The qmlContext is required, otherwise - // it is not possible to reference attached properties. - QQmlContext *qmlContext = QQmlEngine::contextForObject(this); - QQmlProperty role(this, QStringLiteral("Accessible.role"), qmlContext); - role.write(QAccessible::Grouping); -#endif // QT_NO_ACCESSIBILITY - - QTimer::singleShot(0, this, &QQuickWebEngineView::lazyInitialize); -} - -void QQuickWebEngineView::lazyInitialize() -{ - Q_D(QQuickWebEngineView); - d->ensureContentsAdapter(); -} - -QQuickWebEngineView::LifecycleState QQuickWebEngineView::lifecycleState() const -{ - Q_D(const QQuickWebEngineView); - return static_cast<LifecycleState>(d->adapter->lifecycleState()); -} - -void QQuickWebEngineView::setLifecycleState(LifecycleState state) -{ - Q_D(QQuickWebEngineView); - d->adapter->setLifecycleState(static_cast<WebContentsAdapterClient::LifecycleState>(state)); -} - -QQuickWebEngineView::LifecycleState QQuickWebEngineView::recommendedState() const -{ - Q_D(const QQuickWebEngineView); - return static_cast<LifecycleState>(d->adapter->recommendedState()); -} - -QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest() - : m_viewPrivate(0) - , m_toggleOn(false) -{ -} - -QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn) - : m_viewPrivate(viewPrivate) - , m_origin(origin) - , m_toggleOn(toggleOn) -{ -} - -void QQuickWebEngineFullScreenRequest::accept() -{ - if (m_viewPrivate) - m_viewPrivate->setFullScreenMode(m_toggleOn); -} - -void QQuickWebEngineFullScreenRequest::reject() -{ - if (m_viewPrivate) - m_viewPrivate->setFullScreenMode(!m_toggleOn); -} - -QQuickContextMenuBuilder::QQuickContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data, - QQuickWebEngineView *view, - QObject *menu) - : QtWebEngineCore::RenderViewContextMenuQt(data) - , m_view(view) - , m_menu(menu) -{ -} - -void QQuickContextMenuBuilder::appendExtraItems(QQmlEngine *engine) -{ - m_view->d_ptr->ui()->addMenuSeparator(m_menu); - if (QObject *menuExtras = m_view->d_ptr->contextMenuExtraItems->create(qmlContext(m_view))) { - menuExtras->setParent(m_menu); - QQmlListReference entries(m_menu, defaultPropertyName(m_menu), engine); - if (entries.isValid()) - entries.append(menuExtras); - } -} - -bool QQuickContextMenuBuilder::hasInspector() -{ - return m_view->d_ptr->adapter->hasInspector(); -} - -bool QQuickContextMenuBuilder::isFullScreenMode() -{ - return m_view->d_ptr->isFullScreenMode(); -} - -void QQuickContextMenuBuilder::addMenuItem(ContextMenuItem menuItem) -{ - QQuickWebEngineAction *action = nullptr; - - switch (menuItem) { - case ContextMenuItem::Back: - action = m_view->action(QQuickWebEngineView::Back); - break; - case ContextMenuItem::Forward: - action = m_view->action(QQuickWebEngineView::Forward); - break; - case ContextMenuItem::Reload: - action = m_view->action(QQuickWebEngineView::Reload); - break; - case ContextMenuItem::Cut: - action = m_view->action(QQuickWebEngineView::Cut); - break; - case ContextMenuItem::Copy: - action = m_view->action(QQuickWebEngineView::Copy); - break; - case ContextMenuItem::Paste: - action = m_view->action(QQuickWebEngineView::Paste); - break; - case ContextMenuItem::Undo: - action = m_view->action(QQuickWebEngineView::Undo); - break; - case ContextMenuItem::Redo: - action = m_view->action(QQuickWebEngineView::Redo); - break; - case ContextMenuItem::SelectAll: - action = m_view->action(QQuickWebEngineView::SelectAll); - break; - case ContextMenuItem::PasteAndMatchStyle: - action = m_view->action(QQuickWebEngineView::PasteAndMatchStyle); - break; - case ContextMenuItem::OpenLinkInNewWindow: - action = m_view->action(QQuickWebEngineView::OpenLinkInNewWindow); - break; - case ContextMenuItem::OpenLinkInNewTab: - action = m_view->action(QQuickWebEngineView::OpenLinkInNewTab); - break; - case ContextMenuItem::CopyLinkToClipboard: - action = m_view->action(QQuickWebEngineView::CopyLinkToClipboard); - break; - case ContextMenuItem::DownloadLinkToDisk: - action = m_view->action(QQuickWebEngineView::DownloadLinkToDisk); - break; - case ContextMenuItem::CopyImageToClipboard: - action = m_view->action(QQuickWebEngineView::CopyImageToClipboard); - break; - case ContextMenuItem::CopyImageUrlToClipboard: - action = m_view->action(QQuickWebEngineView::CopyImageUrlToClipboard); - break; - case ContextMenuItem::DownloadImageToDisk: - action = m_view->action(QQuickWebEngineView::DownloadImageToDisk); - break; - case ContextMenuItem::CopyMediaUrlToClipboard: - action = m_view->action(QQuickWebEngineView::CopyMediaUrlToClipboard); - break; - case ContextMenuItem::ToggleMediaControls: - action = m_view->action(QQuickWebEngineView::ToggleMediaControls); - break; - case ContextMenuItem::ToggleMediaLoop: - action = m_view->action(QQuickWebEngineView::ToggleMediaLoop); - break; - case ContextMenuItem::DownloadMediaToDisk: - action = m_view->action(QQuickWebEngineView::DownloadMediaToDisk); - break; - case ContextMenuItem::InspectElement: - action = m_view->action(QQuickWebEngineView::InspectElement); - break; - case ContextMenuItem::ExitFullScreen: - action = m_view->action(QQuickWebEngineView::ExitFullScreen); - break; - case ContextMenuItem::SavePage: - action = m_view->action(QQuickWebEngineView::SavePage); - break; - case ContextMenuItem::ViewSource: - action = m_view->action(QQuickWebEngineView::ViewSource); - break; - case ContextMenuItem::SpellingSuggestions: - { - QPointer<QQuickWebEngineView> thisRef(m_view); - for (int i=0; i < m_contextData.spellCheckerSuggestions().count() && i < 4; i++) { - action = new QQuickWebEngineAction(m_menu); - QString replacement = m_contextData.spellCheckerSuggestions().at(i); - QObject::connect(action, &QQuickWebEngineAction::triggered, [thisRef, replacement] { thisRef->replaceMisspelledWord(replacement); }); - m_view->d_ptr->ui()->addMenuItem(action, m_menu); - } - return; - } - case ContextMenuItem::Separator: - m_view->d_ptr->ui()->addMenuSeparator(m_menu); - return; - } - // Set enabled property directly with avoiding binding loops caused by its notifier signal. - action->d_ptr->m_enabled = isMenuItemEnabled(menuItem); - m_view->d_ptr->ui()->addMenuItem(action, m_menu); -} - -bool QQuickContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem) -{ - switch (menuItem) { - case ContextMenuItem::Back: - return m_view->canGoBack(); - case ContextMenuItem::Forward: - return m_view->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_view->d_ptr->adapter->canViewSource(); - case ContextMenuItem::SpellingSuggestions: - case ContextMenuItem::Separator: - return true; - } - Q_UNREACHABLE(); -} - - -QQuickWebEngineTouchHandle::QQuickWebEngineTouchHandle(QtWebEngineCore::UIDelegatesManager *ui, const QMap<int, QImage> &images) -{ - Q_ASSERT(ui); - m_item.reset(ui->createTouchHandle()); - - QQmlEngine *engine = qmlEngine(m_item.data()); - Q_ASSERT(engine); - QQuickWebEngineTouchHandleProvider *touchHandleProvider = - static_cast<QQuickWebEngineTouchHandleProvider *>(engine->imageProvider(QQuickWebEngineTouchHandleProvider::identifier())); - Q_ASSERT(touchHandleProvider); - touchHandleProvider->init(images); -} - -void QQuickWebEngineTouchHandle::setImage(int orientation) -{ - QUrl url = QQuickWebEngineTouchHandleProvider::url(orientation); - m_item->setProperty("source", url); -} - -void QQuickWebEngineTouchHandle::setBounds(const QRect &bounds) -{ - m_item->setProperty("x", bounds.x()); - m_item->setProperty("y", bounds.y()); - m_item->setProperty("width", bounds.width()); - m_item->setProperty("height", bounds.height()); -} - -void QQuickWebEngineTouchHandle::setVisible(bool visible) -{ - m_item->setProperty("visible", visible); -} - -void QQuickWebEngineTouchHandle::setOpacity(float opacity) -{ - m_item->setProperty("opacity", opacity); -} - -QT_END_NAMESPACE - diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h deleted file mode 100644 index ab84b2600..000000000 --- a/src/webengine/api/qquickwebengineview_p.h +++ /dev/null @@ -1,616 +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 QQUICKWEBENGINEVIEW_P_H -#define QQUICKWEBENGINEVIEW_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 <QtWebEngine/private/qtwebengineglobal_p.h> -#include <QQuickItem> -#include <QtGui/qcolor.h> - -#include "qquickwebenginescript.h" - -QT_BEGIN_NAMESPACE - -class QQmlWebChannel; -class QQuickContextMenuBuilder; -class QQuickWebEngineAction; -class QQuickWebEngineAuthenticationDialogRequest; -class QQuickWebEngineCertificateError; -class QQuickWebEngineClientCertificateSelection; -class QQuickWebEngineColorDialogRequest; -class QQuickWebEngineContextMenuRequest; -class QQuickWebEngineFaviconProvider; -class QQuickWebEngineFileDialogRequest; -class QQuickWebEngineHistory; -class QQuickWebEngineJavaScriptDialogRequest; -class QQuickWebEngineLoadRequest; -class QQuickWebEngineNavigationRequest; -class QQuickWebEngineNewViewRequest; -class QQuickWebEngineProfile; -class QQuickWebEngineSettings; -class QQuickWebEngineTooltipRequest; -class QQuickWebEngineFormValidationMessageRequest; -class QQuickWebEngineViewPrivate; -class QWebEngineFindTextResult; -class QWebEngineQuotaRequest; -class QWebEngineRegisterProtocolHandlerRequest; - -#if QT_CONFIG(webengine_testsupport) -class QQuickWebEngineTestSupport; -#endif - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFullScreenRequest { - Q_GADGET - Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL) - Q_PROPERTY(bool toggleOn READ toggleOn CONSTANT FINAL) -public: - QQuickWebEngineFullScreenRequest(); - QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn); - - Q_INVOKABLE void accept(); - Q_INVOKABLE void reject(); - QUrl origin() const { return m_origin; } - bool toggleOn() const { return m_toggleOn; } - -private: - QQuickWebEngineViewPrivate *m_viewPrivate; - const QUrl m_origin; - const bool m_toggleOn; -}; - -#define LATEST_WEBENGINEVIEW_REVISION 10 - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { - Q_OBJECT - Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") - Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged FINAL) - Q_PROPERTY(QUrl icon READ icon NOTIFY iconChanged FINAL) - Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged FINAL) - Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged FINAL) - Q_PROPERTY(QString title READ title NOTIFY titleChanged FINAL) - Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY urlChanged FINAL) - Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY urlChanged FINAL) - Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged REVISION 1 FINAL) - Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged REVISION 1 FINAL) - Q_PROPERTY(QQuickWebEngineProfile *profile READ profile WRITE setProfile NOTIFY profileChanged FINAL REVISION 1) - Q_PROPERTY(QQuickWebEngineSettings *settings READ settings REVISION 1 CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineHistory *navigationHistory READ navigationHistory CONSTANT FINAL REVISION 1) - Q_PROPERTY(QQmlWebChannel *webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged REVISION 1 FINAL) - Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL REVISION 1) - Q_PROPERTY(bool activeFocusOnPress READ activeFocusOnPress WRITE setActiveFocusOnPress NOTIFY activeFocusOnPressChanged REVISION 2 FINAL) - Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged REVISION 2 FINAL) - Q_PROPERTY(QSizeF contentsSize READ contentsSize NOTIFY contentsSizeChanged FINAL REVISION 3) - Q_PROPERTY(QPointF scrollPosition READ scrollPosition NOTIFY scrollPositionChanged FINAL REVISION 3) - Q_PROPERTY(bool audioMuted READ isAudioMuted WRITE setAudioMuted NOTIFY audioMutedChanged FINAL REVISION 3) - Q_PROPERTY(bool recentlyAudible READ recentlyAudible NOTIFY recentlyAudibleChanged FINAL REVISION 3) - Q_PROPERTY(uint webChannelWorld READ webChannelWorld WRITE setWebChannelWorld NOTIFY webChannelWorldChanged REVISION 3 FINAL) - - Q_PROPERTY(QQuickWebEngineView *inspectedView READ inspectedView WRITE setInspectedView NOTIFY inspectedViewChanged REVISION 7 FINAL) - Q_PROPERTY(QQuickWebEngineView *devToolsView READ devToolsView WRITE setDevToolsView NOTIFY devToolsViewChanged REVISION 7 FINAL) -#if QT_CONFIG(webengine_testsupport) - Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport NOTIFY testSupportChanged FINAL) -#endif - - Q_PROPERTY(LifecycleState lifecycleState READ lifecycleState WRITE setLifecycleState NOTIFY lifecycleStateChanged REVISION 10 FINAL) - Q_PROPERTY(LifecycleState recommendedState READ recommendedState NOTIFY recommendedStateChanged REVISION 10 FINAL) - - Q_PROPERTY(qint64 renderProcessPid READ renderProcessPid NOTIFY renderProcessPidChanged FINAL REVISION 11) - -public: - QQuickWebEngineView(QQuickItem *parent = 0); - ~QQuickWebEngineView(); - - QUrl url() const; - void setUrl(const QUrl&); - QUrl icon() const; - bool isLoading() const; - int loadProgress() const; - QString title() const; - bool canGoBack() const; - bool canGoForward() const; - bool isFullScreen() const; - qreal zoomFactor() const; - void setZoomFactor(qreal arg); - QColor backgroundColor() const; - void setBackgroundColor(const QColor &color); - QSizeF contentsSize() const; - QPointF scrollPosition() const; - - // must match WebContentsAdapterClient::NavigationRequestAction - enum NavigationRequestAction { - AcceptRequest, - // Make room in the valid range of the enum so - // we can expose extra actions. - IgnoreRequest = 0xFF - }; - Q_ENUM(NavigationRequestAction) - - // must match WebContentsAdapterClient::NavigationType - enum NavigationType { - LinkClickedNavigation, - TypedNavigation, - FormSubmittedNavigation, - BackForwardNavigation, - ReloadNavigation, - OtherNavigation, - RedirectNavigation, - }; - Q_ENUM(NavigationType) - - enum LoadStatus { - LoadStartedStatus, - LoadStoppedStatus, - LoadSucceededStatus, - LoadFailedStatus - }; - Q_ENUM(LoadStatus) - - enum ErrorDomain { - NoErrorDomain, - InternalErrorDomain, - ConnectionErrorDomain, - CertificateErrorDomain, - HttpErrorDomain, - FtpErrorDomain, - DnsErrorDomain - }; - Q_ENUM(ErrorDomain) - - enum NewViewDestination { - NewViewInWindow, - NewViewInTab, - NewViewInDialog, - NewViewInBackgroundTab - }; - Q_ENUM(NewViewDestination) - - enum Feature { - MediaAudioCapture, - MediaVideoCapture, - MediaAudioVideoCapture, - Geolocation, - DesktopVideoCapture, - DesktopAudioVideoCapture, - Notifications, - }; - Q_ENUM(Feature) - - 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, - ViewSource, - - ToggleBold, - ToggleItalic, - ToggleUnderline, - ToggleStrikethrough, - - AlignLeft, - AlignCenter, - AlignRight, - AlignJustified, - Indent, - Outdent, - - InsertOrderedList, - InsertUnorderedList, - - WebActionCount - }; - Q_ENUM(WebAction) - - // 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) - - enum FindFlag { - FindBackward = 1, - FindCaseSensitively = 2, - }; - Q_DECLARE_FLAGS(FindFlags, FindFlag) - Q_FLAG(FindFlags) - - // must match QPageSize::PageSizeId - enum PrintedPageSizeId { - // Existing Qt sizes - A4, - B5, - Letter, - Legal, - Executive, - A0, - A1, - A2, - A3, - A5, - A6, - A7, - A8, - A9, - B0, - B1, - B10, - B2, - B3, - B4, - B6, - B7, - B8, - B9, - C5E, - Comm10E, - DLE, - Folio, - Ledger, - Tabloid, - Custom, - - // New values derived from PPD standard - A10, - A3Extra, - A4Extra, - A4Plus, - A4Small, - A5Extra, - B5Extra, - - JisB0, - JisB1, - JisB2, - JisB3, - JisB4, - JisB5, - JisB6, - JisB7, - JisB8, - JisB9, - JisB10, - - // AnsiA = Letter, - // AnsiB = Ledger, - AnsiC, - AnsiD, - AnsiE, - LegalExtra, - LetterExtra, - LetterPlus, - LetterSmall, - TabloidExtra, - - ArchA, - ArchB, - ArchC, - ArchD, - ArchE, - - Imperial7x9, - Imperial8x10, - Imperial9x11, - Imperial9x12, - Imperial10x11, - Imperial10x13, - Imperial10x14, - Imperial12x11, - Imperial15x11, - - ExecutiveStandard, - Note, - Quarto, - Statement, - SuperA, - SuperB, - Postcard, - DoublePostcard, - Prc16K, - Prc32K, - Prc32KBig, - - FanFoldUS, - FanFoldGerman, - FanFoldGermanLegal, - - EnvelopeB4, - EnvelopeB5, - EnvelopeB6, - EnvelopeC0, - EnvelopeC1, - EnvelopeC2, - EnvelopeC3, - EnvelopeC4, - // EnvelopeC5 = C5E, - EnvelopeC6, - EnvelopeC65, - EnvelopeC7, - // EnvelopeDL = DLE, - - Envelope9, - // Envelope10 = Comm10E, - Envelope11, - Envelope12, - Envelope14, - EnvelopeMonarch, - EnvelopePersonal, - - EnvelopeChou3, - EnvelopeChou4, - EnvelopeInvite, - EnvelopeItalian, - EnvelopeKaku2, - EnvelopeKaku3, - EnvelopePrc1, - EnvelopePrc2, - EnvelopePrc3, - EnvelopePrc4, - EnvelopePrc5, - EnvelopePrc6, - EnvelopePrc7, - EnvelopePrc8, - EnvelopePrc9, - EnvelopePrc10, - EnvelopeYou4, - - // Last item, with commonly used synynoms from QPagedPrintEngine / QPrinter - LastPageSize = EnvelopeYou4, - NPageSize = LastPageSize, - NPaperSize = LastPageSize, - - // Convenience overloads for naming consistency - AnsiA = Letter, - AnsiB = Ledger, - EnvelopeC5 = C5E, - EnvelopeDL = DLE, - Envelope10 = Comm10E - }; - Q_ENUM(PrintedPageSizeId) - - // must match QPageLayout::Orientation - enum PrintedPageOrientation { - Portrait, - Landscape - }; - Q_ENUM(PrintedPageOrientation) - - // must match WebContentsAdapterClient::LifecycleState - enum class LifecycleState { - Active, - Frozen, - Discarded, - }; - Q_ENUM(LifecycleState) - - // QmlParserStatus - void componentComplete() override; - - QQuickWebEngineProfile *profile(); - void setProfile(QQuickWebEngineProfile *); - QQmlListProperty<QQuickWebEngineScript> userScripts(); - - QQuickWebEngineSettings *settings(); - QQmlWebChannel *webChannel(); - void setWebChannel(QQmlWebChannel *); - QQuickWebEngineHistory *navigationHistory() const; - uint webChannelWorld() const; - void setWebChannelWorld(uint); - Q_REVISION(8) Q_INVOKABLE QQuickWebEngineAction *action(WebAction action); - - bool isAudioMuted() const; - void setAudioMuted(bool muted); - bool recentlyAudible() const; - - qint64 renderProcessPid() const; - -#if QT_CONFIG(webengine_testsupport) - QQuickWebEngineTestSupport *testSupport() const; - void setTestSupport(QQuickWebEngineTestSupport *testSupport); -#endif - - bool activeFocusOnPress() const; - - void setInspectedView(QQuickWebEngineView *); - QQuickWebEngineView *inspectedView() const; - void setDevToolsView(QQuickWebEngineView *); - QQuickWebEngineView *devToolsView() const; - - LifecycleState lifecycleState() const; - void setLifecycleState(LifecycleState state); - - LifecycleState recommendedState() const; - -public Q_SLOTS: - void runJavaScript(const QString&, const QJSValue & = QJSValue()); - Q_REVISION(3) void runJavaScript(const QString&, quint32 worldId, const QJSValue & = QJSValue()); - void loadHtml(const QString &html, const QUrl &baseUrl = QUrl()); - void goBack(); - void goForward(); - Q_REVISION(1) void goBackOrForward(int index); - void reload(); - Q_REVISION(1) void reloadAndBypassCache(); - void stop(); - Q_REVISION(1) void findText(const QString &subString, FindFlags options = { }, const QJSValue &callback = QJSValue()); - Q_REVISION(1) void fullScreenCancelled(); - Q_REVISION(1) void grantFeaturePermission(const QUrl &securityOrigin, Feature, bool granted); - Q_REVISION(2) void setActiveFocusOnPress(bool arg); - Q_REVISION(2) void triggerWebAction(WebAction action); - Q_REVISION(3) void printToPdf(const QString &filePath, PrintedPageSizeId pageSizeId = PrintedPageSizeId::A4, PrintedPageOrientation orientation = PrintedPageOrientation::Portrait); - Q_REVISION(3) void printToPdf(const QJSValue &callback, PrintedPageSizeId pageSizeId = PrintedPageSizeId::A4, PrintedPageOrientation orientation = PrintedPageOrientation::Portrait); - Q_REVISION(4) void replaceMisspelledWord(const QString &replacement); - -private Q_SLOTS: - void lazyInitialize(); - -Q_SIGNALS: - void titleChanged(); - void urlChanged(); - void iconChanged(); - void loadingChanged(QQuickWebEngineLoadRequest *loadRequest); - void loadProgressChanged(); - void linkHovered(const QUrl &hoveredUrl); - void navigationRequested(QQuickWebEngineNavigationRequest *request); - void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID); - Q_REVISION(1) void certificateError(QQuickWebEngineCertificateError *error); - Q_REVISION(1) void fullScreenRequested(const QQuickWebEngineFullScreenRequest &request); - Q_REVISION(1) void isFullScreenChanged(); - Q_REVISION(1) void featurePermissionRequested(const QUrl &securityOrigin, Feature feature); - Q_REVISION(1) void newViewRequested(QQuickWebEngineNewViewRequest *request); - Q_REVISION(1) void zoomFactorChanged(qreal arg); - Q_REVISION(1) void profileChanged(); - Q_REVISION(1) void webChannelChanged(); - Q_REVISION(2) void activeFocusOnPressChanged(bool); - Q_REVISION(2) void backgroundColorChanged(); - Q_REVISION(2) void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode); - Q_REVISION(2) void windowCloseRequested(); - Q_REVISION(3) void contentsSizeChanged(const QSizeF& size); - Q_REVISION(3) void scrollPositionChanged(const QPointF& position); - Q_REVISION(3) void audioMutedChanged(bool muted); - Q_REVISION(3) void recentlyAudibleChanged(bool recentlyAudible); - Q_REVISION(3) void webChannelWorldChanged(uint); - Q_REVISION(4) void contextMenuRequested(QQuickWebEngineContextMenuRequest *request); - Q_REVISION(4) void authenticationDialogRequested(QQuickWebEngineAuthenticationDialogRequest *request); - Q_REVISION(4) void javaScriptDialogRequested(QQuickWebEngineJavaScriptDialogRequest *request); - Q_REVISION(4) void colorDialogRequested(QQuickWebEngineColorDialogRequest *request); - Q_REVISION(4) void fileDialogRequested(QQuickWebEngineFileDialogRequest *request); - Q_REVISION(4) void formValidationMessageRequested(QQuickWebEngineFormValidationMessageRequest *request); - Q_REVISION(5) void pdfPrintingFinished(const QString &filePath, bool success); - Q_REVISION(7) void quotaRequested(const QWebEngineQuotaRequest &request); - Q_REVISION(7) void geometryChangeRequested(const QRect &geometry, const QRect &frameGeometry); - Q_REVISION(7) void inspectedViewChanged(); - Q_REVISION(7) void devToolsViewChanged(); - Q_REVISION(7) void registerProtocolHandlerRequested(const QWebEngineRegisterProtocolHandlerRequest &request); - Q_REVISION(8) void printRequested(); - Q_REVISION(9) void selectClientCertificate(QQuickWebEngineClientCertificateSelection *clientCertSelection); - Q_REVISION(10) void tooltipRequested(QQuickWebEngineTooltipRequest *request); - Q_REVISION(10) void lifecycleStateChanged(LifecycleState state); - Q_REVISION(10) void recommendedStateChanged(LifecycleState state); - Q_REVISION(10) void findTextFinished(const QWebEngineFindTextResult &result); - Q_REVISION(11) void renderProcessPidChanged(qint64 pid); - -#if QT_CONFIG(webengine_testsupport) - void testSupportChanged(); -#endif - -protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; - void itemChange(ItemChange, const ItemChangeData &) override; -#if QT_CONFIG(draganddrop) - void dragEnterEvent(QDragEnterEvent *e) override; - void dragLeaveEvent(QDragLeaveEvent *e) override; - void dragMoveEvent(QDragMoveEvent *e) override; - void dropEvent(QDropEvent *e) override; -#endif // QT_CONFIG(draganddrop) - -private: - Q_DECLARE_PRIVATE(QQuickWebEngineView) - QScopedPointer<QQuickWebEngineViewPrivate> d_ptr; - - friend class QQuickContextMenuBuilder; - friend class QQuickWebEngineNewViewRequest; - friend class QQuickWebEngineFaviconProvider; -#ifndef QT_NO_ACCESSIBILITY - friend class QQuickWebEngineViewAccessible; -#endif // QT_NO_ACCESSIBILITY -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickWebEngineView) -Q_DECLARE_METATYPE(QQuickWebEngineFullScreenRequest) - -#endif // QQUICKWEBENGINEVIEW_P_H diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h deleted file mode 100644 index 68d65410a..000000000 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ /dev/null @@ -1,286 +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 QQUICKWEBENGINEVIEW_P_P_H -#define QQUICKWEBENGINEVIEW_P_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 "qquickwebengineview_p.h" -#include "render_view_context_menu_qt.h" -#include "touch_handle_drawable_client.h" -#include "web_contents_adapter_client.h" - -#include <QPointer> -#include <QScopedPointer> -#include <QSharedData> -#include <QString> -#include <QtCore/qcompilerdetection.h> -#include <QtGui/qaccessibleobject.h> - -namespace QtWebEngineCore { -class RenderWidgetHostViewQtDelegateQuick; -class TouchHandleDrawableClient; -class TouchSelectionMenuController; -class UIDelegatesManager; -class WebContentsAdapter; -} - -QT_BEGIN_NAMESPACE -class QQuickWebEngineView; -class QQmlComponent; -class QQmlContext; -class QQuickWebEngineContextMenuRequest; -class QQuickWebEngineSettings; -class QQuickWebEngineFaviconProvider; -class QQuickWebEngineProfilePrivate; -class QQuickWebEngineTouchHandleProvider; -class QWebEngineFindTextResult; - -#if QT_CONFIG(webengine_testsupport) -class QQuickWebEngineTestSupport; -#endif - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewPrivate : public QtWebEngineCore::WebContentsAdapterClient -{ -public: - Q_DECLARE_PUBLIC(QQuickWebEngineView) - QQuickWebEngineView *q_ptr; - QQuickWebEngineViewPrivate(); - ~QQuickWebEngineViewPrivate(); - void releaseProfile() override; - void initializeProfile(); - QtWebEngineCore::UIDelegatesManager *ui(); - - QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override; - QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override; - 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 = false, int errorCode = 0, const QString &errorDescription = QString()) override; - void focusContainer() override; - void unhandledKeyEvent(QKeyEvent *event) override; - QSharedPointer<QtWebEngineCore::WebContentsAdapter> - adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, - WindowOpenDisposition disposition, bool userGesture, const QRect &, - const QUrl &targetUrl) override; - bool isBeingAdopted() override; - void close() override; - void windowCloseRejected() override; - void requestFullScreenMode(const QUrl &origin, bool fullscreen) override; - bool isFullScreenMode() const override; - void contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) override; - void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) override; - void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) override; - void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) override; - void showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController>) override; - void didRunJavaScript(quint64, const QVariant&) override; - void didFetchDocumentMarkup(quint64, const QString&) override { } - void didFetchDocumentInnerText(quint64, const QString&) override { } - void didPrintPage(quint64 requestId, QSharedPointer<QByteArray>) 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 runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) 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> &errorController) override; - void selectClientCert(const QSharedPointer<ClientCertSelectController> &selectController) override; - void runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin) 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; - QtWebEngineCore::TouchHandleDrawableClient *createTouchHandle(const QMap<int, QImage> &images) override; - void showTouchSelectionMenu(QtWebEngineCore::TouchSelectionMenuController *, const QRect &, const QSize &) override; - void hideTouchSelectionMenu() override; - const QObject *holdingQObject() const override; - ClientType clientType() override { return QtWebEngineCore::WebContentsAdapterClient::QmlClient; } - - QtWebEngineCore::ProfileAdapter *profileAdapter() override; - QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; - void printRequested() override; - void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidgetBase) override; - void findTextFinished(const QWebEngineFindTextResult &result) override; - - void updateAction(QQuickWebEngineView::WebAction) const; - void adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents); - void setProfile(QQuickWebEngineProfile *profile); - void updateAdapter(); - void ensureContentsAdapter(); - void setFullScreenMode(bool); - - static void bindViewAndWidget(QQuickWebEngineView *view, QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick *widget); - void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick *oldWidget, - QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick *newWidget); - - // QQmlListPropertyHelpers - static void userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script); - static int userScripts_count(QQmlListProperty<QQuickWebEngineScript> *p); - static QQuickWebEngineScript *userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx); - static void userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p); - - QQuickWebEngineProfile *m_profile; - QSharedPointer<QtWebEngineCore::WebContentsAdapter> adapter; - QScopedPointer<QQuickWebEngineHistory> m_history; - QScopedPointer<QQuickWebEngineSettings> m_settings; -#if QT_CONFIG(webengine_testsupport) - QQuickWebEngineTestSupport *m_testSupport; -#endif - QQmlComponent *contextMenuExtraItems; - QtWebEngineCore::WebEngineContextMenuData m_contextMenuData; - QUrl m_url; - QString m_html; - QUrl iconUrl; - QQuickWebEngineFaviconProvider *faviconProvider; - int loadProgress; - bool m_fullscreenMode; - bool isLoading; - bool m_activeFocusOnPress; - bool m_navigationActionTriggered; - qreal devicePixelRatio; - QMap<quint64, QJSValue> m_callbacks; - QList<QSharedPointer<CertificateErrorController> > m_certificateErrorControllers; - QQmlWebChannel *m_webChannel; - QPointer<QQuickWebEngineView> inspectedView; - QPointer<QQuickWebEngineView> devToolsView; - uint m_webChannelWorld; - bool m_defaultAudioMuted; - bool m_isBeingAdopted; - mutable QQuickWebEngineAction *actions[QQuickWebEngineView::WebActionCount]; - QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick *widget = nullptr; - - bool profileInitialized() const; - -private: - QScopedPointer<QtWebEngineCore::UIDelegatesManager> m_uIDelegatesManager; - QList<QQuickWebEngineScript *> m_userScripts; - QColor m_backgroundColor; - qreal m_zoomFactor; - bool m_ui2Enabled; - bool m_profileInitialized; -}; - -#ifndef QT_NO_ACCESSIBILITY -class QQuickWebEngineViewAccessible : public QAccessibleObject -{ -public: - QQuickWebEngineViewAccessible(QQuickWebEngineView *o); - bool isValid() const override; - QAccessibleInterface *parent() const override; - QAccessibleInterface *focusChild() const override; - int childCount() const override; - QAccessibleInterface *child(int index) const override; - int indexOfChild(const QAccessibleInterface*) const override; - QString text(QAccessible::Text) const override; - QAccessible::Role role() const override; - QAccessible::State state() const override; - -private: - QQuickWebEngineView *engineView() const { return static_cast<QQuickWebEngineView*>(object()); } -}; -#endif // QT_NO_ACCESSIBILITY - -class QQuickContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt -{ -public: - QQuickContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data, QQuickWebEngineView *view, QObject *menu); - void appendExtraItems(QQmlEngine *engine); - -private: - virtual bool hasInspector() override; - virtual bool isFullScreenMode() override; - - virtual void addMenuItem(ContextMenuItem menuItem) override; - virtual bool isMenuItemEnabled(ContextMenuItem menuItem) override; - - QQuickWebEngineView *m_view; - QObject *m_menu; -}; - -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTouchHandle : public QtWebEngineCore::TouchHandleDrawableClient { -public: - QQuickWebEngineTouchHandle(QtWebEngineCore::UIDelegatesManager *ui, const QMap<int, QImage> &images); - - void setImage(int orientation) override; - void setBounds(const QRect &bounds) override; - void setVisible(bool visible) override; - void setOpacity(float opacity) override; - -private: - QScopedPointer<QQuickItem> m_item; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEVIEW_P_P_H diff --git a/src/webengine/api/qtwebengineglobal.cpp b/src/webengine/api/qtwebengineglobal.cpp deleted file mode 100644 index 4346832c9..000000000 --- a/src/webengine/api/qtwebengineglobal.cpp +++ /dev/null @@ -1,87 +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 "qtwebengineglobal.h" -#include <QCoreApplication> - -namespace QtWebEngineCore -{ - extern void initialize(); -} - -QT_BEGIN_NAMESPACE - -namespace QtWebEngine { - -/*! - \namespace QtWebEngine - \inmodule QtWebEngine - \ingroup qtwebengine-namespaces - \keyword QtWebEngine Namespace - - \brief Helper functions for the \QWE (Qt Quick) module. - - The \l[CPP]{QtWebEngine} namespace is part of the \QWE module. -*/ - -/*! - \fn QtWebEngine::initialize() - - Sets up an OpenGL Context that can be shared between threads. This has to be done before - QGuiApplication is created and before window's QPlatformOpenGLContext is created. - - This has the same effect as setting the Qt::AA_ShareOpenGLContexts - attribute with QCoreApplication::setAttribute before constructing - QGuiApplication. -*/ -void initialize() -{ - QCoreApplication *app = QCoreApplication::instance(); - if (app) { - qWarning("QtWebEngine::initialize() called with QCoreApplication object already created and should be call before. "\ - "This is depreciated and may fail in the future."); - QtWebEngineCore::initialize(); - return; - } - // call initialize the same way as widgets do - qAddPreRoutine(QtWebEngineCore::initialize); -} -} // namespace QtWebEngine - -QT_END_NAMESPACE diff --git a/src/webengine/api/qtwebengineglobal.h b/src/webengine/api/qtwebengineglobal.h deleted file mode 100644 index c2b33778a..000000000 --- a/src/webengine/api/qtwebengineglobal.h +++ /dev/null @@ -1,65 +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 QTWEBENGINEGLOBAL_H -#define QTWEBENGINEGLOBAL_H - -#include <QtCore/qglobal.h> -#include <QtWebEngine/qtwebengine-config.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_WEBENGINE_LIB) -# define Q_WEBENGINE_EXPORT Q_DECL_EXPORT -# else -# define Q_WEBENGINE_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_WEBENGINE_EXPORT -#endif - -namespace QtWebEngine -{ - Q_WEBENGINE_EXPORT void initialize(); -} - -QT_END_NAMESPACE - -#endif // QTWEBENGINEGLOBAL_H diff --git a/src/webengine/api/qtwebengineglobal_p.h b/src/webengine/api/qtwebengineglobal_p.h deleted file mode 100644 index 2d30f75b0..000000000 --- a/src/webengine/api/qtwebengineglobal_p.h +++ /dev/null @@ -1,64 +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 QTWEBENGINEGLOBAL_P_H -#define QTWEBENGINEGLOBAL_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 <QtWebEngine/qtwebengineglobal.h> -#include <QtCore/private/qglobal_p.h> -#include <QtWebEngine/private/qtwebengine-config_p.h> - -QT_BEGIN_NAMESPACE - -#define Q_WEBENGINE_PRIVATE_EXPORT Q_WEBENGINE_EXPORT - -QT_END_NAMESPACE - -#endif // QTWEBENGINEGLOBAL_P_H |