diff options
Diffstat (limited to 'src/webengine/api')
37 files changed, 0 insertions, 10392 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/qquickwebengineclientcertificateselection.cpp b/src/webengine/api/qquickwebengineclientcertificateselection.cpp deleted file mode 100644 index f6c37a5b0..000000000 --- a/src/webengine/api/qquickwebengineclientcertificateselection.cpp +++ /dev/null @@ -1,227 +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<QtWebEngineCore::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()) { - QList<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 fe868e76c..000000000 --- a/src/webengine/api/qquickwebengineclientcertificateselection_p.h +++ /dev/null @@ -1,135 +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/QList> -#include <QtQml/QQmlListProperty> - -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) - -namespace QtWebEngineCore { -class ClientCertSelectController; -} - -QT_BEGIN_NAMESPACE - -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<QtWebEngineCore::ClientCertSelectController>); - - mutable QList<QQuickWebEngineClientCertificateOption *> m_certificates; - QSharedPointer<QtWebEngineCore::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/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/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 c264a73f9..000000000 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ /dev/null @@ -1,1059 +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 "qquickwebengineprofile_p.h" -#include "qquickwebenginesettings_p.h" -#include "qwebenginescriptcollection.h" -#include "qwebenginescriptcollection_p.h" -#include "qquickwebenginescriptcollection.h" -#include "qquickwebengineview_p_p.h" -#include "qwebenginecookiestore.h" -#include "qwebenginenotification.h" -#include <QFileInfo> -#include <QDir> -#include <QQmlEngine> -#include <QtQml/QQmlInfo> - -#include "profile_adapter.h" -#include "web_engine_settings.h" - -#include <QtWebEngineCore/private/qwebenginedownloadrequest_p.h> -#include <QtWebEngineCore/qwebengineurlscheme.h> - -using QtWebEngineCore::ProfileAdapter; - -QT_BEGIN_NAMESPACE - -/*! - \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(QWebEngineDownloadRequest *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{QWebEngineDownloadRequest::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(QWebEngineDownloadRequest *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) - , m_scriptCollection(new QQuickWebEngineScriptCollection(new QWebEngineScriptCollection( - new QWebEngineScriptCollectionPrivate(profileAdapter->userResourceController())))) -{ - profileAdapter->addClient(this); - // 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(QWebEngineSettings::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)); - QWebEngineDownloadRequestPrivate *itemPrivate = new QWebEngineDownloadRequestPrivate(m_profileAdapter, info.url); - itemPrivate->downloadId = info.id; - itemPrivate->downloadState = QWebEngineDownloadRequest::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<QWebEngineDownloadRequest::SavePageFormat>( - info.savePageFormat); - itemPrivate->isSavePageDownload = info.isSavePageDownload; - if (info.page && info.page->clientType() == QtWebEngineCore::WebContentsAdapterClient::QmlClient) - itemPrivate->page = static_cast<QQuickWebEngineViewPrivate *>(info.page)->q_ptr; - else - itemPrivate->page = nullptr; - - QWebEngineDownloadRequest *download = new QWebEngineDownloadRequest(itemPrivate, q); - - m_ongoingDownloads.insert(info.id, download); - QObject::connect(download, &QWebEngineDownloadRequest::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); }); - - QQmlEngine::setObjectOwnership(download, QQmlEngine::JavaScriptOwnership); - Q_EMIT q->downloadRequested(download); - - QWebEngineDownloadRequest::DownloadState state = download->state(); - info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName()); - info.savePageFormat = itemPrivate->savePageFormat; - info.accepted = state != QWebEngineDownloadRequest::DownloadCancelled - && state != QWebEngineDownloadRequest::DownloadRequested; - - if (state == QWebEngineDownloadRequest::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); - - QWebEngineDownloadRequest* 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); -} - -/*! - \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 -*/ - -QQuickWebEngineScriptCollection *QQuickWebEngineProfile::userScripts() const -{ - const Q_D(QQuickWebEngineProfile); - return d->m_scriptCollection.data(); -} - -/*! - \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 - -#include "moc_qquickwebengineprofile.cpp" diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h deleted file mode 100644 index a0480b424..000000000 --- a/src/webengine/api/qquickwebengineprofile.h +++ /dev/null @@ -1,192 +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> - -QT_BEGIN_NAMESPACE - -class QWebEngineDownloadRequest; -class QWebEngineScript; -class QQuickWebEngineSettings; -class QWebEngineClientCertificateStore; -class QWebEngineCookieStore; -class QWebEngineNotification; -class QWebEngineUrlRequestInterceptor; -class QWebEngineUrlSchemeHandler; -class QQuickWebEngineScriptCollection; -class QQuickWebEngineProfilePrivate; - -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(QQuickWebEngineScriptCollection *userScripts READ userScripts) - 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; - - QQuickWebEngineScriptCollection *userScripts() const; - - 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(QWebEngineDownloadRequest *download); - void downloadFinished(QWebEngineDownloadRequest *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 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 b9b52a693..000000000 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef 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 QWebEngineDownloadRequest; -class QQuickWebEngineSettings; -class QQuickWebEngineViewPrivate; -class QQuickWebEngineScriptCollection; - -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; - -private: - friend class QQuickWebEngineView; - QQuickWebEngineProfile *q_ptr; - QScopedPointer<QQuickWebEngineSettings> m_settings; - QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter; - QMap<quint32, QPointer<QWebEngineDownloadRequest> > m_ongoingDownloads; - QScopedPointer<QQuickWebEngineScriptCollection> m_scriptCollection; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEPROFILE_P_H diff --git a/src/webengine/api/qquickwebenginescriptcollection.cpp b/src/webengine/api/qquickwebenginescriptcollection.cpp deleted file mode 100644 index c0939d72f..000000000 --- a/src/webengine/api/qquickwebenginescriptcollection.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 "qquickwebenginescriptcollection.h" -#include "qwebenginescriptcollection.h" -#include "qwebenginescriptcollection_p.h" -#include <QtQml/QQmlInfo> -#include <QtQml/private/qqmlengine_p.h> -#include <QtQml/private/qv4scopedvalue_p.h> -#include <QtQml/private/qv4arrayobject_p.h> - -QWebEngineScript parseScript(const QJSValue &value, bool *ok) -{ - QWebEngineScript s; - if (ok) - *ok = false; - - if (value.isObject()) { - - if (value.hasProperty(QStringLiteral("name"))) - s.setName(value.property(QStringLiteral("name")).toString()); - - if (value.hasProperty(QStringLiteral("sourceUrl"))) - s.setSourceUrl(value.property(QStringLiteral("sourceUrl")).toString()); - - if (value.hasProperty(QStringLiteral("injectionPoint"))) - s.setInjectionPoint(QWebEngineScript::InjectionPoint( - value.property(QStringLiteral("injectionPoint")).toUInt())); - - if (value.hasProperty(QStringLiteral("sourceCode"))) - s.setSourceCode(value.property(QStringLiteral("sourceCode")).toString()); - - if (value.hasProperty(QStringLiteral("worldId"))) - s.setWorldId(QWebEngineScript::ScriptWorldId( - value.property(QStringLiteral("worldId")).toUInt())); - - if (value.hasProperty(QStringLiteral("runOnSubframes"))) - s.setRunsOnSubFrames(value.property(QStringLiteral("runOnSubframes")).toBool()); - - if (ok) - *ok = true; - } - return s; -} - -QQuickWebEngineScriptCollection::QQuickWebEngineScriptCollection( - QWebEngineScriptCollection *collection) - : d(collection) -{ -} - -QQuickWebEngineScriptCollection::~QQuickWebEngineScriptCollection() { } - -bool QQuickWebEngineScriptCollection::contains(const QWebEngineScript &value) const -{ - return d->contains(value); -} - -QList<QWebEngineScript> QQuickWebEngineScriptCollection::find(const QString &name) const -{ - return d->find(name); -} - -void QQuickWebEngineScriptCollection::insert(const QWebEngineScript &s) -{ - d->insert(s); -} - -void QQuickWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list) -{ - d->insert(list); -} - -bool QQuickWebEngineScriptCollection::remove(const QWebEngineScript &script) -{ - return d->remove(script); -} - -void QQuickWebEngineScriptCollection::clear() -{ - d->clear(); -} - -QJSValue QQuickWebEngineScriptCollection::collection() const -{ - const QList<QWebEngineScript> &list = d->toList(); - QQmlContext *context = QQmlEngine::contextForObject(this); - QQmlEngine *engine = context->engine(); - QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine); - QV4::Scope scope(v4); - QV4::Scoped<QV4::ArrayObject> scriptArray(scope, v4->newArrayObject(list.length())); - int i = 0; - for (const auto &val : list) { - QV4::ScopedValue sv(scope, v4->fromVariant(QVariant::fromValue(val))); - scriptArray->put(i++, sv); - } - return QJSValuePrivate::fromReturnedValue(scriptArray.asReturnedValue()); -} - -void QQuickWebEngineScriptCollection::setCollection(const QJSValue &scripts) -{ - if (!scripts.isArray()) - return; - - QList<QWebEngineScript> scriptList; - quint32 length = scripts.property(QStringLiteral("length")).toUInt(); - for (quint32 i = 0; i < length; ++i) { - bool ok; - QWebEngineScript s = parseScript(scripts.property(i), &ok); - if (!ok) { - qmlWarning(this) << "Unsupported script type"; - return; - } - scriptList.append(s); - } - if (scriptList != d->toList()) { - clear(); - insert(scriptList); - Q_EMIT collectionChanged(); - } -} diff --git a/src/webengine/api/qquickwebenginescriptcollection.h b/src/webengine/api/qquickwebenginescriptcollection.h deleted file mode 100644 index 8ae3dc02b..000000000 --- a/src/webengine/api/qquickwebenginescriptcollection.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 QQUICKWEBENGINESCRIPTCOLLECTION_H -#define QQUICKWEBENGINESCRIPTCOLLECTION_H - -#include <QtWebEngine/qtwebengineglobal.h> -#include <QtWebEngineCore/qwebenginescript.h> -#include <QtCore/qscopedpointer.h> -#include <QtCore/qlist.h> -#include <QtCore/qset.h> -#include <QtCore/QObject> -#include <QtQml/QJSValue> - -QT_BEGIN_NAMESPACE -class QWebEngineScriptCollection; - -class Q_WEBENGINE_EXPORT QQuickWebEngineScriptCollection : public QObject -{ - Q_OBJECT -public: - Q_PROPERTY(QJSValue collection READ collection WRITE setCollection NOTIFY collectionChanged) - ~QQuickWebEngineScriptCollection(); - - Q_INVOKABLE bool contains(const QWebEngineScript &value) const; - Q_INVOKABLE QList<QWebEngineScript> find(const QString &name) const; - Q_INVOKABLE void insert(const QWebEngineScript &); - Q_INVOKABLE void insert(const QList<QWebEngineScript> &list); - Q_INVOKABLE bool remove(const QWebEngineScript &); - Q_INVOKABLE void clear(); - - QJSValue collection() const; - void setCollection(const QJSValue &scripts); - -Q_SIGNALS: - void collectionChanged(); - -private: - Q_DISABLE_COPY(QQuickWebEngineScriptCollection) - QQuickWebEngineScriptCollection(QWebEngineScriptCollection *d); - QScopedPointer<QWebEngineScriptCollection> d; - friend class QQuickWebEngineProfilePrivate; - friend class QQuickWebEngineViewPrivate; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QQuickWebEngineScriptCollection *) - -#endif // QWEBENGINESCRIPTCOLLECTION_H diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp deleted file mode 100644 index 8728cc51a..000000000 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ /dev/null @@ -1,765 +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 QWebEngineSettings(parentSettings ? parentSettings->d_ptr.data() : nullptr)) -{ } - -/*! - \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(QWebEngineSettings::AutoLoadImages); -} - -/*! - \qmlproperty bool WebEngineSettings::javascriptEnabled - - Enables the running of JavaScript programs. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::javascriptEnabled() const -{ - return d_ptr->testAttribute(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::JavascriptCanAccessClipboard); -} - -/*! - \qmlproperty bool WebEngineSettings::linksIncludedInFocusChain - - Includes hyperlinks in the keyboard focus chain. - - Enabled by default. -*/ -bool QQuickWebEngineSettings::linksIncludedInFocusChain() const -{ - return d_ptr->testAttribute(QWebEngineSettings::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(QWebEngineSettings::LocalStorageEnabled); -} - -/*! - \qmlproperty bool WebEngineSettings::localContentCanAccessRemoteUrls - - Allows locally loaded documents to access remote URLs. - - Disabled by default. -*/ -bool QQuickWebEngineSettings::localContentCanAccessRemoteUrls() const -{ - return d_ptr->testAttribute(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::AllowWindowActivationFromJavaScript); -} - -/*! - \qmlproperty bool WebEngineSettings::showScrollBars - \since QtWebEngine 1.6 - Shows scroll bars. Enabled by default. -*/ -bool QQuickWebEngineSettings::showScrollBars() const -{ - return d_ptr->testAttribute(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::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, QWebEngineSettings::DisallowUnknownUrlSchemes) -ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction) -ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowAllUnknownUrlSchemes, QWebEngineSettings::AllowAllUnknownUrlSchemes) - -/*! - \qmlproperty QWebEngineSettings::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(QWebEngineSettings::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(QWebEngineSettings::AutoLoadImages, on); - if (wasOn != on) - Q_EMIT autoLoadImagesChanged(); -} - -void QQuickWebEngineSettings::setJavascriptEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::JavascriptEnabled); - d_ptr->setAttribute(QWebEngineSettings::JavascriptEnabled, on); - if (wasOn != on) - Q_EMIT javascriptEnabledChanged(); -} - -void QQuickWebEngineSettings::setJavascriptCanOpenWindows(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows); - d_ptr->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, on); - if (wasOn != on) - Q_EMIT javascriptCanOpenWindowsChanged(); -} - -void QQuickWebEngineSettings::setJavascriptCanAccessClipboard(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard); - d_ptr->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, on); - if (wasOn != on) - Q_EMIT javascriptCanAccessClipboardChanged(); -} - -void QQuickWebEngineSettings::setLinksIncludedInFocusChain(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain); - d_ptr->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, on); - if (wasOn != on) - Q_EMIT linksIncludedInFocusChainChanged(); -} - -void QQuickWebEngineSettings::setLocalStorageEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::LocalStorageEnabled); - d_ptr->setAttribute(QWebEngineSettings::LocalStorageEnabled, on); - if (wasOn != on) - Q_EMIT localStorageEnabledChanged(); -} - -void QQuickWebEngineSettings::setLocalContentCanAccessRemoteUrls(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls); - d_ptr->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, on); - if (wasOn != on) - Q_EMIT localContentCanAccessRemoteUrlsChanged(); -} - - -void QQuickWebEngineSettings::setSpatialNavigationEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::SpatialNavigationEnabled); - d_ptr->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, on); - if (wasOn != on) - Q_EMIT spatialNavigationEnabledChanged(); -} - -void QQuickWebEngineSettings::setLocalContentCanAccessFileUrls(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls); - d_ptr->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, on); - if (wasOn != on) - Q_EMIT localContentCanAccessFileUrlsChanged(); -} - -void QQuickWebEngineSettings::setHyperlinkAuditingEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled); - d_ptr->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, on); - if (wasOn != on) - Q_EMIT hyperlinkAuditingEnabledChanged(); -} - -void QQuickWebEngineSettings::setErrorPageEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::ErrorPageEnabled); - d_ptr->setAttribute(QWebEngineSettings::ErrorPageEnabled, on); - if (wasOn != on) - Q_EMIT errorPageEnabledChanged(); -} - -void QQuickWebEngineSettings::setPluginsEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::PluginsEnabled); - d_ptr->setAttribute(QWebEngineSettings::PluginsEnabled, on); - if (wasOn != on) - Q_EMIT pluginsEnabledChanged(); -} - -void QQuickWebEngineSettings::setFullScreenSupportEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::FullScreenSupportEnabled); - d_ptr->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, on); - if (wasOn != on) - Q_EMIT fullScreenSupportEnabledChanged(); -} - -void QQuickWebEngineSettings::setScreenCaptureEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::ScreenCaptureEnabled); - d_ptr->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, on); - if (wasOn != on) - Q_EMIT screenCaptureEnabledChanged(); -} - -void QQuickWebEngineSettings::setWebGLEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::WebGLEnabled); - d_ptr->setAttribute(QWebEngineSettings::WebGLEnabled, on); - if (wasOn != on) - Q_EMIT webGLEnabledChanged(); -} - -void QQuickWebEngineSettings::setAccelerated2dCanvasEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled); - d_ptr->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, on); - if (wasOn != on) - Q_EMIT accelerated2dCanvasEnabledChanged(); -} - -void QQuickWebEngineSettings::setAutoLoadIconsForPage(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::AutoLoadIconsForPage); - d_ptr->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, on); - if (wasOn != on) - Q_EMIT autoLoadIconsForPageChanged(); -} - -void QQuickWebEngineSettings::setTouchIconsEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::TouchIconsEnabled); - d_ptr->setAttribute(QWebEngineSettings::TouchIconsEnabled, on); - if (wasOn != on) - Q_EMIT touchIconsEnabledChanged(); -} - -void QQuickWebEngineSettings::setPrintElementBackgrounds(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::PrintElementBackgrounds); - d_ptr->setAttribute(QWebEngineSettings::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(QWebEngineSettings::FocusOnNavigationEnabled); - d_ptr->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, on); - if (wasOn != on) - Q_EMIT focusOnNavigationEnabledChanged(); -} - - -void QQuickWebEngineSettings::setAllowRunningInsecureContent(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::AllowRunningInsecureContent); - d_ptr->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, on); - if (wasOn != on) - Q_EMIT allowRunningInsecureContentChanged(); -} - -void QQuickWebEngineSettings::setAllowGeolocationOnInsecureOrigins(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::AllowGeolocationOnInsecureOrigins); - d_ptr->setAttribute(QWebEngineSettings::AllowGeolocationOnInsecureOrigins, on); - if (wasOn != on) - Q_EMIT allowGeolocationOnInsecureOriginsChanged(); -} - -void QQuickWebEngineSettings::setAllowWindowActivationFromJavaScript(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript); - d_ptr->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, on); - if (wasOn != on) - Q_EMIT allowWindowActivationFromJavaScriptChanged(); -} - -void QQuickWebEngineSettings::setShowScrollBars(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::ShowScrollBars); - d_ptr->setAttribute(QWebEngineSettings::ShowScrollBars, on); - if (wasOn != on) - Q_EMIT showScrollBarsChanged(); -} - -void QQuickWebEngineSettings::setPlaybackRequiresUserGesture(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::PlaybackRequiresUserGesture); - d_ptr->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, on); - if (wasOn != on) - Q_EMIT playbackRequiresUserGestureChanged(); -} - -void QQuickWebEngineSettings::setJavascriptCanPaste(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::JavascriptCanPaste); - d_ptr->setAttribute(QWebEngineSettings::JavascriptCanPaste, on); - if (wasOn != on) - Q_EMIT javascriptCanPasteChanged(); -} - -void QQuickWebEngineSettings::setDnsPrefetchEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::DnsPrefetchEnabled); - d_ptr->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, on); - if (wasOn != on) - Q_EMIT dnsPrefetchEnabledChanged(); -} - -void QQuickWebEngineSettings::setPdfViewerEnabled(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::PdfViewerEnabled); - d_ptr->setAttribute(QWebEngineSettings::PdfViewerEnabled, on); - if (wasOn != on) - Q_EMIT pdfViewerEnabledChanged(); -} - -void QQuickWebEngineSettings::setUnknownUrlSchemePolicy(QQuickWebEngineSettings::UnknownUrlSchemePolicy policy) -{ - QWebEngineSettings::UnknownUrlSchemePolicy oldPolicy = d_ptr->unknownUrlSchemePolicy(); - QWebEngineSettings::UnknownUrlSchemePolicy newPolicy = static_cast<QWebEngineSettings::UnknownUrlSchemePolicy>(policy); - d_ptr->setUnknownUrlSchemePolicy(newPolicy); - if (oldPolicy != newPolicy) - Q_EMIT unknownUrlSchemePolicyChanged(); -} - -void QQuickWebEngineSettings::setWebRTCPublicInterfacesOnly(bool on) -{ - bool wasOn = d_ptr->testAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly); - d_ptr->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, on); - if (wasOn != on) - Q_EMIT webRTCPublicInterfacesOnlyChanged(); -} - -void QQuickWebEngineSettings::setParentSettings(QQuickWebEngineSettings *parentSettings) -{ - d_ptr->setParentSettings(parentSettings->d_ptr.data()); -} - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h deleted file mode 100644 index 20db86448..000000000 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ /dev/null @@ -1,220 +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 QWebEngineSettings; -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<QWebEngineSettings> 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 d49d92329..000000000 --- a/src/webengine/api/qquickwebenginesingleton.cpp +++ /dev/null @@ -1,101 +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(); -} - -QWebEngineScript QQuickWebEngineSingleton::script() const -{ - return QWebEngineScript(); -} - -#include "moc_qquickwebenginesingleton_p.cpp" - -QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebenginesingleton_p.h b/src/webengine/api/qquickwebenginesingleton_p.h deleted file mode 100644 index bca106314..000000000 --- a/src/webengine/api/qquickwebenginesingleton_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 <QtWebEngineCore/qwebenginescript.h> -#include <QtCore/qobject.h> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineSettings; -class QQuickWebEngineProfile; - -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; - Q_INVOKABLE QWebEngineScript script() 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 56162b223..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.insert(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 fe9d32b8b..000000000 --- a/src/webengine/api/qquickwebengineview.cpp +++ /dev/null @@ -1,2464 +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 "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 "qquickwebengineclientcertificateselection_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 "qquickwebenginetouchhandleprovider_p_p.h" -#include "qwebenginecertificateerror.h" -#include "qwebenginefindtextresult.h" -#include "qwebenginefullscreenrequest.h" -#include "qwebenginequotarequest.h" -#include "qwebenginescriptcollection.h" -#include "qwebenginescriptcollection_p.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 "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) - , m_contextMenuRequest(nullptr) -{ - 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); - m_scriptCollection.reset(new QQuickWebEngineScriptCollection( - new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate( - profileAdapter()->userResourceController(), adapter)))); - } -} - -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(QWebEngineContextMenuRequest *request) -{ - Q_Q(QQuickWebEngineView); - - m_contextMenuRequest = request; - - // FIXME: we most liekly do not need to make any copy here - auto *r = new QWebEngineContextMenuRequest( - new QWebEngineContextMenuRequestPrivate(*request->d.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(r); - Q_EMIT q->contextMenuRequested(r); - - if (r->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(), r->position()); - if (!menu) - return; - - QQuickContextMenuBuilder contextMenuBuilder(r, 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 QWebEngineCertificateError &error) -{ - Q_Q(QQuickWebEngineView); - Q_EMIT q->certificateError(error); -} - -void QQuickWebEngineViewPrivate::selectClientCert( - const QSharedPointer<QtWebEngineCore::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(); - - QTimer::singleShot(0, q, [q, provisionalUrl]() { - QQuickWebEngineLoadRequest loadRequest(provisionalUrl, QQuickWebEngineView::LoadStartedStatus); - - emit q->loadingChanged(&loadRequest); - }); -} - -void QQuickWebEngineViewPrivate::loadCommitted() -{ - m_history->reset(); -} - -void QQuickWebEngineViewPrivate::didFirstVisuallyNonEmptyPaint() -{ -#if QT_CONFIG(webengine_testsupport) - if (m_loadVisuallyCommittedState == NotCommitted) { - m_loadVisuallyCommittedState = DidFirstVisuallyNonEmptyPaint; - } else if (m_loadVisuallyCommittedState == DidFirstCompositorFrameSwap) { - if (m_testSupport) - Q_EMIT m_testSupport->loadVisuallyCommitted(); - m_loadVisuallyCommittedState = NotCommitted; - } -#endif -} - -void QQuickWebEngineViewPrivate::didCompositorFrameSwap() -{ -#if QT_CONFIG(webengine_testsupport) - if (m_loadVisuallyCommittedState == NotCommitted) { - m_loadVisuallyCommittedState = DidFirstCompositorFrameSwap; - } else if (m_loadVisuallyCommittedState == DidFirstVisuallyNonEmptyPaint) { - if (m_testSupport) - Q_EMIT m_testSupport->loadVisuallyCommitted(); - m_loadVisuallyCommittedState = NotCommitted; - } -#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); - QWebEngineFullScreenRequest request(origin, fullscreen, [q = QPointer(q)] (bool toggleOn) { if (q) q->d_ptr->setFullScreenMode(toggleOn); }); - 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); -} - -QWebEngineSettings *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); - - m_scriptCollection->d->d->initializationFinished(adapter); - - 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(); -} - -QQuickWebEngineScriptCollection *QQuickWebEngineView::userScripts() -{ - Q_D(QQuickWebEngineView); - return d->m_scriptCollection.data(); -} - -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, QWebEngineScript::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::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - QQuickItem::geometryChange(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 QPointF mapToScreen(const QQuickItem *item, const QPointF &clientPos) -{ - return item->window()->position() + item->mapToScene(clientPos); -} - -void QQuickWebEngineView::dragEnterEvent(QDragEnterEvent *e) -{ - Q_D(QQuickWebEngineView); - e->accept(); - d->adapter->enterDrag(e, mapToScreen(this, e->position())); -} - -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->position())); - 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->position())); -} -#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_contextMenuRequest->filteredLinkUrl().isValid()) - setUrl(d->m_contextMenuRequest->filteredLinkUrl()); - break; - case OpenLinkInNewWindow: - if (d->m_contextMenuRequest->filteredLinkUrl().isValid()) { - QQuickWebEngineNewViewRequest request; - request.m_requestedUrl = d->m_contextMenuRequest->filteredLinkUrl(); - request.m_isUserInitiated = true; - request.m_destination = NewViewInWindow; - Q_EMIT newViewRequested(&request); - } - break; - case OpenLinkInNewTab: - if (d->m_contextMenuRequest->filteredLinkUrl().isValid()) { - QQuickWebEngineNewViewRequest request; - request.m_requestedUrl = d->m_contextMenuRequest->filteredLinkUrl(); - request.m_isUserInitiated = true; - request.m_destination = NewViewInBackgroundTab; - Q_EMIT newViewRequested(&request); - } - break; - case CopyLinkToClipboard: - if (!d->m_contextMenuRequest->linkUrl().isEmpty()) { - QString urlString = - d->m_contextMenuRequest->linkUrl().toString(QUrl::FullyEncoded); - QString linkText = d->m_contextMenuRequest->linkText().toHtmlEscaped(); - QString title = d->m_contextMenuRequest->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_contextMenuRequest->linkUrl()); - qApp->clipboard()->setMimeData(data); - } - break; - case DownloadLinkToDisk: - if (d->m_contextMenuRequest->filteredLinkUrl().isValid()) - d->adapter->download(d->m_contextMenuRequest->filteredLinkUrl(), - d->m_contextMenuRequest->suggestedFileName(), - d->m_contextMenuRequest->referrerUrl(), - d->m_contextMenuRequest->referrerPolicy()); - break; - case CopyImageToClipboard: - if (d->m_contextMenuRequest->hasImageContent() - && (d->m_contextMenuRequest->mediaType() == QWebEngineContextMenuRequest::MediaTypeImage - || d->m_contextMenuRequest->mediaType() - == QWebEngineContextMenuRequest::MediaTypeCanvas)) { - d->adapter->copyImageAt(d->m_contextMenuRequest->position()); - } - break; - case CopyImageUrlToClipboard: - if (d->m_contextMenuRequest->mediaUrl().isValid() - && d->m_contextMenuRequest->mediaType() - == QWebEngineContextMenuRequest::MediaTypeImage) { - QString urlString = d->m_contextMenuRequest->mediaUrl().toString(QUrl::FullyEncoded); - QString alt = d->m_contextMenuRequest->altText(); - if (!alt.isEmpty()) - alt = QStringLiteral(" alt=\"%1\"").arg(alt.toHtmlEscaped()); - QString title = d->m_contextMenuRequest->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_contextMenuRequest->mediaUrl()); - qApp->clipboard()->setMimeData(data); - } - break; - case DownloadImageToDisk: - case DownloadMediaToDisk: - if (d->m_contextMenuRequest->mediaUrl().isValid()) - d->adapter->download(d->m_contextMenuRequest->mediaUrl(), - d->m_contextMenuRequest->suggestedFileName(), - d->m_contextMenuRequest->referrerUrl(), - d->m_contextMenuRequest->referrerPolicy()); - break; - case CopyMediaUrlToClipboard: - if (d->m_contextMenuRequest->mediaUrl().isValid() - && (d->m_contextMenuRequest->mediaType() == QWebEngineContextMenuRequest::MediaTypeAudio - || d->m_contextMenuRequest->mediaType() - == QWebEngineContextMenuRequest::MediaTypeVideo)) { - QString urlString = d->m_contextMenuRequest->mediaUrl().toString(QUrl::FullyEncoded); - QString title = d->m_contextMenuRequest->titleText(); - if (!title.isEmpty()) - title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped()); - QMimeData *data = new QMimeData(); - data->setText(urlString); - if (d->m_contextMenuRequest->mediaType() - == QWebEngineContextMenuRequest::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_contextMenuRequest->mediaUrl()); - qApp->clipboard()->setMimeData(data); - } - break; - case ToggleMediaControls: - if (d->m_contextMenuRequest->mediaUrl().isValid() - && d->m_contextMenuRequest->mediaFlags() - & QWebEngineContextMenuRequest::MediaCanToggleControls) { - bool enable = !(d->m_contextMenuRequest->mediaFlags() - & QWebEngineContextMenuRequest::MediaControls); - d->adapter->executeMediaPlayerActionAt(d->m_contextMenuRequest->position(), - WebContentsAdapter::MediaPlayerControls, enable); - } - break; - case ToggleMediaLoop: - if (d->m_contextMenuRequest->mediaUrl().isValid() - && (d->m_contextMenuRequest->mediaType() == QWebEngineContextMenuRequest::MediaTypeAudio - || d->m_contextMenuRequest->mediaType() - == QWebEngineContextMenuRequest::MediaTypeVideo)) { - bool enable = !(d->m_contextMenuRequest->mediaFlags() - & QWebEngineContextMenuRequest::MediaLoop); - d->adapter->executeMediaPlayerActionAt(d->m_contextMenuRequest->position(), - WebContentsAdapter::MediaPlayerLoop, enable); - } - break; - case ToggleMediaPlayPause: - if (d->m_contextMenuRequest->mediaUrl().isValid() - && (d->m_contextMenuRequest->mediaType() == QWebEngineContextMenuRequest::MediaTypeAudio - || d->m_contextMenuRequest->mediaType() - == QWebEngineContextMenuRequest::MediaTypeVideo)) { - bool enable = (d->m_contextMenuRequest->mediaFlags() - & QWebEngineContextMenuRequest::MediaPaused); - d->adapter->executeMediaPlayerActionAt(d->m_contextMenuRequest->position(), - WebContentsAdapter::MediaPlayerPlay, enable); - } - break; - case ToggleMediaMute: - if (d->m_contextMenuRequest->mediaUrl().isValid() - && d->m_contextMenuRequest->mediaFlags() - & QWebEngineContextMenuRequest::MediaHasAudio) { - bool enable = !(d->m_contextMenuRequest->mediaFlags() - & QWebEngineContextMenuRequest::MediaMuted); - d->adapter->executeMediaPlayerActionAt(d->m_contextMenuRequest->position(), - WebContentsAdapter::MediaPlayerMute, enable); - } - break; - case InspectElement: - d->adapter->inspectElementAt(d->m_contextMenuRequest->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');"), QWebEngineScript::ApplicationWorld); - break; - case ToggleItalic: - runJavaScript(QStringLiteral("document.execCommand('italic');"), QWebEngineScript::ApplicationWorld); - break; - case ToggleUnderline: - runJavaScript(QStringLiteral("document.execCommand('underline');"), QWebEngineScript::ApplicationWorld); - break; - case ToggleStrikethrough: - runJavaScript(QStringLiteral("document.execCommand('strikethrough');"), QWebEngineScript::ApplicationWorld); - break; - case AlignLeft: - runJavaScript(QStringLiteral("document.execCommand('justifyLeft');"), QWebEngineScript::ApplicationWorld); - break; - case AlignCenter: - runJavaScript(QStringLiteral("document.execCommand('justifyCenter');"), QWebEngineScript::ApplicationWorld); - break; - case AlignRight: - runJavaScript(QStringLiteral("document.execCommand('justifyRight');"), QWebEngineScript::ApplicationWorld); - break; - case AlignJustified: - runJavaScript(QStringLiteral("document.execCommand('justifyFull');"), QWebEngineScript::ApplicationWorld); - break; - case Indent: - runJavaScript(QStringLiteral("document.execCommand('indent');"), QWebEngineScript::ApplicationWorld); - break; - case Outdent: - runJavaScript(QStringLiteral("document.execCommand('outdent');"), QWebEngineScript::ApplicationWorld); - break; - case InsertOrderedList: - runJavaScript(QStringLiteral("document.execCommand('insertOrderedList');"), QWebEngineScript::ApplicationWorld); - break; - case InsertUnorderedList: - runJavaScript(QStringLiteral("document.execCommand('insertUnorderedList');"), QWebEngineScript::ApplicationWorld); - break; - 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 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()); -} - -QQuickContextMenuBuilder::QQuickContextMenuBuilder(QWebEngineContextMenuRequest *request, - QQuickWebEngineView *view, QObject *menu) - : QtWebEngineCore::RenderViewContextMenuQt(request), 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() & QWebEngineContextMenuRequest::CanCut; - case ContextMenuItem::Copy: - return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanCopy; - case ContextMenuItem::Paste: - return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste; - case ContextMenuItem::Undo: - return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanUndo; - case ContextMenuItem::Redo: - return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanRedo; - case ContextMenuItem::SelectAll: - return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanSelectAll; - case ContextMenuItem::PasteAndMatchStyle: - return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste; - case ContextMenuItem::OpenLinkInNewWindow: - case ContextMenuItem::OpenLinkInNewTab: - case ContextMenuItem::CopyLinkToClipboard: - case ContextMenuItem::DownloadLinkToDisk: - case ContextMenuItem::CopyImageToClipboard: - case ContextMenuItem::CopyImageUrlToClipboard: - case ContextMenuItem::DownloadImageToDisk: - case ContextMenuItem::CopyMediaUrlToClipboard: - case ContextMenuItem::ToggleMediaControls: - case ContextMenuItem::ToggleMediaLoop: - case ContextMenuItem::DownloadMediaToDisk: - case ContextMenuItem::InspectElement: - case ContextMenuItem::ExitFullScreen: - case ContextMenuItem::SavePage: - return true; - case ContextMenuItem::ViewSource: - return m_view->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 - -#include "moc_qquickwebengineview_p.cpp" diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h deleted file mode 100644 index 255ca3d32..000000000 --- a/src/webengine/api/qquickwebengineview_p.h +++ /dev/null @@ -1,605 +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 <QtWebEngineCore/qtwebenginecoreglobal.h> -#include <QtWebEngine/private/qtwebengineglobal_p.h> -#include <QQuickItem> -#include <QtGui/qcolor.h> - -#include "qquickwebengineprofile.h" - -namespace QtWebEngineCore { -class RenderWidgetHostViewQtDelegateQuick; -} - -QT_BEGIN_NAMESPACE - -class QQmlWebChannel; -class QQuickContextMenuBuilder; -class QQuickWebEngineAction; -class QQuickWebEngineAuthenticationDialogRequest; -class QQuickWebEngineClientCertificateSelection; -class QQuickWebEngineColorDialogRequest; -class QQuickWebEngineFaviconProvider; -class QQuickWebEngineFileDialogRequest; -class QQuickWebEngineHistory; -class QQuickWebEngineJavaScriptDialogRequest; -class QQuickWebEngineLoadRequest; -class QQuickWebEngineNavigationRequest; -class QQuickWebEngineNewViewRequest; -class QQuickWebEngineSettings; -class QQuickWebEngineTooltipRequest; -class QQuickWebEngineFormValidationMessageRequest; -class QQuickWebEngineViewPrivate; -class QWebEngineCertificateError; -class QWebEngineFindTextResult; -class QWebEngineFullScreenRequest; -class QWebEngineQuotaRequest; -class QWebEngineRegisterProtocolHandlerRequest; -class QWebEngineContextMenuRequest; -class QQuickWebEngineScriptCollection; - -#if QT_CONFIG(webengine_testsupport) -class QQuickWebEngineTestSupport; -#endif - -#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) -#if QT_CONFIG(webengine_webchannel) - Q_PROPERTY(QQmlWebChannel *webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged REVISION 1 FINAL) -#endif - Q_PROPERTY(QQuickWebEngineScriptCollection *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 *); - QQuickWebEngineScriptCollection *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(const QWebEngineCertificateError &error); - Q_REVISION(1) void fullScreenRequested(const QWebEngineFullScreenRequest &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(QWebEngineContextMenuRequest *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 geometryChange(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 QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick; - 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) - -#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 b16263d5f..000000000 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ /dev/null @@ -1,291 +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 "qquickwebenginescriptcollection.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 QWebEngineContextMenuRequest; -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 didFirstVisuallyNonEmptyPaint() 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(QWebEngineContextMenuRequest *request) 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; - QWebEngineSettings *webEngineSettings() const override; - void allowCertificateError(const QWebEngineCertificateError &error) override; - void selectClientCert(const QSharedPointer<QtWebEngineCore::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 didCompositorFrameSwap(); - - 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); - - 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; - 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; - 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: - enum LoadVisuallyCommittedState { - NotCommitted, - DidFirstVisuallyNonEmptyPaint, - DidFirstCompositorFrameSwap - }; - - QScopedPointer<QtWebEngineCore::UIDelegatesManager> m_uIDelegatesManager; - QColor m_backgroundColor; - qreal m_zoomFactor; - bool m_ui2Enabled; - bool m_profileInitialized; - QWebEngineContextMenuRequest *m_contextMenuRequest; - LoadVisuallyCommittedState m_loadVisuallyCommittedState = NotCommitted; - QScopedPointer<QQuickWebEngineScriptCollection> m_scriptCollection; -}; - -#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(QWebEngineContextMenuRequest *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 825805888..000000000 --- a/src/webengine/api/qtwebengineglobal.cpp +++ /dev/null @@ -1,89 +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> -#include <QQuickWindow> - -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); - QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi); -} -} // 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 |