summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/core_api.pro9
-rw-r--r--src/core/api/qwebengineurlrequestjob.cpp110
-rw-r--r--src/core/api/qwebengineurlrequestjob.h94
-rw-r--r--src/core/api/qwebengineurlschemehandler.cpp109
-rw-r--r--src/core/api/qwebengineurlschemehandler.h70
-rw-r--r--src/core/api/qwebengineurlschemehandler_p.h76
-rw-r--r--src/core/browser_context_adapter.cpp6
-rw-r--r--src/core/browser_context_adapter.h1
-rw-r--r--src/core/custom_url_scheme_handler.cpp4
-rw-r--r--src/core/custom_url_scheme_handler.h2
10 files changed, 474 insertions, 7 deletions
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index d72b27229..1f82c7e21 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -37,8 +37,13 @@ HEADERS = \
qwebenginecookiestoreclient_p.h \
qwebengineurlrequestinterceptor.h \
qwebengineurlrequestinfo.h \
- qwebengineurlrequestinfo_p.h
+ qwebengineurlrequestinfo_p.h \
+ qwebengineurlrequestjob.h \
+ qwebengineurlschemehandler.h \
+ qwebengineurlschemehandler_p.h
SOURCES = \
qwebenginecookiestoreclient.cpp \
- qwebengineurlrequestinfo.cpp
+ qwebengineurlrequestinfo.cpp \
+ qwebengineurlrequestjob.cpp \
+ qwebengineurlschemehandler.cpp
diff --git a/src/core/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp
new file mode 100644
index 000000000..f2a7f1619
--- /dev/null
+++ b/src/core/api/qwebengineurlrequestjob.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.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 "qwebengineurlrequestjob.h"
+
+#include "url_request_custom_job_delegate.h"
+
+using QtWebEngineCore::URLRequestCustomJobDelegate;
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWebEngineUrlRequestJob
+ \brief The QWebEngineUrlRequestJob class represents a custom URL request.
+ \since 5.6
+
+ A QWebEngineUrlRequestJob is given to QWebEngineUrlSchemeHandler::requestStarted() and must
+ be handled by the derived implementations of the class.
+
+ A job can be handled by calling either setReply(), redirect() or setError().
+
+ The class is owned by QtWebEngine and does not need to be deleted. Note QtWebEngine may delete
+ the job when it is no longer needed, so the signal QObject::destroyed() must be monitored if
+ a pointer to the object is stored.
+
+ \inmodule QtWebEngineCore
+*/
+
+/*!
+ \internal
+ */
+QWebEngineUrlRequestJob::QWebEngineUrlRequestJob(URLRequestCustomJobDelegate * p)
+ : QObject(p) // owned by the jobdelegate and deleted when the job is done
+ , d_ptr(p)
+{
+}
+
+/*!
+ \internal
+ */
+QWebEngineUrlRequestJob::~QWebEngineUrlRequestJob()
+{
+}
+
+/*!
+ Returns the url requested.
+ */
+QUrl QWebEngineUrlRequestJob::requestUrl() const
+{
+ return d_ptr->url();
+}
+
+/*!
+ Sets the reply for the request to \a device with the mime-type \a contentType.
+ */
+void QWebEngineUrlRequestJob::setReply(const QByteArray &contentType, QIODevice *device)
+{
+ d_ptr->setReply(contentType, device);
+}
+
+/*!
+ Fails the request with error \a error.
+ */
+void QWebEngineUrlRequestJob::setError(Error r)
+{
+ d_ptr->fail((URLRequestCustomJobDelegate::Error)r);
+}
+
+/*!
+ Tell the request is redirected to \a url.
+ */
+void QWebEngineUrlRequestJob::setRedirect(const QUrl &url)
+{
+ d_ptr->redirect(url);
+}
+
+QT_END_NAMESPACE
diff --git a/src/core/api/qwebengineurlrequestjob.h b/src/core/api/qwebengineurlrequestjob.h
new file mode 100644
index 000000000..1be3808fa
--- /dev/null
+++ b/src/core/api/qwebengineurlrequestjob.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.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 QWEBENGINEURLREQUESTJOB_H
+#define QWEBENGINEURLREQUESTJOB_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.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+
+namespace QtWebEngineCore {
+class URLRequestCustomJobDelegate;
+} // namespace
+
+QT_BEGIN_NAMESPACE
+
+class QIODevice;
+
+class QWEBENGINE_EXPORT QWebEngineUrlRequestJob : public QObject {
+ Q_OBJECT
+public:
+ ~QWebEngineUrlRequestJob();
+
+ enum Error {
+ NoError = 0,
+ UrlNotFound,
+ UrlInvalid,
+ RequestAborted,
+ RequestDenied,
+ RequestFailed
+ };
+ Q_ENUM(Error)
+
+ QUrl requestUrl() const;
+ void setReply(const QByteArray &contentType, QIODevice *device);
+ void setError(Error error);
+ void setRedirect(const QUrl &url);
+
+private:
+ QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate *);
+ friend class QWebEngineUrlSchemeHandlerPrivate;
+
+ QtWebEngineCore::URLRequestCustomJobDelegate* d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINEURLREQUESTJOB_H
diff --git a/src/core/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp
new file mode 100644
index 000000000..330648893
--- /dev/null
+++ b/src/core/api/qwebengineurlschemehandler.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.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 "qwebengineurlschemehandler.h"
+#include "qwebengineurlschemehandler_p.h"
+
+#include "qwebengineurlrequestjob.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWebEngineUrlSchemeHandler
+ \brief The QWebEngineUrlSchemeHandler base class for handling custom URL schemes.
+ \since 5.6
+
+ To implement a custom URL scheme for QtWebEngine you must write a class derived from this class,
+ and reimplement requestStarted().
+
+ \inmodule QtWebEngineCore
+
+*/
+
+QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme, QWebEngineUrlSchemeHandler *q)
+ : CustomUrlSchemeHandler(scheme)
+ , q_ptr(q)
+{
+}
+
+QWebEngineUrlSchemeHandlerPrivate::~QWebEngineUrlSchemeHandlerPrivate()
+{
+}
+
+bool QWebEngineUrlSchemeHandlerPrivate::handleJob(QtWebEngineCore::URLRequestCustomJobDelegate *job)
+{
+ QWebEngineUrlRequestJob *requestJob = new QWebEngineUrlRequestJob(job);
+ q_ptr->requestStarted(requestJob);
+ return true;
+}
+
+/*!
+ Constructs a new URL scheme handler.
+
+ The handler is created for \a scheme with the parent \a parent.
+
+ */
+QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent)
+ : QObject(parent)
+ , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme, this))
+{
+}
+
+QWebEngineUrlSchemeHandler::~QWebEngineUrlSchemeHandler()
+{
+ delete d_ptr;
+}
+
+/*!
+ Returns the custom URL scheme handled.
+*/
+QByteArray QWebEngineUrlSchemeHandler::scheme() const
+{
+ return d_ptr->scheme();
+}
+
+/*!
+ \fn void QWebEngineUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request)
+
+ This method is called whenever a request \a request for the registered scheme is started.
+
+ This method must be reimplemented by all custom URL scheme handlers.
+ The request is asynchronous and does not need to be handled right away.
+
+ \sa QWebEngineUrlRequestJob
+*/
+
+QT_END_NAMESPACE
diff --git a/src/core/api/qwebengineurlschemehandler.h b/src/core/api/qwebengineurlschemehandler.h
new file mode 100644
index 000000000..b6f6a69f0
--- /dev/null
+++ b/src/core/api/qwebengineurlschemehandler.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.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 QWEBENGINEURLSCHEMEHANDLER_H
+#define QWEBENGINEURLSCHEMEHANDLER_H
+
+#include "qtwebenginecoreglobal.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineUrlRequestJob;
+class QWebEngineUrlSchemeHandlerPrivate;
+
+class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandler : public QObject {
+ Q_OBJECT
+public:
+ QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent = 0);
+ ~QWebEngineUrlSchemeHandler();
+
+ QByteArray scheme() const;
+
+ virtual void requestStarted(QWebEngineUrlRequestJob*) = 0;
+
+private:
+ Q_DISABLE_COPY(QWebEngineUrlSchemeHandler)
+ Q_DECLARE_PRIVATE(QWebEngineUrlSchemeHandler)
+ friend class QWebEngineProfile;
+ friend class QQuickWebEngineProfile;
+ QWebEngineUrlSchemeHandlerPrivate *d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINEURLSCHEMEHANDLER_H
diff --git a/src/core/api/qwebengineurlschemehandler_p.h b/src/core/api/qwebengineurlschemehandler_p.h
new file mode 100644
index 000000000..dc4b272b3
--- /dev/null
+++ b/src/core/api/qwebengineurlschemehandler_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.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 QWEBENGINEURLSCHEMEHANDLER_P_H
+#define QWEBENGINEURLSCHEMEHANDLER_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 "qwebengineurlschemehandler.h"
+
+#include "custom_url_scheme_handler.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineProfile;
+class QWebEngineUrlRequestJob;
+class QWebEngineUrlSchemeHandler;
+
+class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandlerPrivate : public QtWebEngineCore::CustomUrlSchemeHandler {
+public:
+ Q_DECLARE_PUBLIC(QWebEngineUrlSchemeHandler)
+
+ QWebEngineUrlSchemeHandlerPrivate(const QByteArray &, QWebEngineUrlSchemeHandler *);
+ virtual ~QWebEngineUrlSchemeHandlerPrivate();
+
+ virtual bool handleJob(QtWebEngineCore::URLRequestCustomJobDelegate*) Q_DECL_OVERRIDE;
+
+private:
+ QWebEngineUrlSchemeHandler *q_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINEURLSCHEMEHANDLER_P_H
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index 75a906b35..48d05ae1d 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -358,6 +358,12 @@ void BrowserContextAdapter::updateCustomUrlSchemeHandlers()
m_browserContext->url_request_getter_->updateStorageSettings();
}
+void BrowserContextAdapter::removeCustomUrlSchemeHandler(CustomUrlSchemeHandler *handler)
+{
+ m_customUrlSchemeHandlers.removeOne(handler);
+ Q_ASSERT(!m_customUrlSchemeHandlers.contains(handler));
+}
+
UserScriptControllerHost *BrowserContextAdapter::userScriptController()
{
if (!m_userScriptController)
diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h
index 896743f4b..0bca1bf8b 100644
--- a/src/core/browser_context_adapter.h
+++ b/src/core/browser_context_adapter.h
@@ -147,6 +147,7 @@ public:
QVector<CustomUrlSchemeHandler*> &customUrlSchemeHandlers();
void updateCustomUrlSchemeHandlers();
+ void removeCustomUrlSchemeHandler(CustomUrlSchemeHandler*);
UserScriptControllerHost *userScriptController();
void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply);
diff --git a/src/core/custom_url_scheme_handler.cpp b/src/core/custom_url_scheme_handler.cpp
index b9fcf9c36..29791b555 100644
--- a/src/core/custom_url_scheme_handler.cpp
+++ b/src/core/custom_url_scheme_handler.cpp
@@ -44,10 +44,6 @@ CustomUrlSchemeHandler::CustomUrlSchemeHandler(const QByteArray &scheme)
{
}
-CustomUrlSchemeHandler::~CustomUrlSchemeHandler()
-{
-}
-
QByteArray CustomUrlSchemeHandler::scheme() const
{
return m_scheme;
diff --git a/src/core/custom_url_scheme_handler.h b/src/core/custom_url_scheme_handler.h
index 745f0eb4c..d866628de 100644
--- a/src/core/custom_url_scheme_handler.h
+++ b/src/core/custom_url_scheme_handler.h
@@ -53,7 +53,7 @@ class URLRequestCustomJobDelegate;
class QWEBENGINE_EXPORT CustomUrlSchemeHandler {
public:
explicit CustomUrlSchemeHandler(const QByteArray &);
- ~CustomUrlSchemeHandler();
+ virtual ~CustomUrlSchemeHandler() { }
QByteArray scheme() const;
void setScheme(const QByteArray &);