summaryrefslogtreecommitdiffstats
path: root/src/core/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/api')
-rw-r--r--src/core/api/core_api.pro2
-rw-r--r--src/core/api/qwebengineclientcertificatestore.cpp53
-rw-r--r--src/core/api/qwebengineclientcertificatestore.h22
-rw-r--r--src/core/api/qwebenginecookiestore.cpp2
-rw-r--r--src/core/api/qwebenginemessagepumpscheduler.cpp72
-rw-r--r--src/core/api/qwebenginemessagepumpscheduler_p.h80
-rw-r--r--src/core/api/qwebenginenotification.cpp15
-rw-r--r--src/core/api/qwebenginenotification.h21
-rw-r--r--src/core/api/qwebengineurlrequestjob.cpp2
-rw-r--r--src/core/api/qwebengineurlrequestjob.h2
-rw-r--r--src/core/api/qwebengineurlschemehandler.cpp2
11 files changed, 195 insertions, 78 deletions
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index 4d3ddcc8e..326d4481f 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -38,6 +38,7 @@ HEADERS = \
qwebenginecookiestore.h \
qwebenginecookiestore_p.h \
qwebenginehttprequest.h \
+ qwebenginemessagepumpscheduler_p.h \
qwebenginenotification.h \
qwebenginequotarequest.h \
qwebengineregisterprotocolhandlerrequest.h \
@@ -53,6 +54,7 @@ SOURCES = \
qwebengineclientcertificatestore.cpp \
qwebenginecookiestore.cpp \
qwebenginehttprequest.cpp \
+ qwebenginemessagepumpscheduler.cpp \
qwebenginenotification.cpp \
qwebenginequotarequest.cpp \
qwebengineregisterprotocolhandlerrequest.cpp \
diff --git a/src/core/api/qwebengineclientcertificatestore.cpp b/src/core/api/qwebengineclientcertificatestore.cpp
index 850dd16d7..854628b29 100644
--- a/src/core/api/qwebengineclientcertificatestore.cpp
+++ b/src/core/api/qwebengineclientcertificatestore.cpp
@@ -48,8 +48,6 @@ QT_BEGIN_NAMESPACE
#if QT_CONFIG(ssl)
-QWebEngineClientCertificateStore *QWebEngineClientCertificateStore::m_instance = nullptr;
-
/*!
\class QWebEngineClientCertificateStore::Entry
\inmodule QtWebEngineCore
@@ -69,8 +67,8 @@ QWebEngineClientCertificateStore *QWebEngineClientCertificateStore::m_instance =
The getInstance() method can be used to access the single instance of the class.
*/
-QWebEngineClientCertificateStore::QWebEngineClientCertificateStore()
- : d_ptr(new QtWebEngineCore::ClientCertificateStoreData)
+QWebEngineClientCertificateStore::QWebEngineClientCertificateStore(QtWebEngineCore::ClientCertificateStoreData *storeData)
+ : m_storeData(storeData)
{
}
@@ -85,59 +83,35 @@ QWebEngineClientCertificateStore::~QWebEngineClientCertificateStore()
}
/*!
- Returns an in-memory client certificate store.
-*/
-
-QWebEngineClientCertificateStore *QWebEngineClientCertificateStore::getInstance()
-{
- if (!m_instance)
- m_instance = new QWebEngineClientCertificateStore;
- return m_instance;
-}
-
-/*!
Adds a \a certificate with the \a privateKey to the in-memory client certificate store.
*/
void QWebEngineClientCertificateStore::add(const QSslCertificate &certificate, const QSslKey &privateKey)
{
- d_ptr->add(certificate, privateKey);
+ m_storeData->add(certificate, privateKey);
}
/*!
- Returns a list of private and public keys of client certificates in the in-memory store.
- Returns an empty list if the in-memory store does not contain certificates.
+ Returns a list of the client certificates in the in-memory store.
+ Returns an empty list if the store does not contain any certificates.
*/
-QList<QWebEngineClientCertificateStore::Entry> QWebEngineClientCertificateStore::toList() const
+QVector<QSslCertificate> QWebEngineClientCertificateStore::certificates() const
{
- QList<Entry> certificateList;
- for (auto data : qAsConst(d_ptr->addedCerts)) {
- Entry entry;
- entry.certificate = data->certificate;
- entry.privateKey = data->key;
- certificateList.append(entry);
- }
+ QVector<QSslCertificate> certificateList;
+ for (auto data : qAsConst(m_storeData->extraCerts))
+ certificateList.append(data->certificate);
return certificateList;
}
/*!
Deletes all the instances of the client certificate in the in-memory client certificate store
- that matches the certificate in the \a entry.
+ that matches the certificate \a certificate.
*/
-void QWebEngineClientCertificateStore::remove(Entry entry)
+void QWebEngineClientCertificateStore::remove(const QSslCertificate &certificate)
{
- auto it = d_ptr->addedCerts.begin();
- while (it != d_ptr->addedCerts.end()) {
- auto *overrideData = *it;
- if (entry.certificate.toDer() == overrideData->certificate.toDer()) {
- d_ptr->deletedCerts.append(overrideData);
- it = d_ptr->addedCerts.erase(it);
- continue;
- }
- ++it;
- }
+ m_storeData->remove(certificate);
}
/*!
@@ -146,8 +120,7 @@ void QWebEngineClientCertificateStore::remove(Entry entry)
void QWebEngineClientCertificateStore::clear()
{
- d_ptr->deletedCerts.append(d_ptr->addedCerts);
- d_ptr->addedCerts.clear();
+ m_storeData->clear();
}
#endif // QT_CONFIG(ssl)
diff --git a/src/core/api/qwebengineclientcertificatestore.h b/src/core/api/qwebengineclientcertificatestore.h
index c0bd66e2b..d9a1a0545 100644
--- a/src/core/api/qwebengineclientcertificatestore.h
+++ b/src/core/api/qwebengineclientcertificatestore.h
@@ -42,42 +42,34 @@
#include <QtWebEngineCore/qtwebenginecoreglobal.h>
-#include <QtCore/qscopedpointer.h>
+#include <QtCore/qvector.h>
#include <QtNetwork/qsslcertificate.h>
#include <QtNetwork/qsslkey.h>
namespace QtWebEngineCore {
-class ClientCertOverrideStore;
struct ClientCertificateStoreData;
+class ProfileAdapter;
}
QT_BEGIN_NAMESPACE
#if QT_CONFIG(ssl)
-
class QWEBENGINECORE_EXPORT QWebEngineClientCertificateStore {
public:
- struct Entry {
- QSslKey privateKey;
- QSslCertificate certificate;
- };
-
- static QWebEngineClientCertificateStore *getInstance();
void add(const QSslCertificate &certificate, const QSslKey &privateKey);
- QList<Entry> toList() const;
- void remove(Entry entry);
+ QVector<QSslCertificate> certificates() const;
+ void remove(const QSslCertificate &certificate);
void clear();
private:
- friend class QtWebEngineCore::ClientCertOverrideStore;
- static QWebEngineClientCertificateStore *m_instance;
+ friend class QtWebEngineCore::ProfileAdapter;
Q_DISABLE_COPY(QWebEngineClientCertificateStore)
- QWebEngineClientCertificateStore();
+ QWebEngineClientCertificateStore(QtWebEngineCore::ClientCertificateStoreData *storeData);
~QWebEngineClientCertificateStore();
- QScopedPointer<QtWebEngineCore::ClientCertificateStoreData> d_ptr;
+ QtWebEngineCore::ClientCertificateStoreData *m_storeData;
};
#endif // QT_CONFIG(ssl)
diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp
index 035c98342..3897fb128 100644
--- a/src/core/api/qwebenginecookiestore.cpp
+++ b/src/core/api/qwebenginecookiestore.cpp
@@ -382,7 +382,7 @@ void QWebEngineCookieStore::setCookieFilter(std::function<bool(const FilterReque
\inmodule QtWebEngineCore
\since 5.11
- \brief This struct is used in conjunction with QWebEngineCookieStore::setCookieFilter() and is
+ \brief The QWebEngineCookieStore::FilterRequest struct is used in conjunction with QWebEngineCookieStore::setCookieFilter() and is
the type \a filterCallback operates on.
\sa QWebEngineCookieStore::setCookieFilter()
diff --git a/src/core/api/qwebenginemessagepumpscheduler.cpp b/src/core/api/qwebenginemessagepumpscheduler.cpp
new file mode 100644
index 000000000..34cbc49bf
--- /dev/null
+++ b/src/core/api/qwebenginemessagepumpscheduler.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebenginemessagepumpscheduler_p.h"
+
+#include <QAbstractEventDispatcher>
+#include <QCoreApplication>
+#include <QTimerEvent>
+
+QWebEngineMessagePumpScheduler::QWebEngineMessagePumpScheduler(std::function<void()> callback)
+ : m_callback(std::move(callback))
+{}
+
+void QWebEngineMessagePumpScheduler::scheduleWork()
+{
+ QCoreApplication::postEvent(this, new QTimerEvent(0));
+}
+
+void QWebEngineMessagePumpScheduler::scheduleDelayedWork(int delay)
+{
+ if (delay < 0) {
+ killTimer(m_timerId);
+ m_timerId = 0;
+ } else if (!m_timerId || delay < QAbstractEventDispatcher::instance()->remainingTime(m_timerId)) {
+ killTimer(m_timerId);
+ m_timerId = startTimer(delay);
+ }
+}
+
+void QWebEngineMessagePumpScheduler::timerEvent(QTimerEvent *ev)
+{
+ Q_ASSERT(!ev->timerId() || m_timerId == ev->timerId());
+ killTimer(m_timerId);
+ m_timerId = 0;
+ m_callback();
+}
diff --git a/src/core/api/qwebenginemessagepumpscheduler_p.h b/src/core/api/qwebenginemessagepumpscheduler_p.h
new file mode 100644
index 000000000..4c9e4d600
--- /dev/null
+++ b/src/core/api/qwebenginemessagepumpscheduler_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINEMESSAGEPUMPSCHEDULER_P_H
+#define QWEBENGINEMESSAGEPUMPSCHEDULER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qtwebenginecoreglobal_p.h"
+
+#include <QtCore/qobject.h>
+
+#include <functional>
+
+QT_BEGIN_NAMESPACE
+
+class QWEBENGINECORE_PRIVATE_EXPORT QWebEngineMessagePumpScheduler : public QObject
+{
+ Q_OBJECT
+public:
+ QWebEngineMessagePumpScheduler(std::function<void()> callback);
+ void scheduleWork();
+ void scheduleDelayedWork(int delay);
+
+protected:
+ void timerEvent(QTimerEvent *ev) override;
+
+private:
+ int m_timerId = 0;
+ std::function<void()> m_callback;
+};
+
+QT_END_NAMESPACE
+
+#endif // !QWEBENGINEMESSAGEPUMPSCHEDULER_P_H
diff --git a/src/core/api/qwebenginenotification.cpp b/src/core/api/qwebenginenotification.cpp
index 0b91cf273..89fd1eff9 100644
--- a/src/core/api/qwebenginenotification.cpp
+++ b/src/core/api/qwebenginenotification.cpp
@@ -55,6 +55,11 @@ using QtWebEngineCore::UserNotificationController;
\inmodule QtWebEngineCore
This class contains the information and API for HTML5 desktop and push notifications.
+
+ Web engine notifications are passed to the user in the
+ \l QWebEngineProfile::setNotificationPresenter() and
+ \l QQuickWebEngineProfile::userNotification() calls and the
+ \l WebEngineProfile::userNotification() signal.
*/
class QWebEngineNotificationPrivate : public UserNotificationController::Client {
@@ -212,18 +217,18 @@ QString QWebEngineNotification::language() const
\brief The text direction for the notification's title and body.
\sa title(), message()
*/
-QWebEngineNotification::Direction QWebEngineNotification::direction() const
+Qt::LayoutDirection QWebEngineNotification::direction() const
{
Q_D(const QWebEngineNotification);
- return d ? static_cast<Direction>(d->controller->direction()) : DirectionAuto;
+ return d ? d->controller->direction() : Qt::LayoutDirectionAuto;
}
/*!
- Returns \c true if the notification is a default constructed null notification.
+ Returns \c true if the notification is not a default constructed null notification.
*/
-bool QWebEngineNotification::isNull() const
+bool QWebEngineNotification::isValid() const
{
- return d_ptr.isNull();
+ return !d_ptr.isNull();
}
/*!
diff --git a/src/core/api/qwebenginenotification.h b/src/core/api/qwebenginenotification.h
index b6b7414f9..0012e5d78 100644
--- a/src/core/api/qwebenginenotification.h
+++ b/src/core/api/qwebenginenotification.h
@@ -64,22 +64,15 @@ class QWEBENGINECORE_EXPORT QWebEngineNotification : public QObject {
Q_PROPERTY(QString message READ message CONSTANT FINAL)
Q_PROPERTY(QString tag READ tag CONSTANT FINAL)
Q_PROPERTY(QString language READ language CONSTANT FINAL)
- Q_PROPERTY(Direction direction READ direction CONSTANT FINAL)
+ Q_PROPERTY(Qt::LayoutDirection direction READ direction CONSTANT FINAL)
public:
QWebEngineNotification();
- QWebEngineNotification(const QWebEngineNotification &);
+ QWebEngineNotification(const QWebEngineNotification &other);
virtual ~QWebEngineNotification();
- const QWebEngineNotification &operator=(const QWebEngineNotification &);
+ const QWebEngineNotification &operator=(const QWebEngineNotification &other);
- enum Direction {
- LeftToRight = Qt::LeftToRight,
- RightToLeft = Qt::RightToLeft,
- DirectionAuto = Qt::LayoutDirectionAuto
- };
- Q_ENUM(Direction)
-
- bool matches(const QWebEngineNotification &) const;
+ bool matches(const QWebEngineNotification &other) const;
QUrl origin() const;
QIcon icon() const;
@@ -87,9 +80,9 @@ public:
QString message() const;
QString tag() const;
QString language() const;
- Direction direction() const;
+ Qt::LayoutDirection direction() const;
- bool isNull() const;
+ bool isValid() const;
public Q_SLOTS:
void show() const;
@@ -100,7 +93,7 @@ Q_SIGNALS:
void closed();
private:
- QWebEngineNotification(const QSharedPointer<QtWebEngineCore::UserNotificationController> &);
+ QWebEngineNotification(const QSharedPointer<QtWebEngineCore::UserNotificationController> &controller);
Q_DECLARE_PRIVATE(QWebEngineNotification)
QScopedPointer<QWebEngineNotificationPrivate> d_ptr;
friend class QQuickWebEngineProfilePrivate;
diff --git a/src/core/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp
index 41b43d42c..bc860b3b3 100644
--- a/src/core/api/qwebengineurlrequestjob.cpp
+++ b/src/core/api/qwebengineurlrequestjob.cpp
@@ -143,7 +143,7 @@ QUrl QWebEngineUrlRequestJob::initiator() const
\since 5.13
Returns any HTTP headers added to the request.
*/
-const QMap<QByteArray, QByteArray> &QWebEngineUrlRequestJob::requestHeaders() const
+QMap<QByteArray, QByteArray> QWebEngineUrlRequestJob::requestHeaders() const
{
return d_ptr->requestHeaders();
}
diff --git a/src/core/api/qwebengineurlrequestjob.h b/src/core/api/qwebengineurlrequestjob.h
index 55ec7c6d2..b2dd8baa3 100644
--- a/src/core/api/qwebengineurlrequestjob.h
+++ b/src/core/api/qwebengineurlrequestjob.h
@@ -73,7 +73,7 @@ public:
QUrl requestUrl() const;
QByteArray requestMethod() const;
QUrl initiator() const;
- const QMap<QByteArray, QByteArray> &requestHeaders() const;
+ QMap<QByteArray, QByteArray> requestHeaders() const;
void reply(const QByteArray &contentType, QIODevice *device);
void fail(Error error);
diff --git a/src/core/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp
index 2e93f4b73..aecee5044 100644
--- a/src/core/api/qwebengineurlschemehandler.cpp
+++ b/src/core/api/qwebengineurlschemehandler.cpp
@@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QWebEngineUrlSchemeHandler
- \brief The QWebEngineUrlSchemeHandler is a base class for handling custom URL schemes.
+ \brief The QWebEngineUrlSchemeHandler class is a base class for handling custom URL schemes.
\since 5.6
To implement a custom URL scheme for QtWebEngine, you first have to create an instance of