summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-05-06 14:40:23 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-05-06 15:21:18 +0000
commiteed2622ebc3298ec533d298fc7798a3690d2440c (patch)
tree1761f4a5b573f1d83cd9b18c7f59e49045e9844f
parent7a5f9b62cca4f65b2194c6b842be323ad4c312ff (diff)
Add documentation of Custom URL requests
Adds basic documentation to the API. Though the API is still private we would like people to experiment with it, which is easy if it is documented. Change-Id: I63985dfc16dc91270d95edf6fc306f9c71a10f29 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com> Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org>
-rw-r--r--src/webenginewidgets/api/qwebengineurlrequestjob.cpp30
-rw-r--r--src/webenginewidgets/api/qwebengineurlschemehandler.cpp37
2 files changed, 67 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp b/src/webenginewidgets/api/qwebengineurlrequestjob.cpp
index cb8b200a2..323cdcc72 100644
--- a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp
+++ b/src/webenginewidgets/api/qwebengineurlrequestjob.cpp
@@ -42,21 +42,51 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QWebEngineUrlRequestJob
+ \brief The QWebEngineUrlRequestJob class represents a custom URL request.
+ \since 5.5
+ \internal
+
+ A QWebEngineUrlRequestJob is given to QWebEngineUrlSchemeHandler::requestStarted() and must
+ be handled by the derived implementations of class.
+
+ A job can be handled by calling setReply().
+
+ 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 QtWebEngineWidgets
+*/
+
+/*!
+ \internal
+ */
QWebEngineUrlRequestJob::QWebEngineUrlRequestJob(QtWebEngineCore::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);
diff --git a/src/webenginewidgets/api/qwebengineurlschemehandler.cpp b/src/webenginewidgets/api/qwebengineurlschemehandler.cpp
index 16ad220b2..65dd8f000 100644
--- a/src/webenginewidgets/api/qwebengineurlschemehandler.cpp
+++ b/src/webenginewidgets/api/qwebengineurlschemehandler.cpp
@@ -43,6 +43,23 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QWebEngineUrlSchemeHandler
+ \brief The QWebEngineUrlSchemeHandler Base class for handling custom URL schemes.
+ \since 5.5
+ \internal
+
+ To implement a custom URL scheme for QtWebEngine you must write a class derived from this class,
+ and reimplement requestStarted().
+
+ To install a custom URL scheme handler into a QtWebProfile, you only need to call the constructor
+ with the correct profile. Each instance of a QWebEngineUrlSchemeHandler can only handle requests
+ from a single profile.
+
+ \inmodule QtWebEngineWidgets
+
+*/
+
QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme, QWebEngineUrlSchemeHandler *q, QWebEngineProfile *profile)
: CustomUrlSchemeHandler(scheme)
, q_ptr(q)
@@ -61,6 +78,12 @@ bool QWebEngineUrlSchemeHandlerPrivate::handleJob(QtWebEngineCore::URLRequestCus
return true;
}
+/*!
+ Constructs a new URL scheme handler.
+
+ The handler is created for \a scheme and for the \a profile.
+
+ */
QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(const QByteArray &scheme, QWebEngineProfile *profile, QObject *parent)
: QObject(parent)
, d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme, this, profile))
@@ -74,9 +97,23 @@ QWebEngineUrlSchemeHandler::~QWebEngineUrlSchemeHandler()
d_ptr->m_profile->d_func()->removeUrlSchemeHandler(this);
}
+/*!
+ 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 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