diff options
Diffstat (limited to 'src/core/api')
-rw-r--r-- | src/core/api/qwebengineurlrequestinfo.cpp | 14 | ||||
-rw-r--r-- | src/core/api/qwebengineurlrequestinfo.h | 1 | ||||
-rw-r--r-- | src/core/api/qwebengineurlrequestinfo_p.h | 2 | ||||
-rw-r--r-- | src/core/api/qwebengineurlrequestjob.cpp | 38 | ||||
-rw-r--r-- | src/core/api/qwebengineurlrequestjob.h | 14 | ||||
-rw-r--r-- | src/core/api/qwebengineurlschemehandler.cpp | 28 | ||||
-rw-r--r-- | src/core/api/qwebengineurlschemehandler.h | 9 | ||||
-rw-r--r-- | src/core/api/qwebengineurlschemehandler_p.h | 19 |
8 files changed, 72 insertions, 53 deletions
diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp index b769081f8..e8ce65be3 100644 --- a/src/core/api/qwebengineurlrequestinfo.cpp +++ b/src/core/api/qwebengineurlrequestinfo.cpp @@ -119,11 +119,12 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::OtherNavigation, Q */ -QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource, QWebEngineUrlRequestInfo::NavigationType navigation, const QUrl &u, const QByteArray &m) +QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource, QWebEngineUrlRequestInfo::NavigationType navigation, const QUrl &u, const QUrl &fpu, const QByteArray &m) : resourceType(resource) , navigationType(navigation) , shouldBlockRequest(false) , url(u) + , firstPartyUrl(fpu) , method(m) { } @@ -218,6 +219,17 @@ QUrl QWebEngineUrlRequestInfo::requestUrl() const return d->url; } +/*! + Returns the first party URL of the request. + The first party URL is the URL of the page that issued the request. +*/ + +QUrl QWebEngineUrlRequestInfo::firstPartyUrl() const +{ + Q_D(const QWebEngineUrlRequestInfo); + return d->firstPartyUrl; +} + /*! Returns the HTTP method of the request (for example, GET or POST). diff --git a/src/core/api/qwebengineurlrequestinfo.h b/src/core/api/qwebengineurlrequestinfo.h index 7c016d20d..e6e225051 100644 --- a/src/core/api/qwebengineurlrequestinfo.h +++ b/src/core/api/qwebengineurlrequestinfo.h @@ -86,6 +86,7 @@ public: NavigationType navigationType() const; QUrl requestUrl() const; + QUrl firstPartyUrl() const; QByteArray requestMethod() const; void block(bool shouldBlock); diff --git a/src/core/api/qwebengineurlrequestinfo_p.h b/src/core/api/qwebengineurlrequestinfo_p.h index b6a304a03..1b1279d27 100644 --- a/src/core/api/qwebengineurlrequestinfo_p.h +++ b/src/core/api/qwebengineurlrequestinfo_p.h @@ -58,6 +58,7 @@ public: QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource , QWebEngineUrlRequestInfo::NavigationType navigation , const QUrl &u + , const QUrl &fpu , const QByteArray &m); QWebEngineUrlRequestInfo::ResourceType resourceType; @@ -65,6 +66,7 @@ public: bool shouldBlockRequest; QUrl url; + QUrl firstPartyUrl; const QByteArray method; QHash<QByteArray, QByteArray> extraHeaders; diff --git a/src/core/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp index d9f3833b9..0e56ba5b3 100644 --- a/src/core/api/qwebengineurlrequestjob.cpp +++ b/src/core/api/qwebengineurlrequestjob.cpp @@ -48,18 +48,36 @@ QT_BEGIN_NAMESPACE \since 5.6 A QWebEngineUrlRequestJob is given to QWebEngineUrlSchemeHandler::requestStarted() and must - be handled by the derived implementations of the class. + be handled by the derived implementations of the class. The job can be handled by calling + either reply(), redirect(), or fail(). - A job can be handled by calling either reply(), redirect() or fail(). - - 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. + The class is owned by the web engine and does not need to be deleted. However, the web engine + may delete the job when it is no longer needed, and therefore the signal QObject::destroyed() + must be monitored if a pointer to the object is stored. \inmodule QtWebEngineCore */ /*! + \enum QWebEngineUrlRequestJob::Error + + This enum type holds the type of the error that occurred: + + \value NoError + The request was successful. + \value UrlNotFound + The requested URL was not found. + \value UrlInvalid + The requested URL is invalid. + \value RequestAborted + The request was canceled. + \value RequestDenied + The request was denied. + \value RequestFailed + The request failed. +*/ + +/*! \internal */ QWebEngineUrlRequestJob::QWebEngineUrlRequestJob(URLRequestCustomJobDelegate * p) @@ -92,7 +110,7 @@ QByteArray QWebEngineUrlRequestJob::requestMethod() const } /*! - Replies the request with \a device with the mime-type \a contentType. + Replies to the request with \a device and the MIME type \a contentType. */ void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *device) { @@ -100,7 +118,9 @@ void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *de } /*! - Fails the request with error \a error. + Fails the request with the error \a r. + + \sa Error */ void QWebEngineUrlRequestJob::fail(Error r) { @@ -108,7 +128,7 @@ void QWebEngineUrlRequestJob::fail(Error r) } /*! - Tell the request is redirected to \a url. + Redirects the request to \a url. */ void QWebEngineUrlRequestJob::redirect(const QUrl &url) { diff --git a/src/core/api/qwebengineurlrequestjob.h b/src/core/api/qwebengineurlrequestjob.h index 098d46c93..fc9f4d911 100644 --- a/src/core/api/qwebengineurlrequestjob.h +++ b/src/core/api/qwebengineurlrequestjob.h @@ -37,17 +37,6 @@ #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> @@ -55,6 +44,7 @@ #include <QtCore/qurl.h> namespace QtWebEngineCore { +class URLRequestCustomJob; class URLRequestCustomJobDelegate; } // namespace @@ -86,7 +76,7 @@ public: private: QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate *); - friend class QWebEngineUrlSchemeHandlerPrivate; + friend class QtWebEngineCore::URLRequestCustomJob; QtWebEngineCore::URLRequestCustomJobDelegate* d_ptr; }; diff --git a/src/core/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp index 330648893..e6c20dbca 100644 --- a/src/core/api/qwebengineurlschemehandler.cpp +++ b/src/core/api/qwebengineurlschemehandler.cpp @@ -43,31 +43,25 @@ QT_BEGIN_NAMESPACE /*! \class QWebEngineUrlSchemeHandler - \brief The QWebEngineUrlSchemeHandler base class for handling custom URL schemes. + \brief The QWebEngineUrlSchemeHandler is a 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, + 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) -{ -} +/*! + \fn QWebEngineUrlSchemeHandler::destroyed(QWebEngineUrlSchemeHandler *handler) -QWebEngineUrlSchemeHandlerPrivate::~QWebEngineUrlSchemeHandlerPrivate() -{ -} + This signal is emitted when the custom URL scheme handler \a handler is deleted. +*/ -bool QWebEngineUrlSchemeHandlerPrivate::handleJob(QtWebEngineCore::URLRequestCustomJobDelegate *job) +QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme) + : m_scheme(scheme) { - QWebEngineUrlRequestJob *requestJob = new QWebEngineUrlRequestJob(job); - q_ptr->requestStarted(requestJob); - return true; } /*! @@ -78,12 +72,16 @@ bool QWebEngineUrlSchemeHandlerPrivate::handleJob(QtWebEngineCore::URLRequestCus */ QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme, this)) + , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme)) { } +/*! + Deletes a custom URL scheme handler. +*/ QWebEngineUrlSchemeHandler::~QWebEngineUrlSchemeHandler() { + Q_EMIT destroyed(this); delete d_ptr; } diff --git a/src/core/api/qwebengineurlschemehandler.h b/src/core/api/qwebengineurlschemehandler.h index b6f6a69f0..1b6a66706 100644 --- a/src/core/api/qwebengineurlschemehandler.h +++ b/src/core/api/qwebengineurlschemehandler.h @@ -42,6 +42,10 @@ #include <QtCore/qbytearray.h> #include <QtCore/qobject.h> +namespace QtWebEngineCore { +class URLRequestContextGetterQt; +} + QT_BEGIN_NAMESPACE class QWebEngineUrlRequestJob; @@ -57,11 +61,12 @@ public: virtual void requestStarted(QWebEngineUrlRequestJob*) = 0; +Q_SIGNALS: + void destroyed(QWebEngineUrlSchemeHandler*); + private: Q_DISABLE_COPY(QWebEngineUrlSchemeHandler) Q_DECLARE_PRIVATE(QWebEngineUrlSchemeHandler) - friend class QWebEngineProfile; - friend class QQuickWebEngineProfile; QWebEngineUrlSchemeHandlerPrivate *d_ptr; }; diff --git a/src/core/api/qwebengineurlschemehandler_p.h b/src/core/api/qwebengineurlschemehandler_p.h index dc4b272b3..d63666326 100644 --- a/src/core/api/qwebengineurlschemehandler_p.h +++ b/src/core/api/qwebengineurlschemehandler_p.h @@ -48,27 +48,18 @@ // We mean it. // -#include "qwebengineurlschemehandler.h" - -#include "custom_url_scheme_handler.h" +#include <QtCore/qbytearray.h> QT_BEGIN_NAMESPACE -class QWebEngineProfile; -class QWebEngineUrlRequestJob; -class QWebEngineUrlSchemeHandler; - -class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandlerPrivate : public QtWebEngineCore::CustomUrlSchemeHandler { +class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandlerPrivate { public: - Q_DECLARE_PUBLIC(QWebEngineUrlSchemeHandler) - - QWebEngineUrlSchemeHandlerPrivate(const QByteArray &, QWebEngineUrlSchemeHandler *); - virtual ~QWebEngineUrlSchemeHandlerPrivate(); + QWebEngineUrlSchemeHandlerPrivate(const QByteArray &); - virtual bool handleJob(QtWebEngineCore::URLRequestCustomJobDelegate*) Q_DECL_OVERRIDE; + const QByteArray &scheme() const { return m_scheme; } private: - QWebEngineUrlSchemeHandler *q_ptr; + QByteArray m_scheme; }; QT_END_NAMESPACE |