diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2023-03-17 09:47:55 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-03-24 09:14:55 +0000 |
commit | 1416afe5db193023292e09c3eafad1755ea88575 (patch) | |
tree | 2c9d746e645974b96e643733b915c57954127809 /src | |
parent | 9529f13652ce4c6297fb6b14610b1da01e891560 (diff) | |
download | qtwebengine-1416afe5db193023292e09c3eafad1755ea88575.tar.gz |
Remove webui example
Doesn't demonstrate anything complicated, the code isn't even worth
quoting as snippets. We could consider introducing a help browser to
replace it with more functionality.
Task-number: QTBUG-108751
Change-Id: I3b796388796a78d017836a10bee18032b2cd4905
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
(cherry picked from commit e4051de7db7b7f0905770280f9a06e133d453cf7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/api/qwebengineurlschemehandler.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/core/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp index e78a206d6..9e5b95ef4 100644 --- a/src/core/api/qwebengineurlschemehandler.cpp +++ b/src/core/api/qwebengineurlschemehandler.cpp @@ -30,10 +30,23 @@ QT_BEGIN_NAMESPACE { public: MySchemeHandler(QObject *parent = nullptr); - void requestStarted(QWebEngineUrlRequestJob *request) + void requestStarted(QWebEngineUrlRequestJob *job) { - // .... + const QByteArray method = job->requestMethod(); + const QUrl url = job->requestUrl(); + + if (isValidUrl(url)) { + if (method == QByteArrayLiteral("GET")) { + job->reply(QByteArrayLiteral("text/html"), makeReply(url)); + else // Unsupported method + job->fail(QWebEngineUrlRequestJob::RequestDenied); + } else { + // Invalid URL + job->fail(QWebEngineUrlRequestJob::UrlNotFound); + } } + bool isValidUrl(const QUrl &url) const // .... + QIODevice *makeReply(const QUrl &url) // .... }; int main(int argc, char **argv) @@ -56,7 +69,7 @@ QT_BEGIN_NAMESPACE \inmodule QtWebEngineCore - \sa {QWebEngineUrlScheme}, {WebEngine Widgets WebUI Example} + \sa {QWebEngineUrlScheme} */ /*! |