summaryrefslogtreecommitdiffstats
path: root/src/webengine/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/api')
-rw-r--r--src/webengine/api/qquickwebenginecertificateerror.cpp173
-rw-r--r--src/webengine/api/qquickwebenginecertificateerror_p.h97
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp272
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p.h96
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h (renamed from src/webengine/api/qquickwebenginesettings_p_p.h)31
-rw-r--r--src/webengine/api/qquickwebenginehistory.cpp4
-rw-r--r--src/webengine/api/qquickwebenginenewviewrequest.cpp46
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp410
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h131
-rw-r--r--src/webengine/api/qquickwebengineprofile_p_p.h80
-rw-r--r--src/webengine/api/qquickwebenginesettings.cpp192
-rw-r--r--src/webengine/api/qquickwebenginesettings_p.h38
-rw-r--r--src/webengine/api/qquickwebenginesingleton.cpp8
-rw-r--r--src/webengine/api/qquickwebenginesingleton_p.h4
-rw-r--r--src/webengine/api/qquickwebengineview.cpp247
-rw-r--r--src/webengine/api/qquickwebengineview_p.h29
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h34
17 files changed, 1679 insertions, 213 deletions
diff --git a/src/webengine/api/qquickwebenginecertificateerror.cpp b/src/webengine/api/qquickwebenginecertificateerror.cpp
new file mode 100644
index 000000000..37b92727a
--- /dev/null
+++ b/src/webengine/api/qquickwebenginecertificateerror.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qquickwebenginecertificateerror_p.h>
+#include "certificate_error_controller.h"
+QT_BEGIN_NAMESPACE
+
+class QQuickWebEngineCertificateErrorPrivate {
+public:
+ QQuickWebEngineCertificateErrorPrivate(const QSharedPointer<CertificateErrorController> &controller)
+ : weakRefCertErrorController(controller),
+ error(static_cast<QQuickWebEngineCertificateError::Error>(static_cast<int>(controller->error()))),
+ description(controller->errorString()),
+ overridable(controller->overridable()),
+ async(false)
+ {
+ }
+
+ const QWeakPointer<CertificateErrorController> weakRefCertErrorController;
+ QQuickWebEngineCertificateError::Error error;
+ QString description;
+ bool overridable;
+ bool async;
+};
+
+
+
+/*!
+ \qmltype WebEngineCertificateError
+ \instantiates QQuickWebEngineCertificateError
+ \inqmlmodule QtWebEngine 1.1
+ \since QtWebEngine 1.1
+
+ \brief A utility class for accepting or denying certificate exceptions when a certificate error occurs.
+
+ This class contains information about a certificate error that happened and provides a way to accept or
+ deny a certificate exception.
+
+ \sa WebEngineView::certificateError
+*/
+QQuickWebEngineCertificateError::QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent)
+ : QObject(parent)
+ , d_ptr(new QQuickWebEngineCertificateErrorPrivate(controller))
+{
+}
+
+QQuickWebEngineCertificateError::~QQuickWebEngineCertificateError()
+{
+ rejectCertificate();
+}
+
+
+/*!
+ \qmlmethod void WebEngineCertificateError::defer()
+
+ This function should be called when there is a need to postpone the decision to ignore or not the certificate error. This is useful to
+ wait for user input. When called it will pause the url request until WebEngineCertificateError::ignoreCertificateError() or
+ WebEngineCertificateError::rejectCertificate() is called.
+ */
+void QQuickWebEngineCertificateError::defer()
+{
+ Q_D(QQuickWebEngineCertificateError);
+ d->async = true;
+}
+/*!
+ \qmlmethod void WebEngineCertificateError::ignoreCertificateError()
+
+ The certificate error is ignored and the WebEngineView continues to load the requested url.
+ */
+void QQuickWebEngineCertificateError::ignoreCertificateError()
+{
+ Q_D(const QQuickWebEngineCertificateError);
+
+ QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef();
+ if (strongRefCert)
+ strongRefCert->accept(true);
+}
+
+/*!
+ \qmlmethod void WebEngineCertificateError::rejectCertificate()
+
+ The WebEngineView stops loading the requested url.
+ */
+void QQuickWebEngineCertificateError::rejectCertificate()
+{
+ Q_D(const QQuickWebEngineCertificateError);
+
+ QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef();
+ if (strongRefCert)
+ strongRefCert->accept(false);
+}
+
+/*!
+ \qmlproperty url WebEngineCertificateError::url
+ \brief The URL of the certificate error.
+ */
+QUrl QQuickWebEngineCertificateError::url() const
+{
+ Q_D(const QQuickWebEngineCertificateError);
+ QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef();
+ if (strongRefCert)
+ return strongRefCert->url();
+ return QUrl();
+}
+
+/*!
+ \qmlproperty enumeration WebEngineCertificateError::error
+*/
+QQuickWebEngineCertificateError::Error QQuickWebEngineCertificateError::error() const
+{
+ Q_D(const QQuickWebEngineCertificateError);
+ return d->error;
+}
+
+/*!
+ \qmlproperty string WebEngineCertificateError::description
+*/
+QString QQuickWebEngineCertificateError::description() const
+{
+ Q_D(const QQuickWebEngineCertificateError);
+ return d->description;
+}
+
+/*!
+ \qmlproperty bool WebEngineCertificateError::overridable
+*/
+bool QQuickWebEngineCertificateError::overridable() const
+{
+ Q_D(const QQuickWebEngineCertificateError);
+ return d->overridable;
+}
+
+bool QQuickWebEngineCertificateError::deferred() const
+{
+ Q_D(const QQuickWebEngineCertificateError);
+ return d->async;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h
new file mode 100644
index 000000000..735cc8705
--- /dev/null
+++ b/src/webengine/api/qquickwebenginecertificateerror_p.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINECERTIFICATEERROR_P_H
+#define QQUICKWEBENGINECERTIFICATEERROR_P_H
+
+#include <QObject>
+#include "qquickwebengineview_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickWebEngineCertificateErrorPrivate;
+class CertificateErrorController;
+
+class Q_WEBENGINE_EXPORT QQuickWebEngineCertificateError : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QUrl url READ url)
+ Q_PROPERTY(Error error READ error)
+ Q_PROPERTY(QString description READ description)
+ Q_PROPERTY(bool overridable READ overridable)
+ Q_ENUMS(Error)
+
+public:
+
+ // Keep this identical to CertificateErrorController::CertificateError, or add mapping layer.
+ enum Error {
+ SslPinnedKeyNotInCertificateChain = -150,
+ CertificateCommonNameInvalid = -200,
+ CertificateDateInvalid = -201,
+ CertificateAuthorityInvalid = -202,
+ CertificateContainsErrors = -203,
+ CertificateNoRevocationMechanism = -204,
+ CertificateUnableToCheckRevocation = -205,
+ CertificateRevoked = -206,
+ CertificateInvalid = -207,
+ CertificateWeakSignatureAlgorithm = -208,
+ CertificateNonUniqueName = -210,
+ CertificateWeakKey = -211,
+ CertificateNameConstraintViolation = -212,
+ };
+
+ QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent = 0);
+ ~QQuickWebEngineCertificateError();
+
+ Q_INVOKABLE void defer();
+ Q_INVOKABLE void ignoreCertificateError();
+ Q_INVOKABLE void rejectCertificate();
+ QUrl url() const;
+ Error error() const;
+ QString description() const;
+ bool overridable() const;
+ bool deferred() const;
+
+private:
+ Q_DISABLE_COPY(QQuickWebEngineCertificateError)
+ Q_DECLARE_PRIVATE(QQuickWebEngineCertificateError)
+ QScopedPointer<QQuickWebEngineCertificateErrorPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickWebEngineCertificateError)
+
+#endif // QQUICKWEBENGINECERTIFICATEERROR_P_H
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
new file mode 100644
index 000000000..6ee00d9a0
--- /dev/null
+++ b/src/webengine/api/qquickwebenginedownloaditem.cpp
@@ -0,0 +1,272 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickwebenginedownloaditem_p.h"
+#include "qquickwebenginedownloaditem_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+static inline QQuickWebEngineDownloadItem::DownloadState toDownloadState(int state) {
+ switch (state) {
+ case BrowserContextAdapterClient::DownloadInProgress:
+ return QQuickWebEngineDownloadItem::DownloadInProgress;
+ case BrowserContextAdapterClient::DownloadCompleted:
+ return QQuickWebEngineDownloadItem::DownloadCompleted;
+ case BrowserContextAdapterClient::DownloadCancelled:
+ return QQuickWebEngineDownloadItem::DownloadCancelled;
+ case BrowserContextAdapterClient::DownloadInterrupted:
+ return QQuickWebEngineDownloadItem::DownloadInterrupted;
+ default:
+ Q_UNREACHABLE();
+ return QQuickWebEngineDownloadItem::DownloadCancelled;
+ }
+}
+
+QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfilePrivate *p)
+ : profile(p)
+ , downloadId(-1)
+ , downloadState(QQuickWebEngineDownloadItem::DownloadCancelled)
+{
+}
+
+QQuickWebEngineDownloadItemPrivate::~QQuickWebEngineDownloadItemPrivate()
+{
+ profile->downloadDestroyed(downloadId);
+}
+
+/*!
+ \qmltype WebEngineDownloadItem
+ \instantiates QQuickWebEngineDownloadItem
+ \inqmlmodule QtWebEngine 1.1
+ \since QtWebEngine 1.1
+ \brief A WebEngineDownloadItem provides information about a download.
+
+ WebEngineDownloadItem stores the state of a download to be used to manage requested downloads.
+
+ By default the download is rejected unless the user explicitly accepts it with
+ WebEngineDownloadItem::accept().
+*/
+
+void QQuickWebEngineDownloadItemPrivate::update(const BrowserContextAdapterClient::DownloadItemInfo &info)
+{
+ Q_Q(QQuickWebEngineDownloadItem);
+
+ updateState(toDownloadState(info.state));
+
+ if (info.receivedBytes != receivedBytes) {
+ receivedBytes = info.receivedBytes;
+ Q_EMIT q->receivedBytesChanged();
+ }
+
+ if (info.totalBytes != totalBytes) {
+ totalBytes = info.totalBytes;
+ Q_EMIT q->totalBytesChanged();
+ }
+}
+
+void QQuickWebEngineDownloadItemPrivate::updateState(QQuickWebEngineDownloadItem::DownloadState newState)
+{
+ Q_Q(QQuickWebEngineDownloadItem);
+
+ if (downloadState != newState) {
+ downloadState = newState;
+ Q_EMIT q->stateChanged();
+ }
+}
+
+/*!
+ \qmlmethod void WebEngineDownloadItem::accept()
+
+ Accepts the download request, which will start the download.
+
+ \sa WebEngineDownloadItem::cancel()
+*/
+
+void QQuickWebEngineDownloadItem::accept()
+{
+ Q_D(QQuickWebEngineDownloadItem);
+
+ if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested)
+ return;
+
+ d->updateState(QQuickWebEngineDownloadItem::DownloadInProgress);
+}
+
+/*!
+ \qmlmethod void WebEngineDownloadItem::cancel()
+
+ Cancels the download.
+*/
+
+void QQuickWebEngineDownloadItem::cancel()
+{
+ Q_D(QQuickWebEngineDownloadItem);
+
+ QQuickWebEngineDownloadItem::DownloadState state = d->downloadState;
+
+ if (state == QQuickWebEngineDownloadItem::DownloadCompleted
+ || state == QQuickWebEngineDownloadItem::DownloadCancelled)
+ return;
+
+ d->updateState(QQuickWebEngineDownloadItem::DownloadCancelled);
+
+ // We directly cancel the download if the user cancels before
+ // it even started, so no need to notify the profile here.
+ if (state == QQuickWebEngineDownloadItem::DownloadInProgress)
+ d->profile->cancelDownload(d->downloadId);
+}
+
+/*!
+ \qmlproperty quint32 WebEngineDownloadItem::id
+
+ The download item's id.
+*/
+
+quint32 QQuickWebEngineDownloadItem::id() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadId;
+}
+
+/*!
+ \qmlproperty enumeration WebEngineDownloadItem::state
+
+ This property describes the state in which the download is in.
+
+ The state can be one of:
+
+ \table
+
+ \header
+ \li Constant
+ \li Description
+
+ \row
+ \li DownloadRequested
+ \li The download has been requested, but has not been accepted yet.
+
+ \row
+ \li DownloadInProgress
+ \li The download is in progress.
+
+ \row
+ \li DownloadCompleted
+ \li The download completed successfully.
+
+ \row
+ \li DownloadInterrupted
+ \li The download has been interrupted (by the server or because of lost connectivity).
+
+ \endtable
+*/
+
+QQuickWebEngineDownloadItem::DownloadState QQuickWebEngineDownloadItem::state() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadState;
+}
+
+/*!
+ \qmlproperty int WebEngineDownloadItem::totalBytes
+
+ The download's total size in bytes.
+
+ -1 means the total size is unknown.
+*/
+
+qint64 QQuickWebEngineDownloadItem::totalBytes() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->totalBytes;
+}
+
+/*!
+ \qmlproperty int WebEngineDownloadItem::receivedBytes
+
+ The download's bytes that have been received so far.
+*/
+
+qint64 QQuickWebEngineDownloadItem::receivedBytes() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->receivedBytes;
+}
+
+/*!
+ \qmlproperty QString WebEngineDownloadItem::path
+
+ The download item's full target path where it is being downloaded to.
+
+ The path includes the file name. The default suggested path is the standard
+ download location and file name is deduced not to overwrite already existing files.
+
+ The download path can only be set in the \c WebEngineProfile.onDownloadRequested
+ handler before the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(WebEngineDownloadItem download), WebEngineDownloadItem::accept()
+*/
+
+QString QQuickWebEngineDownloadItem::path() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadPath;
+}
+
+void QQuickWebEngineDownloadItem::setPath(QString path)
+{
+ Q_D(QQuickWebEngineDownloadItem);
+ if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
+ qWarning("Setting the download path is not allowed after the download has been accepted.");
+ return;
+ }
+ if (d->downloadPath != path) {
+ d->downloadPath = path;
+ Q_EMIT pathChanged();
+ }
+}
+
+QQuickWebEngineDownloadItem::QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate *p, QObject *parent)
+ : QObject(parent)
+ , d_ptr(p)
+{
+ p->q_ptr = this;
+}
+
+QQuickWebEngineDownloadItem::~QQuickWebEngineDownloadItem()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h
new file mode 100644
index 000000000..ea12c9c94
--- /dev/null
+++ b/src/webengine/api/qquickwebenginedownloaditem_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINEDOWNLOADITEM_P_H
+#define QQUICKWEBENGINEDOWNLOADITEM_P_H
+
+#include <private/qtwebengineglobal_p.h>
+#include <QObject>
+#include <QScopedPointer>
+#include <QString>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickWebEngineDownloadItemPrivate;
+class QQuickWebEngineProfilePrivate;
+
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineDownloadItem: public QObject {
+ Q_OBJECT
+public:
+ ~QQuickWebEngineDownloadItem();
+ enum DownloadState {
+ DownloadRequested,
+ DownloadInProgress,
+ DownloadCompleted,
+ DownloadCancelled,
+ DownloadInterrupted
+ };
+ Q_ENUMS(DownloadState)
+
+ Q_PROPERTY(quint32 id READ id() CONSTANT FINAL)
+ Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged)
+ Q_PROPERTY(qint64 totalBytes READ totalBytes NOTIFY totalBytesChanged)
+ Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY receivedBytesChanged)
+ Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
+
+ Q_INVOKABLE void accept();
+ Q_INVOKABLE void cancel();
+
+ quint32 id() const;
+ DownloadState state() const;
+ qint64 totalBytes() const;
+ qint64 receivedBytes() const;
+ QString path() const;
+ void setPath(QString path);
+
+Q_SIGNALS:
+ void stateChanged();
+ void receivedBytesChanged();
+ void totalBytesChanged();
+ void pathChanged();
+
+private:
+ QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate*, QObject *parent = 0);
+ Q_DISABLE_COPY(QQuickWebEngineDownloadItem)
+ Q_DECLARE_PRIVATE(QQuickWebEngineDownloadItem)
+ friend class QQuickWebEngineProfilePrivate;
+
+ QScopedPointer<QQuickWebEngineDownloadItemPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKWEBENGINEDOWNLOADITEM_P_H
diff --git a/src/webengine/api/qquickwebenginesettings_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
index 8f3e95eea..0250a8faa 100644
--- a/src/webengine/api/qquickwebenginesettings_p_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
@@ -34,24 +34,35 @@
**
****************************************************************************/
-#ifndef QQUICKWEBENGINESETTINGS_P_P_H
-#define QQUICKWEBENGINESETTINGS_P_P_H
+#ifndef QQUICKWEBENGINEDOWNLOADITEM_P_P_H
+#define QQUICKWEBENGINEDOWNLOADITEM_P_P_H
-#include "web_engine_settings.h"
+#include "qquickwebenginedownloaditem_p.h"
+#include "qquickwebengineprofile_p_p.h"
+#include <private/qtwebengineglobal_p.h>
+#include <QString>
QT_BEGIN_NAMESPACE
-class QQuickWebEngineSettingsPrivate : public WebEngineSettingsDelegate {
+class QQuickWebEngineDownloadItemPrivate {
+ QQuickWebEngineDownloadItem *q_ptr;
+ QQuickWebEngineProfilePrivate* profile;
+ friend class QQuickWebEngineProfilePrivate;
public:
- QQuickWebEngineSettingsPrivate();
- QQuickWebEngineSettingsPrivate(WebContentsAdapter *adapter);
+ Q_DECLARE_PUBLIC(QQuickWebEngineDownloadItem)
+ QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfilePrivate *p);
+ ~QQuickWebEngineDownloadItemPrivate();
- void apply() Q_DECL_OVERRIDE;
- WebEngineSettings *fallbackSettings() const Q_DECL_OVERRIDE;
+ quint32 downloadId;
+ QQuickWebEngineDownloadItem::DownloadState downloadState;
+ qint64 totalBytes;
+ qint64 receivedBytes;
+ QString downloadPath;
- QScopedPointer<WebEngineSettings> coreSettings;
+ void update(const BrowserContextAdapterClient::DownloadItemInfo &info);
+ void updateState(QQuickWebEngineDownloadItem::DownloadState newState);
};
QT_END_NAMESPACE
-#endif // QQUICKWEBENGINESETTINGS_P_P_H
+#endif // QQUICKWEBENGINEDOWNLOADITEM_P_P_H
diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webengine/api/qquickwebenginehistory.cpp
index ffb857791..7924dbc5e 100644
--- a/src/webengine/api/qquickwebenginehistory.cpp
+++ b/src/webengine/api/qquickwebenginehistory.cpp
@@ -63,6 +63,8 @@ QQuickWebEngineBackHistoryListModelPrivate::QQuickWebEngineBackHistoryListModelP
int QQuickWebEngineBackHistoryListModelPrivate::count() const
{
+ if (!adapter())
+ return -1;
return adapter()->currentNavigationEntryIndex();
}
@@ -79,6 +81,8 @@ QQuickWebEngineForwardHistoryListModelPrivate::QQuickWebEngineForwardHistoryList
int QQuickWebEngineForwardHistoryListModelPrivate::count() const
{
+ if (!adapter())
+ return -1;
return adapter()->navigationEntryCount() - adapter()->currentNavigationEntryIndex() - 1;
}
diff --git a/src/webengine/api/qquickwebenginenewviewrequest.cpp b/src/webengine/api/qquickwebenginenewviewrequest.cpp
index f2a361f55..053fcd2f6 100644
--- a/src/webengine/api/qquickwebenginenewviewrequest.cpp
+++ b/src/webengine/api/qquickwebenginenewviewrequest.cpp
@@ -39,6 +39,18 @@
#include "qquickwebengineview_p_p.h"
#include "web_contents_adapter.h"
+/*!
+ \qmltype WebEngineNewViewRequest
+ \instantiates QQuickWebEngineNewViewRequest
+ \inqmlmodule QtWebEngine 1.1
+ \since QtWebEngine 1.1
+
+ \brief A utility class for the WebEngineView::newViewRequested signal.
+
+ This class contains information about the request of a page to open a new window.
+
+ \sa WebEngineView::newViewRequested
+*/
QQuickWebEngineNewViewRequest::QQuickWebEngineNewViewRequest()
{
}
@@ -47,20 +59,48 @@ QQuickWebEngineNewViewRequest::~QQuickWebEngineNewViewRequest()
{
}
+/*!
+ \qmlproperty WebEngineView::NewViewDestination WebEngineNewViewRequest::destination
+ \brief The type of view that is requested by the page.
+ */
QQuickWebEngineView::NewViewDestination QQuickWebEngineNewViewRequest::destination() const
{
return m_destination;
}
+/*!
+ \qmlproperty bool WebEngineNewViewRequest::isUserInitiated
+ \brief Whether this window request was directly triggered as the result of a keyboard or mouse event.
+
+ Use this property to block possibly unwanted "popups".
+ */
bool QQuickWebEngineNewViewRequest::isUserInitiated() const
{
return m_isUserInitiated;
}
+/*!
+ \qmlmethod WebEngineNewViewRequest::openIn(WebEngineView view)
+
+ Call this method to fulfill the request and determine which WebEngineView
+ should be used to contain the new page. Any state, history or loaded page
+ within \a view will be lost as result of this.
+
+ \sa WebEngineView::newViewRequested
+ */
void QQuickWebEngineNewViewRequest::openIn(QQuickWebEngineView *view)
{
- if (view) {
- view->d_func()->adoptWebContents(m_adapter.data());
- m_adapter.reset();
+ if (!m_adapter) {
+ 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;
}
+ view->d_func()->adoptWebContents(m_adapter.data());
+ m_adapter.reset();
}
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
new file mode 100644
index 000000000..5905fb3d9
--- /dev/null
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -0,0 +1,410 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickwebengineprofile_p.h"
+
+#include "qquickwebenginedownloaditem_p.h"
+#include "qquickwebenginedownloaditem_p_p.h"
+#include "qquickwebengineprofile_p_p.h"
+#include "qquickwebenginesettings_p.h"
+
+#include <QQmlEngine>
+
+#include "browser_context_adapter.h"
+#include "web_engine_settings.h"
+
+QT_BEGIN_NAMESPACE
+
+QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapter* browserContext, bool ownsContext)
+ : m_settings(new QQuickWebEngineSettings())
+ , m_browserContext(browserContext)
+{
+ if (ownsContext)
+ m_browserContextRef = browserContext;
+
+ m_browserContext->setClient(this);
+ m_settings->d_ptr->initDefaults(browserContext->isOffTheRecord());
+}
+
+QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate()
+{
+ m_browserContext->setClient(0);
+
+ Q_FOREACH (QQuickWebEngineDownloadItem* download, m_ongoingDownloads) {
+ if (download)
+ download->cancel();
+ }
+
+ m_ongoingDownloads.clear();
+}
+
+void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId)
+{
+ m_browserContext->cancelDownload(downloadId);
+}
+
+void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId)
+{
+ m_ongoingDownloads.remove(downloadId);
+}
+
+void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
+{
+ Q_Q(QQuickWebEngineProfile);
+
+ Q_ASSERT(!m_ongoingDownloads.contains(info.id));
+ QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(this);
+ itemPrivate->downloadId = info.id;
+ itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested;
+ itemPrivate->downloadPath = info.path;
+
+ QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q);
+
+ m_ongoingDownloads.insert(info.id, download);
+
+ QQmlEngine::setObjectOwnership(download, QQmlEngine::JavaScriptOwnership);
+ Q_EMIT q->downloadRequested(download);
+
+ QQuickWebEngineDownloadItem::DownloadState state = download->state();
+ info.path = download->path();
+ info.accepted = state != QQuickWebEngineDownloadItem::DownloadCancelled
+ && state != QQuickWebEngineDownloadItem::DownloadRequested;
+}
+
+void QQuickWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info)
+{
+ if (!m_ongoingDownloads.contains(info.id))
+ return;
+
+ Q_Q(QQuickWebEngineProfile);
+
+ QQuickWebEngineDownloadItem* download = m_ongoingDownloads.value(info.id).data();
+
+ if (!download) {
+ downloadDestroyed(info.id);
+ return;
+ }
+
+ download->d_func()->update(info);
+
+ if (info.state != BrowserContextAdapterClient::DownloadInProgress) {
+ Q_EMIT q->downloadFinished(download);
+ m_ongoingDownloads.remove(info.id);
+ }
+}
+
+/*!
+ \qmltype WebEngineProfile
+ \instantiates QQuickWebEngineProfile
+ \inqmlmodule QtWebEngine 1.1
+ \since QtWebEngine 1.1
+ \brief A WebEngineProfile contains common settings for multiple WebEngineView.
+
+ WebEngineProfile contains settings and history shared by all WebEngineView that belong
+ to the profile.
+
+ A default profile is built-in that all web pages not specifically created with another profile
+ belongs to.
+*/
+
+/*!
+ \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 \a download has to be explicitly accepted with WebEngineDownloadItem::accept(),
+ else the download will be cancelled by default.
+*/
+
+/*!
+ \qmlsignal WebEngineProfile::downloadFinished(WebEngineDownloadItem download)
+
+ This signal is emitted whenever a download finishes downloading.
+ This can be due to the download finishing successfully, being cancelled or
+ interrupted by lost connectivity for example.
+ The \a download argument holds the state of the finished download instance.
+*/
+
+QQuickWebEngineProfile::QQuickWebEngineProfile()
+ : d_ptr(new QQuickWebEngineProfilePrivate(new BrowserContextAdapter(false), true))
+{
+ d_ptr->q_ptr = this;
+}
+
+QQuickWebEngineProfile::QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *privatePtr)
+ : d_ptr(privatePtr)
+{
+ d_ptr->q_ptr = this;
+}
+
+QQuickWebEngineProfile::~QQuickWebEngineProfile()
+{
+}
+
+/*!
+ \qmlproperty QString WebEngineProfile::storageName
+
+ The storage name is used to give each profile that uses the disk separate subdirectories for persistent data and cache.
+*/
+
+QString QQuickWebEngineProfile::storageName() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return d->browserContext()->storageName();
+}
+
+void QQuickWebEngineProfile::setStorageName(const QString &name)
+{
+ Q_D(QQuickWebEngineProfile);
+ if (d->browserContext()->storageName() == name)
+ return;
+ BrowserContextAdapter::HttpCacheType oldCacheType = d->browserContext()->httpCacheType();
+ BrowserContextAdapter::PersistentCookiesPolicy oldPolicy = d->browserContext()->persistentCookiesPolicy();
+ d->browserContext()->setStorageName(name);
+ emit storageNameChanged();
+ emit persistentStoragePathChanged();
+ emit cachePathChanged();
+ if (d->browserContext()->httpCacheType() != oldCacheType)
+ emit httpCacheTypeChanged();
+ if (d->browserContext()->persistentCookiesPolicy() != oldPolicy)
+ emit persistentCookiesPolicyChanged();
+}
+
+/*!
+ \qmlproperty bool WebEngineProfile::offTheRecord
+
+ An offTheRecord profile forces cookies and HTTP cache to be in memory, but also force
+ all other normally persistent data to be stored in memory.
+*/
+bool QQuickWebEngineProfile::isOffTheRecord() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return d->browserContext()->isOffTheRecord();
+}
+
+void QQuickWebEngineProfile::setOffTheRecord(bool offTheRecord)
+{
+ Q_D(QQuickWebEngineProfile);
+ if (d->browserContext()->isOffTheRecord() == offTheRecord)
+ return;
+ BrowserContextAdapter::HttpCacheType oldCacheType = d->browserContext()->httpCacheType();
+ BrowserContextAdapter::PersistentCookiesPolicy oldPolicy = d->browserContext()->persistentCookiesPolicy();
+ d->browserContext()->setOffTheRecord(offTheRecord);
+ emit offTheRecordChanged();
+ if (d->browserContext()->httpCacheType() != oldCacheType)
+ emit httpCacheTypeChanged();
+ if (d->browserContext()->persistentCookiesPolicy() != oldPolicy)
+ emit persistentCookiesPolicyChanged();
+}
+
+/*!
+ \qmlproperty QString WebEngineProfile::persistentStoragePath
+
+ The persistent storage path is where persistent data for the browser and web content is stored.
+ Persistent data includes persistent cookies, HTML5 local storage and visited links.
+
+ By default this is below QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a storageName specific directory.
+*/
+QString QQuickWebEngineProfile::persistentStoragePath() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return d->browserContext()->dataPath();
+}
+
+void QQuickWebEngineProfile::setPersistentStoragePath(const QString &path)
+{
+ Q_D(QQuickWebEngineProfile);
+ if (persistentStoragePath() == path)
+ return;
+ d->browserContext()->setDataPath(path);
+ emit persistentStoragePathChanged();
+}
+
+/*!
+ \qmlproperty QString WebEngineProfile::cachePath
+
+ By default this is below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a storageName specific directory.
+*/
+QString QQuickWebEngineProfile::cachePath() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return d->browserContext()->cachePath();
+}
+
+void QQuickWebEngineProfile::setCachePath(const QString &path)
+{
+ Q_D(QQuickWebEngineProfile);
+ if (cachePath() == path)
+ return;
+ d->browserContext()->setCachePath(path);
+ emit cachePathChanged();
+}
+
+/*!
+ \qmlproperty QString WebEngineProfile::httpUserAgent
+
+ The user-agent string send with HTTP to identify the browser.
+*/
+QString QQuickWebEngineProfile::httpUserAgent() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return d->browserContext()->httpUserAgent();
+}
+
+void QQuickWebEngineProfile::setHttpUserAgent(const QString &userAgent)
+{
+ Q_D(QQuickWebEngineProfile);
+ if (d->browserContext()->httpUserAgent() == userAgent)
+ return;
+ d->browserContext()->setHttpUserAgent(userAgent);
+ emit httpUserAgentChanged();
+}
+
+
+/*!
+ \qmlproperty enumeration WebEngineProfile::httpCacheType
+
+ The type of the HTTP cache.
+
+ \table
+
+ \header
+ \li Constant
+ \li Description
+
+ \row
+ \li MemoryHttpCache
+ \li Use a in-memory cache. This is the only setting possible if offTheRecord is set or no cachePath is available.
+
+ \row
+ \li DiskHttpCache
+ \li DiskHttpCache Use a disk cache. This is the default.
+
+ \endtable
+*/
+
+QQuickWebEngineProfile::HttpCacheType QQuickWebEngineProfile::httpCacheType() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return QQuickWebEngineProfile::HttpCacheType(d->browserContext()->httpCacheType());
+}
+
+void QQuickWebEngineProfile::setHttpCacheType(QQuickWebEngineProfile::HttpCacheType httpCacheType)
+{
+ Q_D(QQuickWebEngineProfile);
+ BrowserContextAdapter::HttpCacheType oldCacheType = d->browserContext()->httpCacheType();
+ d->browserContext()->setHttpCacheType(BrowserContextAdapter::HttpCacheType(httpCacheType));
+ if (d->browserContext()->httpCacheType() != oldCacheType)
+ emit httpCacheTypeChanged();
+}
+
+/*!
+ \qmlproperty enumeration WebEngineProfile::persistentCookiesPolicy
+
+ The policy of cookie persistency.
+
+ \table
+
+ \header
+ \li Constant
+ \li Description
+
+ \row
+ \li NoPersistentCookies
+ \li Both session and persistent cookies are stored in memory. This is the only setting possible if offTheRecord is set or no persistentStoragePath is available.
+
+ \row
+ \li AllowPersistentCookies
+ \li Cookies marked persistent are save and restored from disk, session cookies are only stored to disk for crash recovery. This is the default setting.
+
+ \row
+ \li ForcePersistentCookies
+ \li Both session and persistent cookies are save and restored from disk.
+
+ \endtable
+*/
+
+QQuickWebEngineProfile::PersistentCookiesPolicy QQuickWebEngineProfile::persistentCookiesPolicy() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return QQuickWebEngineProfile::PersistentCookiesPolicy(d->browserContext()->persistentCookiesPolicy());
+}
+
+void QQuickWebEngineProfile::setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy newPersistentCookiesPolicy)
+{
+ Q_D(QQuickWebEngineProfile);
+ BrowserContextAdapter::PersistentCookiesPolicy oldPolicy = d->browserContext()->persistentCookiesPolicy();
+ d->browserContext()->setPersistentCookiesPolicy(BrowserContextAdapter::PersistentCookiesPolicy(newPersistentCookiesPolicy));
+ if (d->browserContext()->persistentCookiesPolicy() != oldPolicy)
+ emit persistentCookiesPolicyChanged();
+}
+
+/*!
+ \qmlproperty int WebEngineProfile::httpCacheMaximumSize
+
+ The maximum size of the HTTP cache. If 0 it means the size will be controlled automatically by QtWebEngine.
+ The default value is 0.
+
+ \sa httpCacheType
+*/
+int QQuickWebEngineProfile::httpCacheMaximumSize() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return d->browserContext()->httpCacheMaxSize();
+}
+
+void QQuickWebEngineProfile::setHttpCacheMaximumSize(int maximumSize)
+{
+ Q_D(QQuickWebEngineProfile);
+ if (d->browserContext()->httpCacheMaxSize() == maximumSize)
+ return;
+ d->browserContext()->setHttpCacheMaxSize(maximumSize);
+ emit httpCacheMaximumSizeChanged();
+}
+
+QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile()
+{
+ static QQuickWebEngineProfile profile(new QQuickWebEngineProfilePrivate(BrowserContextAdapter::defaultContext(), false));
+ return &profile;
+}
+
+QQuickWebEngineSettings *QQuickWebEngineProfile::settings() const
+{
+ const Q_D(QQuickWebEngineProfile);
+ return d->settings();
+}
+
+QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
new file mode 100644
index 000000000..f3e0f5c33
--- /dev/null
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINEPROFILE_P_H
+#define QQUICKWEBENGINEPROFILE_P_H
+
+#include <private/qtwebengineglobal_p.h>
+
+#include <QObject>
+#include <QScopedPointer>
+#include <QString>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickWebEngineDownloadItem;
+class QQuickWebEngineProfilePrivate;
+class QQuickWebEngineSettings;
+
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineProfile : public QObject {
+ Q_OBJECT
+ Q_ENUMS(HttpCacheType);
+ Q_ENUMS(PersistentCookiesPolicy);
+ 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(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL)
+ Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL)
+public:
+ QQuickWebEngineProfile();
+ ~QQuickWebEngineProfile();
+
+ enum HttpCacheType {
+ MemoryHttpCache,
+ DiskHttpCache
+ };
+
+ enum PersistentCookiesPolicy {
+ NoPersistentCookies,
+ AllowPersistentCookies,
+ ForcePersistentCookies
+ };
+
+ 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);
+
+ static QQuickWebEngineProfile *defaultProfile();
+
+signals:
+ void storageNameChanged();
+ void offTheRecordChanged();
+ void persistentStoragePathChanged();
+ void cachePathChanged();
+ void httpUserAgentChanged();
+ void httpCacheTypeChanged();
+ void persistentCookiesPolicyChanged();
+ void httpCacheMaximumSizeChanged();
+
+ void downloadRequested(QQuickWebEngineDownloadItem *download);
+ void downloadFinished(QQuickWebEngineDownloadItem *download);
+
+private:
+ Q_DECLARE_PRIVATE(QQuickWebEngineProfile)
+ QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *);
+ QQuickWebEngineSettings *settings() const;
+
+ friend class QQuickWebEngineSettings;
+ friend class QQuickWebEngineSingleton;
+ friend class QQuickWebEngineViewPrivate;
+ QScopedPointer<QQuickWebEngineProfilePrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKWEBENGINEPROFILE_P_H
diff --git a/src/webengine/api/qquickwebengineprofile_p_p.h b/src/webengine/api/qquickwebengineprofile_p_p.h
new file mode 100644
index 000000000..6b6026abb
--- /dev/null
+++ b/src/webengine/api/qquickwebengineprofile_p_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINEPROFILE_P_P_H
+#define QQUICKWEBENGINEPROFILE_P_P_H
+
+class BrowserContextAdapter;
+
+#include "browser_context_adapter_client.h"
+#include "qquickwebengineprofile_p.h"
+
+#include <QExplicitlySharedDataPointer>
+#include <QMap>
+#include <QPointer>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickWebEngineDownloadItem;
+class QQuickWebEngineSettings;
+
+class QQuickWebEngineProfilePrivate : public BrowserContextAdapterClient {
+public:
+ Q_DECLARE_PUBLIC(QQuickWebEngineProfile)
+ QQuickWebEngineProfilePrivate(BrowserContextAdapter* browserContext, bool ownsContext);
+ ~QQuickWebEngineProfilePrivate();
+
+ BrowserContextAdapter *browserContext() const { return m_browserContext; }
+ QQuickWebEngineSettings *settings() const { return m_settings.data(); }
+
+ void cancelDownload(quint32 downloadId);
+ void downloadDestroyed(quint32 downloadId);
+
+ void downloadRequested(DownloadItemInfo &info) Q_DECL_OVERRIDE;
+ void downloadUpdated(const DownloadItemInfo &info) Q_DECL_OVERRIDE;
+
+private:
+ friend class QQuickWebEngineViewPrivate;
+ QQuickWebEngineProfile *q_ptr;
+ QScopedPointer<QQuickWebEngineSettings> m_settings;
+ BrowserContextAdapter *m_browserContext;
+ QExplicitlySharedDataPointer<BrowserContextAdapter> m_browserContextRef;
+ QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKWEBENGINEPROFILE_P_P_H
diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp
index 743d22d81..f4c9a656d 100644
--- a/src/webengine/api/qquickwebenginesettings.cpp
+++ b/src/webengine/api/qquickwebenginesettings.cpp
@@ -35,238 +35,184 @@
****************************************************************************/
#include "qquickwebenginesettings_p.h"
-#include "qquickwebenginesettings_p_p.h"
+
+#include "qquickwebengineprofile_p.h"
+#include "web_engine_settings.h"
#include <QtCore/QList>
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QList<QQuickWebEngineSettingsPrivate*>, allSettings)
-
-QQuickWebEngineSettingsPrivate::QQuickWebEngineSettingsPrivate()
- : coreSettings(new WebEngineSettings(this))
-{
- allSettings->append(this);
-}
-
-void QQuickWebEngineSettingsPrivate::apply()
-{
- coreSettings->scheduleApply();
- QQuickWebEngineSettingsPrivate *globals = QQuickWebEngineSettings::globalSettings()->d_func();
- Q_ASSERT((this == globals) != (allSettings->contains(this)));
- if (this == globals)
- Q_FOREACH (QQuickWebEngineSettingsPrivate *settings, *allSettings)
- settings->coreSettings->scheduleApply();
-}
-
-WebEngineSettings *QQuickWebEngineSettingsPrivate::fallbackSettings() const
-{
- return QQuickWebEngineSettings::globalSettings()->d_func()->coreSettings.data();
-}
-
-
-QQuickWebEngineSettings *QQuickWebEngineSettings::globalSettings()
-{
- static QQuickWebEngineSettings *globals = 0;
- if (!globals) {
- globals = new QQuickWebEngineSettings;
- allSettings->removeAll(globals->d_func());
- globals->d_func()->coreSettings->initDefaults();
- }
- return globals;
-}
+QQuickWebEngineSettings::QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings)
+ : d_ptr(new WebEngineSettings(parentSettings ? parentSettings->d_ptr.data() : 0))
+{ }
QQuickWebEngineSettings::~QQuickWebEngineSettings()
-{
- allSettings->removeAll(this->d_func());
-}
+{ }
bool QQuickWebEngineSettings::autoLoadImages() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::AutoLoadImages);
+ return d_ptr->testAttribute(WebEngineSettings::AutoLoadImages);
}
bool QQuickWebEngineSettings::javascriptEnabled() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::JavascriptEnabled);
+ return d_ptr->testAttribute(WebEngineSettings::JavascriptEnabled);
}
bool QQuickWebEngineSettings::javascriptCanOpenWindows() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::JavascriptCanOpenWindows);
+ return d_ptr->testAttribute(WebEngineSettings::JavascriptCanOpenWindows);
}
bool QQuickWebEngineSettings::javascriptCanAccessClipboard() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard);
+ return d_ptr->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard);
}
bool QQuickWebEngineSettings::linksIncludedInFocusChain() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::LinksIncludedInFocusChain);
+ return d_ptr->testAttribute(WebEngineSettings::LinksIncludedInFocusChain);
}
bool QQuickWebEngineSettings::localStorageEnabled() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::LocalStorageEnabled);
+ return d_ptr->testAttribute(WebEngineSettings::LocalStorageEnabled);
}
bool QQuickWebEngineSettings::localContentCanAccessRemoteUrls() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls);
+ return d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls);
}
bool QQuickWebEngineSettings::spatialNavigationEnabled() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::SpatialNavigationEnabled);
+ return d_ptr->testAttribute(WebEngineSettings::SpatialNavigationEnabled);
}
bool QQuickWebEngineSettings::localContentCanAccessFileUrls() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls);
+ return d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls);
}
bool QQuickWebEngineSettings::hyperlinkAuditingEnabled() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled);
+ return d_ptr->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled);
}
bool QQuickWebEngineSettings::errorPageEnabled() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->testAttribute(WebEngineSettings::ErrorPageEnabled);
+ return d_ptr->testAttribute(WebEngineSettings::ErrorPageEnabled);
}
QString QQuickWebEngineSettings::defaultTextEncoding() const
{
- Q_D(const QQuickWebEngineSettings);
- return d->coreSettings->defaultTextEncoding();
+ return d_ptr->defaultTextEncoding();
}
void QQuickWebEngineSettings::setAutoLoadImages(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::AutoLoadImages);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::AutoLoadImages);
// Set unconditionally as it sets the override for the current settings while the current setting
// could be from the fallback and is prone to changing later on.
- d->coreSettings->setAttribute(WebEngineSettings::AutoLoadImages, on);
- if (wasOn ^ on)
- Q_EMIT autoLoadImagesChanged(on);
+ d_ptr->setAttribute(WebEngineSettings::AutoLoadImages, on);
+ if (wasOn != on)
+ Q_EMIT autoLoadImagesChanged();
}
void QQuickWebEngineSettings::setJavascriptEnabled(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::JavascriptEnabled);
- d->coreSettings->setAttribute(WebEngineSettings::JavascriptEnabled, on);
- if (wasOn ^ on)
- Q_EMIT javascriptEnabledChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptEnabled);
+ d_ptr->setAttribute(WebEngineSettings::JavascriptEnabled, on);
+ if (wasOn != on)
+ Q_EMIT javascriptEnabledChanged();
}
void QQuickWebEngineSettings::setJavascriptCanOpenWindows(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::JavascriptCanOpenWindows);
- d->coreSettings->setAttribute(WebEngineSettings::JavascriptCanOpenWindows, on);
- if (wasOn ^ on)
- Q_EMIT javascriptCanOpenWindowsChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptCanOpenWindows);
+ d_ptr->setAttribute(WebEngineSettings::JavascriptCanOpenWindows, on);
+ if (wasOn != on)
+ Q_EMIT javascriptCanOpenWindowsChanged();
}
void QQuickWebEngineSettings::setJavascriptCanAccessClipboard(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard);
- d->coreSettings->setAttribute(WebEngineSettings::JavascriptCanAccessClipboard, on);
- if (wasOn ^ on)
- Q_EMIT javascriptCanAccessClipboardChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard);
+ d_ptr->setAttribute(WebEngineSettings::JavascriptCanAccessClipboard, on);
+ if (wasOn != on)
+ Q_EMIT javascriptCanAccessClipboardChanged();
}
void QQuickWebEngineSettings::setLinksIncludedInFocusChain(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::LinksIncludedInFocusChain);
- d->coreSettings->setAttribute(WebEngineSettings::LinksIncludedInFocusChain, on);
- if (wasOn ^ on)
- Q_EMIT linksIncludedInFocusChainChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::LinksIncludedInFocusChain);
+ d_ptr->setAttribute(WebEngineSettings::LinksIncludedInFocusChain, on);
+ if (wasOn != on)
+ Q_EMIT linksIncludedInFocusChainChanged();
}
void QQuickWebEngineSettings::setLocalStorageEnabled(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::LocalStorageEnabled);
- d->coreSettings->setAttribute(WebEngineSettings::LocalStorageEnabled, on);
- if (wasOn ^ on)
- Q_EMIT localStorageEnabledChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::LocalStorageEnabled);
+ d_ptr->setAttribute(WebEngineSettings::LocalStorageEnabled, on);
+ if (wasOn != on)
+ Q_EMIT localStorageEnabledChanged();
}
void QQuickWebEngineSettings::setLocalContentCanAccessRemoteUrls(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls);
- d->coreSettings->setAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls, on);
- if (wasOn ^ on)
- Q_EMIT localContentCanAccessRemoteUrlsChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls);
+ d_ptr->setAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls, on);
+ if (wasOn != on)
+ Q_EMIT localContentCanAccessRemoteUrlsChanged();
}
void QQuickWebEngineSettings::setSpatialNavigationEnabled(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::SpatialNavigationEnabled);
- d->coreSettings->setAttribute(WebEngineSettings::SpatialNavigationEnabled, on);
- if (wasOn ^ on)
- Q_EMIT spatialNavigationEnabledChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::SpatialNavigationEnabled);
+ d_ptr->setAttribute(WebEngineSettings::SpatialNavigationEnabled, on);
+ if (wasOn != on)
+ Q_EMIT spatialNavigationEnabledChanged();
}
void QQuickWebEngineSettings::setLocalContentCanAccessFileUrls(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls);
- d->coreSettings->setAttribute(WebEngineSettings::LocalContentCanAccessFileUrls, on);
- if (wasOn ^ on)
- Q_EMIT localContentCanAccessFileUrlsChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls);
+ d_ptr->setAttribute(WebEngineSettings::LocalContentCanAccessFileUrls, on);
+ if (wasOn != on)
+ Q_EMIT localContentCanAccessFileUrlsChanged();
}
void QQuickWebEngineSettings::setHyperlinkAuditingEnabled(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled);
- d->coreSettings->setAttribute(WebEngineSettings::HyperlinkAuditingEnabled, on);
- if (wasOn ^ on)
- Q_EMIT hyperlinkAuditingEnabledChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled);
+ d_ptr->setAttribute(WebEngineSettings::HyperlinkAuditingEnabled, on);
+ if (wasOn != on)
+ Q_EMIT hyperlinkAuditingEnabledChanged();
}
void QQuickWebEngineSettings::setErrorPageEnabled(bool on)
{
- Q_D(QQuickWebEngineSettings);
- bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::ErrorPageEnabled);
- d->coreSettings->setAttribute(WebEngineSettings::ErrorPageEnabled, on);
- if (wasOn ^ on)
- Q_EMIT errorPageEnabledChanged(on);
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::ErrorPageEnabled);
+ d_ptr->setAttribute(WebEngineSettings::ErrorPageEnabled, on);
+ if (wasOn != on)
+ Q_EMIT errorPageEnabledChanged();
}
void QQuickWebEngineSettings::setDefaultTextEncoding(QString encoding)
{
- Q_D(QQuickWebEngineSettings);
- const QString oldDefaultTextEncoding = d->coreSettings->defaultTextEncoding();
- d->coreSettings->setDefaultTextEncoding(encoding);
+ const QString oldDefaultTextEncoding = d_ptr->defaultTextEncoding();
+ d_ptr->setDefaultTextEncoding(encoding);
if (oldDefaultTextEncoding.compare(encoding))
- Q_EMIT defaultTextEncodingChanged(encoding);
+ Q_EMIT defaultTextEncodingChanged();
}
-QQuickWebEngineSettings::QQuickWebEngineSettings()
- : d_ptr(new QQuickWebEngineSettingsPrivate)
+void QQuickWebEngineSettings::setParentSettings(QQuickWebEngineSettings *parentSettings)
{
+ d_ptr->setParentSettings(parentSettings->d_ptr.data());
+ d_ptr->scheduleApplyRecursively();
}
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h
index 4a7c2f834..6e8bfa219 100644
--- a/src/webengine/api/qquickwebenginesettings_p.h
+++ b/src/webengine/api/qquickwebenginesettings_p.h
@@ -41,9 +41,9 @@
#include <QObject>
#include <QScopedPointer>
-QT_BEGIN_NAMESPACE
+class WebEngineSettings;
-class QQuickWebEngineSettingsPrivate;
+QT_BEGIN_NAMESPACE
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject {
Q_OBJECT
@@ -61,8 +61,6 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject {
Q_PROPERTY(QString defaultTextEncoding READ defaultTextEncoding WRITE setDefaultTextEncoding NOTIFY defaultTextEncodingChanged)
public:
- static QQuickWebEngineSettings *globalSettings();
-
~QQuickWebEngineSettings();
bool autoLoadImages() const;
@@ -92,26 +90,28 @@ public:
void setDefaultTextEncoding(QString encoding);
signals:
- void autoLoadImagesChanged(bool on);
- void javascriptEnabledChanged(bool on);
- void javascriptCanOpenWindowsChanged(bool on);
- void javascriptCanAccessClipboardChanged(bool on);
- void linksIncludedInFocusChainChanged(bool on);
- void localStorageEnabledChanged(bool on);
- void localContentCanAccessRemoteUrlsChanged(bool on);
- void spatialNavigationEnabledChanged(bool on);
- void localContentCanAccessFileUrlsChanged(bool on);
- void hyperlinkAuditingEnabledChanged(bool on);
- void errorPageEnabledChanged(bool on);
- void defaultTextEncodingChanged(QString encoding);
+ void autoLoadImagesChanged();
+ void javascriptEnabledChanged();
+ void javascriptCanOpenWindowsChanged();
+ void javascriptCanAccessClipboardChanged();
+ void linksIncludedInFocusChainChanged();
+ void localStorageEnabledChanged();
+ void localContentCanAccessRemoteUrlsChanged();
+ void spatialNavigationEnabledChanged();
+ void localContentCanAccessFileUrlsChanged();
+ void hyperlinkAuditingEnabledChanged();
+ void errorPageEnabledChanged();
+ void defaultTextEncodingChanged();
private:
- QQuickWebEngineSettings();
+ explicit QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings = 0);
Q_DISABLE_COPY(QQuickWebEngineSettings)
- Q_DECLARE_PRIVATE(QQuickWebEngineSettings)
+ friend class QQuickWebEngineProfilePrivate;
friend class QQuickWebEngineViewPrivate;
- QScopedPointer<QQuickWebEngineSettingsPrivate> d_ptr;
+ void setParentSettings(QQuickWebEngineSettings *parentSettings);
+
+ QScopedPointer<WebEngineSettings> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginesingleton.cpp b/src/webengine/api/qquickwebenginesingleton.cpp
index bf4951f3b..4f1bd32f2 100644
--- a/src/webengine/api/qquickwebenginesingleton.cpp
+++ b/src/webengine/api/qquickwebenginesingleton.cpp
@@ -37,12 +37,18 @@
#include "qquickwebenginesingleton_p.h"
#include "qquickwebenginesettings_p.h"
+#include "qquickwebengineprofile_p.h"
QT_BEGIN_NAMESPACE
QQuickWebEngineSettings *QQuickWebEngineSingleton::settings() const
{
- return QQuickWebEngineSettings::globalSettings();
+ return defaultProfile()->settings();
+}
+
+QQuickWebEngineProfile *QQuickWebEngineSingleton::defaultProfile() const
+{
+ return QQuickWebEngineProfile::defaultProfile();
}
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginesingleton_p.h b/src/webengine/api/qquickwebenginesingleton_p.h
index 23205e2df..f983d0ffb 100644
--- a/src/webengine/api/qquickwebenginesingleton_p.h
+++ b/src/webengine/api/qquickwebenginesingleton_p.h
@@ -41,14 +41,16 @@
#include <qtwebengineglobal_p.h>
QT_BEGIN_NAMESPACE
+class QQuickWebEngineProfile;
class QQuickWebEngineSettings;
-
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSingleton : public QObject {
Q_OBJECT
Q_PROPERTY(QQuickWebEngineSettings* settings READ settings CONSTANT FINAL)
+ Q_PROPERTY(QQuickWebEngineProfile* defaultProfile READ defaultProfile CONSTANT FINAL REVISION 1)
public:
QQuickWebEngineSettings *settings() const;
+ QQuickWebEngineProfile *defaultProfile() const;
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 3497c16ad..a47defb7c 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -37,14 +37,17 @@
#include "qquickwebengineview_p.h"
#include "qquickwebengineview_p_p.h"
+#include "browser_context_adapter.h"
#include "certificate_error_controller.h"
#include "javascript_dialog_controller.h"
#include "qquickwebenginehistory_p.h"
+#include "qquickwebenginecertificateerror_p.h"
#include "qquickwebengineloadrequest_p.h"
#include "qquickwebenginenavigationrequest_p.h"
#include "qquickwebenginenewviewrequest_p.h"
+#include "qquickwebengineprofile_p.h"
+#include "qquickwebengineprofile_p_p.h"
#include "qquickwebenginesettings_p.h"
-#include "qquickwebenginesettings_p_p.h"
#include "render_widget_host_view_qt_delegate_quick.h"
#include "render_widget_host_view_qt_delegate_quickwindow.h"
#include "ui_delegates_manager.h"
@@ -58,29 +61,34 @@
#include <QQmlContext>
#include <QQmlEngine>
#include <QQmlProperty>
+#include <QQmlWebChannel>
#include <QScreen>
#include <QStringBuilder>
#include <QUrl>
+#ifndef QT_NO_ACCESSIBILITY
#include <private/qquickaccessibleattached_p.h>
+#endif // QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
+#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
QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
- : adapter(new WebContentsAdapter)
+ : adapter(0)
, e(new QQuickWebEngineViewExperimental(this))
, v(new QQuickWebEngineViewport(this))
, m_history(new QQuickWebEngineHistory(this))
- , m_settings(new QQuickWebEngineSettings)
+ , m_profile(QQuickWebEngineProfile::defaultProfile())
+ , m_settings(new QQuickWebEngineSettings(m_profile->settings()))
, contextMenuExtraItems(0)
, loadProgress(0)
- , inspectable(false)
, m_isFullScreen(false)
, isLoading(false)
, devicePixelRatio(QGuiApplication::primaryScreen()->devicePixelRatio())
@@ -102,7 +110,9 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
// 1x, 2x, 3x etc assets that fit an integral number of pixels.
setDevicePixelRatio(qMax(1, qRound(webPixelRatio)));
}
+#ifndef QT_NO_ACCESSIBILITY
QAccessible::installFactory(&webAccessibleFactory);
+#endif // QT_NO_ACCESSIBILITY
}
QQuickWebEngineViewPrivate::~QQuickWebEngineViewPrivate()
@@ -211,10 +221,21 @@ void QQuickWebEngineViewPrivate::javascriptDialog(QSharedPointer<JavaScriptDialo
ui()->showDialog(dialog);
}
-void QQuickWebEngineViewPrivate::allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &errorController)
+void QQuickWebEngineViewPrivate::allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController)
{
- // ### Implement a way to export this to QML
- Q_UNUSED(errorController);
+ Q_Q(QQuickWebEngineView);
+
+ m_certificateErrorController = errorController;
+ QQuickWebEngineCertificateError *quickController = new QQuickWebEngineCertificateError(errorController);
+ QQmlEngine::setObjectOwnership(quickController, QQmlEngine::JavaScriptOwnership);
+ Q_EMIT q->certificateError(quickController);
+ if (!quickController->deferred())
+ quickController->rejectCertificate();
+}
+
+void QQuickWebEngineViewPrivate::runGeolocationPermissionRequest(const QUrl &url)
+{
+ Q_EMIT e->featurePermissionRequested(url, QQuickWebEngineViewExperimental::Geolocation);
}
void QQuickWebEngineViewPrivate::runFileChooser(FileChooserMode mode, const QString &defaultFileName, const QStringList &acceptedMimeTypes)
@@ -333,8 +354,16 @@ void QQuickWebEngineViewPrivate::focusContainer()
q->forceActiveFocus();
}
+void QQuickWebEngineViewPrivate::unhandledKeyEvent(QKeyEvent *event)
+{
+ Q_Q(QQuickWebEngineView);
+ if (q->parentItem())
+ q->window()->sendEvent(q->parentItem(), event);
+}
+
void QQuickWebEngineViewPrivate::adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &)
{
+ Q_Q(QQuickWebEngineView);
QQuickWebEngineNewViewRequest request;
// This increases the ref-count of newWebContents and will tell Chromium
// to start loading it and possibly return it to its parent page window.open().
@@ -343,9 +372,11 @@ void QQuickWebEngineViewPrivate::adoptNewWindow(WebContentsAdapter *newWebConten
switch (disposition) {
case WebContentsAdapterClient::NewForegroundTabDisposition:
- case WebContentsAdapterClient::NewBackgroundTabDisposition:
request.m_destination = QQuickWebEngineView::NewViewInTab;
break;
+ case WebContentsAdapterClient::NewBackgroundTabDisposition:
+ request.m_destination = QQuickWebEngineView::NewViewInBackgroundTab;
+ break;
case WebContentsAdapterClient::NewPopupDisposition:
request.m_destination = QQuickWebEngineView::NewViewInDialog;
break;
@@ -356,7 +387,7 @@ void QQuickWebEngineViewPrivate::adoptNewWindow(WebContentsAdapter *newWebConten
Q_UNREACHABLE();
}
- emit e->newViewRequested(&request);
+ Q_EMIT q->newViewRequested(&request);
}
void QQuickWebEngineViewPrivate::close()
@@ -387,23 +418,39 @@ void QQuickWebEngineViewPrivate::runMediaAccessPermissionRequest(const QUrl &sec
return;
QQuickWebEngineViewExperimental::Feature feature;
if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture) && requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture))
- feature = QQuickWebEngineViewExperimental::MediaAudioVideoDevices;
+ feature = QQuickWebEngineViewExperimental::MediaAudioVideoCapture;
else if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture))
- feature = QQuickWebEngineViewExperimental::MediaAudioDevices;
+ feature = QQuickWebEngineViewExperimental::MediaAudioCapture;
else // WebContentsAdapterClient::MediaVideoCapture
- feature = QQuickWebEngineViewExperimental::MediaVideoDevices;
+ feature = QQuickWebEngineViewExperimental::MediaVideoCapture;
Q_EMIT e->featurePermissionRequested(securityOrigin, feature);
}
+void QQuickWebEngineViewPrivate::runMouseLockPermissionRequest(const QUrl &securityOrigin)
+{
+
+ Q_UNUSED(securityOrigin);
+
+ // TODO: Add mouse lock support
+ adapter->grantMouseLockPermission(false);
+}
+
+#ifndef QT_NO_ACCESSIBILITY
QObject *QQuickWebEngineViewPrivate::accessibilityParentObject()
{
Q_Q(QQuickWebEngineView);
return q;
}
+#endif // QT_NO_ACCESSIBILITY
+
+BrowserContextAdapter *QQuickWebEngineViewPrivate::browserContextAdapter()
+{
+ return m_profile->d_ptr->browserContext();
+}
WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const
{
- return m_settings->d_func()->coreSettings.data();
+ return m_settings->d_ptr.data();
}
void QQuickWebEngineViewPrivate::setDevicePixelRatio(qreal devicePixelRatio)
@@ -414,6 +461,7 @@ void QQuickWebEngineViewPrivate::setDevicePixelRatio(qreal devicePixelRatio)
m_dpiScale = devicePixelRatio / screen->devicePixelRatio();
}
+#ifndef QT_NO_ACCESSIBILITY
QQuickWebEngineViewAccessible::QQuickWebEngineViewAccessible(QQuickWebEngineView *o)
: QAccessibleObject(o)
{}
@@ -460,6 +508,7 @@ QAccessible::State QQuickWebEngineViewAccessible::state() const
QAccessible::State s;
return s;
}
+#endif // QT_NO_ACCESSIBILITY
void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContents)
{
@@ -470,6 +519,11 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent
return;
}
+ if (browserContextAdapter() != webContents->browserContextAdapter()) {
+ qWarning("Can not adopt content from a different WebEngineProfile.");
+ return;
+ }
+
Q_Q(QQuickWebEngineView);
// This throws away the WebContentsAdapter that has been used until now.
// All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter.
@@ -493,22 +547,33 @@ QQuickWebEngineView::QQuickWebEngineView(QQuickItem *parent)
{
Q_D(QQuickWebEngineView);
d->e->q_ptr = d->q_ptr = this;
- d->adapter->initialize(d);
this->setActiveFocusOnTab(true);
this->setFlag(QQuickItem::ItemIsFocusScope);
+#ifndef QT_NO_ACCESSIBILITY
QQuickAccessibleAttached *accessible = QQuickAccessibleAttached::qmlAttachedProperties(this);
accessible->setRole(QAccessible::Grouping);
+#endif // QT_NO_ACCESSIBILITY
}
QQuickWebEngineView::~QQuickWebEngineView()
{
}
+void QQuickWebEngineViewPrivate::ensureContentsAdapter()
+{
+ if (!adapter) {
+ adapter = new WebContentsAdapter();
+ adapter->initialize(this);
+ if (explicitUrl.isValid())
+ adapter->load(explicitUrl);
+ }
+}
+
QUrl QQuickWebEngineView::url() const
{
Q_D(const QQuickWebEngineView);
- return d->explicitUrl.isValid() ? d->explicitUrl : d->adapter->activeUrl();
+ return d->explicitUrl.isValid() ? d->explicitUrl : (d->adapter ? d->adapter->activeUrl() : QUrl());
}
void QQuickWebEngineView::setUrl(const QUrl& url)
@@ -518,7 +583,10 @@ void QQuickWebEngineView::setUrl(const QUrl& url)
Q_D(QQuickWebEngineView);
d->explicitUrl = url;
- d->adapter->load(url);
+ if (d->adapter)
+ d->adapter->load(url);
+ if (!qmlEngine(this))
+ d->ensureContentsAdapter();
}
QUrl QQuickWebEngineView::icon() const
@@ -530,33 +598,93 @@ QUrl QQuickWebEngineView::icon() const
void QQuickWebEngineView::loadHtml(const QString &html, const QUrl &baseUrl)
{
Q_D(QQuickWebEngineView);
- d->adapter->setContent(html.toUtf8(), QStringLiteral("text/html;charset=UTF-8"), baseUrl);
+ d->explicitUrl = QUrl();
+ if (!qmlEngine(this))
+ d->ensureContentsAdapter();
+ if (d->adapter)
+ d->adapter->setContent(html.toUtf8(), QStringLiteral("text/html;charset=UTF-8"), baseUrl);
}
void QQuickWebEngineView::goBack()
{
Q_D(QQuickWebEngineView);
+ if (!d->adapter)
+ return;
d->adapter->navigateToOffset(-1);
}
void QQuickWebEngineView::goForward()
{
Q_D(QQuickWebEngineView);
+ if (!d->adapter)
+ return;
d->adapter->navigateToOffset(1);
}
void QQuickWebEngineView::reload()
{
Q_D(QQuickWebEngineView);
+ if (!d->adapter)
+ return;
d->adapter->reload();
}
void QQuickWebEngineView::stop()
{
Q_D(QQuickWebEngineView);
+ if (!d->adapter)
+ return;
d->adapter->stop();
}
+void QQuickWebEngineView::setZoomFactor(qreal arg)
+{
+ Q_D(QQuickWebEngineView);
+ if (!d->adapter)
+ return;
+ qreal oldFactor = d->adapter->currentZoomFactor();
+ d->adapter->setZoomFactor(arg);
+ if (qFuzzyCompare(oldFactor, d->adapter->currentZoomFactor()))
+ return;
+
+ emit zoomFactorChanged(arg);
+}
+
+QQuickWebEngineProfile *QQuickWebEngineView::profile() const
+{
+ Q_D(const QQuickWebEngineView);
+ return d->m_profile;
+}
+
+void QQuickWebEngineView::setProfile(QQuickWebEngineProfile *profile)
+{
+ Q_D(QQuickWebEngineView);
+ d->setProfile(profile);
+}
+
+QQuickWebEngineSettings *QQuickWebEngineView::settings() const
+{
+ Q_D(const QQuickWebEngineView);
+ return d->m_settings.data();
+}
+
+void QQuickWebEngineViewPrivate::setProfile(QQuickWebEngineProfile *profile)
+{
+ if (profile == m_profile)
+ return;
+ m_profile = profile;
+ m_settings->setParentSettings(profile->settings());
+
+ if (adapter && adapter->browserContext() != browserContextAdapter()->browserContext()) {
+ // When the profile changes we need to create a new WebContentAdapter and reload the active URL.
+ QUrl activeUrl = adapter->activeUrl();
+ adapter = 0;
+ ensureContentsAdapter();
+ if (!explicitUrl.isValid() && activeUrl.isValid())
+ adapter->load(activeUrl);
+ }
+}
+
void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVariant &result)
{
Q_Q(QQuickWebEngineView);
@@ -589,24 +717,32 @@ int QQuickWebEngineView::loadProgress() const
QString QQuickWebEngineView::title() const
{
Q_D(const QQuickWebEngineView);
+ if (!d->adapter)
+ return QString();
return d->adapter->pageTitle();
}
bool QQuickWebEngineView::canGoBack() const
{
Q_D(const QQuickWebEngineView);
+ if (!d->adapter)
+ return false;
return d->adapter->canGoBack();
}
bool QQuickWebEngineView::canGoForward() const
{
Q_D(const QQuickWebEngineView);
+ if (!d->adapter)
+ return false;
return d->adapter->canGoForward();
}
void QQuickWebEngineView::runJavaScript(const QString &script, const QJSValue &callback)
{
Q_D(QQuickWebEngineView);
+ if (!d->adapter)
+ return;
if (!callback.isUndefined()) {
quint64 requestId = d_ptr->adapter->runJavaScriptCallbackResult(script);
d->m_callbacks.insert(requestId, callback);
@@ -620,17 +756,12 @@ QQuickWebEngineViewExperimental *QQuickWebEngineView::experimental() const
return d->e.data();
}
-bool QQuickWebEngineViewExperimental::inspectable() const
+qreal QQuickWebEngineView::zoomFactor() const
{
Q_D(const QQuickWebEngineView);
- return d->inspectable;
-}
-
-void QQuickWebEngineViewExperimental::setInspectable(bool enable)
-{
- Q_D(QQuickWebEngineView);
- d->inspectable = enable;
- d->adapter->enableInspector(enable);
+ if (!d->adapter)
+ return 1.0;
+ return d->adapter->currentZoomFactor();
}
void QQuickWebEngineViewExperimental::setIsFullScreen(bool fullscreen)
@@ -657,24 +788,22 @@ QQmlComponent *QQuickWebEngineViewExperimental::extraContextMenuEntriesComponent
return d_ptr->contextMenuExtraItems;
}
-QQuickWebEngineSettings *QQuickWebEngineViewExperimental::settings() const
-{
- return d_ptr->m_settings.data();
-}
-
void QQuickWebEngineViewExperimental::findText(const QString &subString, FindFlags options, const QJSValue &callback)
{
+ Q_D(QQuickWebEngineView);
+ if (!d->adapter)
+ return;
if (subString.isEmpty()) {
- d_ptr->adapter->stopFinding();
+ d->adapter->stopFinding();
if (!callback.isUndefined()) {
QJSValueList args;
args.append(QJSValue(0));
const_cast<QJSValue&>(callback).call(args);
}
} else {
- quint64 requestId = d_ptr->adapter->findText(subString, options & FindCaseSensitively, options & FindBackward);
+ quint64 requestId = d->adapter->findText(subString, options & FindCaseSensitively, options & FindBackward);
if (!callback.isUndefined())
- d_ptr->m_callbacks.insert(requestId, callback);
+ d->m_callbacks.insert(requestId, callback);
}
}
@@ -683,29 +812,54 @@ QQuickWebEngineHistory *QQuickWebEngineViewExperimental::navigationHistory() con
return d_ptr->m_history.data();
}
+QQmlWebChannel *QQuickWebEngineViewExperimental::webChannel() const
+{
+ d_ptr->ensureContentsAdapter();
+ QQmlWebChannel *qmlWebChannel = qobject_cast<QQmlWebChannel *>(d_ptr->adapter->webChannel());
+ Q_ASSERT(!d_ptr->adapter->webChannel() || qmlWebChannel);
+ if (!qmlWebChannel) {
+ qmlWebChannel = new QQmlWebChannel;
+ d_ptr->adapter->setWebChannel(qmlWebChannel);
+ }
+ return qmlWebChannel;
+}
+
+void QQuickWebEngineViewExperimental::setWebChannel(QQmlWebChannel *webChannel)
+{
+ d_ptr->adapter->setWebChannel(webChannel);
+}
+
void QQuickWebEngineViewExperimental::grantFeaturePermission(const QUrl &securityOrigin, QQuickWebEngineViewExperimental::Feature feature, bool granted)
{
- if (!granted && feature >= MediaAudioDevices && feature <= MediaAudioVideoDevices) {
+ if (!d_ptr->adapter)
+ return;
+ if (!granted && feature >= MediaAudioCapture && feature <= MediaAudioVideoCapture) {
d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaNone);
return;
}
switch (feature) {
- case MediaAudioDevices:
+ case MediaAudioCapture:
d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaAudioCapture);
break;
- case MediaVideoDevices:
+ case MediaVideoCapture:
d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaVideoCapture);
break;
- case MediaAudioVideoDevices:
- d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaRequestFlags(WebContentsAdapterClient::MediaAudioCapture
- | WebContentsAdapterClient::MediaVideoCapture));
+ case MediaAudioVideoCapture:
+ d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaRequestFlags(WebContentsAdapterClient::MediaAudioCapture | WebContentsAdapterClient::MediaVideoCapture));
break;
+ case Geolocation:
+ d_ptr->adapter->runGeolocationRequestCallback(securityOrigin, granted);
+ break;
+ default:
+ Q_UNREACHABLE();
}
}
void QQuickWebEngineViewExperimental::goBackTo(int index)
{
+ if (!d_ptr->adapter)
+ return;
int count = d_ptr->adapter->currentNavigationEntryIndex();
if (index < 0 || index >= count)
return;
@@ -715,6 +869,8 @@ void QQuickWebEngineViewExperimental::goBackTo(int index)
void QQuickWebEngineViewExperimental::goForwardTo(int index)
{
+ if (!d_ptr->adapter)
+ return;
int count = d_ptr->adapter->navigationEntryCount() - d_ptr->adapter->currentNavigationEntryIndex() - 1;
if (index < 0 || index >= count)
return;
@@ -734,7 +890,7 @@ void QQuickWebEngineView::geometryChanged(const QRectF &newGeometry, const QRect
void QQuickWebEngineView::itemChange(ItemChange change, const ItemChangeData &value)
{
Q_D(QQuickWebEngineView);
- if (change == ItemSceneChange || change == ItemVisibleHasChanged) {
+ if (d->adapter && (change == ItemSceneChange || change == ItemVisibleHasChanged)) {
if (window() && isVisible())
d->adapter->wasShown();
else
@@ -743,6 +899,13 @@ void QQuickWebEngineView::itemChange(ItemChange change, const ItemChangeData &va
QQuickItem::itemChange(change, value);
}
+void QQuickWebEngineView::componentComplete()
+{
+ Q_D(QQuickWebEngineView);
+ QQuickItem::componentComplete();
+ d->ensureContentsAdapter();
+}
+
QQuickWebEngineViewExperimental::QQuickWebEngineViewExperimental(QQuickWebEngineViewPrivate *viewPrivate)
: q_ptr(0)
, d_ptr(viewPrivate)
@@ -774,6 +937,8 @@ void QQuickWebEngineViewport::setDevicePixelRatio(qreal devicePixelRatio)
if (d->devicePixelRatio == devicePixelRatio)
return;
d->setDevicePixelRatio(devicePixelRatio);
+ if (!d->adapter)
+ return;
d->adapter->dpiScaleChanged();
Q_EMIT devicePixelRatioChanged();
}
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 22713ee22..56a1b47ab 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -42,10 +42,14 @@
QT_BEGIN_NAMESPACE
-class QQuickWebEngineViewExperimental;
-class QQuickWebEngineViewPrivate;
+class QQuickWebEngineCertificateError;
class QQuickWebEngineLoadRequest;
class QQuickWebEngineNavigationRequest;
+class QQuickWebEngineNewViewRequest;
+class QQuickWebEngineProfile;
+class QQuickWebEngineSettings;
+class QQuickWebEngineViewExperimental;
+class QQuickWebEngineViewPrivate;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_OBJECT
@@ -56,6 +60,9 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY urlChanged)
Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY urlChanged)
+ Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged REVISION 1)
+ Q_PROPERTY(QQuickWebEngineProfile *profile READ profile WRITE setProfile FINAL REVISION 1)
+ Q_PROPERTY(QQuickWebEngineSettings *settings READ settings REVISION 1)
Q_ENUMS(NavigationRequestAction);
Q_ENUMS(NavigationType);
Q_ENUMS(LoadStatus);
@@ -75,6 +82,8 @@ public:
QString title() const;
bool canGoBack() const;
bool canGoForward() const;
+ qreal zoomFactor() const;
+ void setZoomFactor(qreal arg);
QQuickWebEngineViewExperimental *experimental() const;
@@ -116,7 +125,8 @@ public:
enum NewViewDestination {
NewViewInWindow,
NewViewInTab,
- NewViewInDialog
+ NewViewInDialog,
+ NewViewInBackgroundTab
};
// must match WebContentsAdapterClient::JavaScriptConsoleMessageLevel
@@ -126,6 +136,14 @@ public:
ErrorMessageLevel
};
+ // QmlParserStatus
+ virtual void componentComplete() Q_DECL_OVERRIDE;
+
+ QQuickWebEngineProfile *profile() const;
+ void setProfile(QQuickWebEngineProfile *);
+
+ QQuickWebEngineSettings *settings() const;
+
public Q_SLOTS:
void runJavaScript(const QString&, const QJSValue & = QJSValue());
void loadHtml(const QString &html, const QUrl &baseUrl = QUrl());
@@ -143,6 +161,9 @@ Q_SIGNALS:
void linkHovered(const QUrl &hoveredUrl);
void navigationRequested(QQuickWebEngineNavigationRequest *request);
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID);
+ Q_REVISION(1) void certificateError(QQuickWebEngineCertificateError *error);
+ Q_REVISION(1) void newViewRequested(QQuickWebEngineNewViewRequest *request);
+ Q_REVISION(1) void zoomFactorChanged(qreal arg);
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
@@ -155,7 +176,9 @@ private:
friend class QQuickWebEngineViewExperimental;
friend class QQuickWebEngineViewExperimentalExtension;
friend class QQuickWebEngineNewViewRequest;
+#ifndef QT_NO_ACCESSIBILITY
friend class QQuickWebEngineViewAccessible;
+#endif // QT_NO_ACCESSIBILITY
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 6662f1f02..d7785092f 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -51,11 +51,11 @@ class UIDelegatesManager;
QT_BEGIN_NAMESPACE
class QQuickWebEngineHistory;
-class QQuickWebEngineNewViewRequest;
class QQuickWebEngineView;
class QQmlComponent;
class QQmlContext;
class QQuickWebEngineSettings;
+class QQmlWebChannel;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewport : public QObject {
Q_OBJECT
@@ -79,18 +79,18 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewExperimental : public QObjec
Q_OBJECT
Q_PROPERTY(QQuickWebEngineViewport *viewport READ viewport)
Q_PROPERTY(QQmlComponent *extraContextMenuEntriesComponent READ extraContextMenuEntriesComponent WRITE setExtraContextMenuEntriesComponent NOTIFY extraContextMenuEntriesComponentChanged)
- Q_PROPERTY(bool inspectable READ inspectable WRITE setInspectable)
Q_PROPERTY(bool isFullScreen READ isFullScreen WRITE setIsFullScreen NOTIFY isFullScreenChanged)
Q_PROPERTY(QQuickWebEngineHistory *navigationHistory READ navigationHistory CONSTANT FINAL)
- Q_PROPERTY(QQuickWebEngineSettings *settings READ settings)
+ Q_PROPERTY(QQmlWebChannel *webChannel READ webChannel WRITE setWebChannel)
Q_ENUMS(Feature)
Q_FLAGS(FindFlags)
public:
enum Feature {
- MediaAudioDevices,
- MediaVideoDevices,
- MediaAudioVideoDevices
+ MediaAudioCapture,
+ MediaVideoCapture,
+ MediaAudioVideoCapture,
+ Geolocation
};
enum FindFlag {
@@ -99,8 +99,6 @@ public:
};
Q_DECLARE_FLAGS(FindFlags, FindFlag)
- bool inspectable() const;
- void setInspectable(bool);
void setIsFullScreen(bool fullscreen);
bool isFullScreen() const;
QQuickWebEngineViewport *viewport() const;
@@ -108,6 +106,8 @@ public:
QQmlComponent *extraContextMenuEntriesComponent() const;
QQuickWebEngineHistory *navigationHistory() const;
QQuickWebEngineSettings *settings() const;
+ QQmlWebChannel *webChannel() const;
+ void setWebChannel(QQmlWebChannel *);
public Q_SLOTS:
void goBackTo(int index);
@@ -116,7 +116,6 @@ public Q_SLOTS:
void grantFeaturePermission(const QUrl &securityOrigin, Feature, bool granted);
Q_SIGNALS:
- void newViewRequested(QQuickWebEngineNewViewRequest *request);
void fullScreenRequested(bool fullScreen);
void isFullScreenChanged();
void extraContextMenuEntriesComponentChanged();
@@ -159,6 +158,7 @@ public:
virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE;
virtual void loadFinished(bool success, const QUrl &url, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE;
virtual void focusContainer() Q_DECL_OVERRIDE;
+ virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;
virtual void requestFullScreen(bool) Q_DECL_OVERRIDE;
@@ -175,33 +175,43 @@ public:
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
virtual void authenticationRequired(const QUrl&, const QString&, bool, const QString&, QString*, QString*) Q_DECL_OVERRIDE { }
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE;
+ virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE;
+#ifndef QT_NO_ACCESSIBILITY
virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE;
+#endif // QT_NO_ACCESSIBILITY
virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE;
- virtual void allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &errorController);
+ virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController);
+ virtual void runGeolocationPermissionRequest(QUrl const&) Q_DECL_OVERRIDE;
+
+ virtual BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE;
void setDevicePixelRatio(qreal);
void adoptWebContents(WebContentsAdapter *webContents);
+ void setProfile(QQuickWebEngineProfile *profile);
+ void ensureContentsAdapter();
QExplicitlySharedDataPointer<WebContentsAdapter> adapter;
QScopedPointer<QQuickWebEngineViewExperimental> e;
QScopedPointer<QQuickWebEngineViewport> v;
QScopedPointer<QQuickWebEngineHistory> m_history;
+ QQuickWebEngineProfile *m_profile;
QScopedPointer<QQuickWebEngineSettings> m_settings;
QQmlComponent *contextMenuExtraItems;
QUrl explicitUrl;
QUrl icon;
int loadProgress;
- bool inspectable;
bool m_isFullScreen;
bool isLoading;
qreal devicePixelRatio;
QMap<quint64, QJSValue> m_callbacks;
+ QSharedPointer<CertificateErrorController> m_certificateErrorController;
private:
QScopedPointer<UIDelegatesManager> m_uIDelegatesManager;
qreal m_dpiScale;
};
+#ifndef QT_NO_ACCESSIBILITY
class QQuickWebEngineViewAccessible : public QAccessibleObject
{
public:
@@ -217,7 +227,7 @@ public:
private:
QQuickWebEngineView *engineView() const { return static_cast<QQuickWebEngineView*>(object()); }
};
-
+#endif // QT_NO_ACCESSIBILITY
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickWebEngineViewExperimental)