summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2018-06-07 16:37:02 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-02 20:52:46 +0000
commit5d79af42e1e442ef67b3f1c87ae75d60a22ef9fc (patch)
treeddafad6255d4766b669c200b1ab3d60d11623efe /src/webengine
parent36cb71a4808456b6851c3fc7ddb2aa57bf286117 (diff)
Add QWebEngineUrlScheme class
Public API for the new url/url_util_qt extension to Chromium, which allows to integrate custom schemes into Chromium's url parsing library and security model. Previously custom schemes would be treated as 'unknown' schemes and rely on fallback behavior in Chromium. [ChangeLog][Custom Schemes] Added the QWebEngineUrlScheme class for configuring how custom schemes are parsed and which security restrictions should apply. Task-number: QTBUG-62536 Change-Id: I7d8b9da3ad742f568b82ccc6a2456ad35e84069b Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp12
-rw-r--r--src/webengine/doc/src/qtwebengine-features.qdoc13
2 files changed, 21 insertions, 4 deletions
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index d11214716..48e5175ca 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -836,22 +836,26 @@ static bool checkInternalScheme(const QByteArray &scheme)
/*!
Registers a handler \a handler for custom URL scheme \a scheme in the profile.
+
+ It is recommended to first register the scheme with \l
+ QWebEngineUrlScheme::addScheme at application startup.
*/
void QQuickWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler)
{
Q_D(QQuickWebEngineProfile);
Q_ASSERT(handler);
- if (checkInternalScheme(scheme)) {
+ QByteArray canonicalScheme = scheme.toLower();
+ if (checkInternalScheme(canonicalScheme)) {
qWarning("Cannot install a URL scheme handler overriding internal scheme: %s", scheme.constData());
return;
}
- if (d->profileAdapter()->customUrlSchemeHandlers().contains(scheme)) {
- if (d->profileAdapter()->customUrlSchemeHandlers().value(scheme) != handler)
+ if (d->profileAdapter()->customUrlSchemeHandlers().contains(canonicalScheme)) {
+ if (d->profileAdapter()->customUrlSchemeHandlers().value(canonicalScheme) != handler)
qWarning("URL scheme handler already installed for the scheme: %s", scheme.constData());
return;
}
- d->profileAdapter()->addCustomUrlSchemeHandler(scheme, handler);
+ d->profileAdapter()->addCustomUrlSchemeHandler(canonicalScheme, handler);
connect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)));
}
diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc
index d900e551b..41d0581e5 100644
--- a/src/webengine/doc/src/qtwebengine-features.qdoc
+++ b/src/webengine/doc/src/qtwebengine-features.qdoc
@@ -111,6 +111,19 @@
For more information, see \l {Qt WebEngine Debugging and Profiling}.
+ \section1 Custom Schemes
+
+ Qt WebEngine makes it possible for the application to define its own custom
+ URL schemes with specialized security policies and transport mechanisms.
+
+ Custom schemes can be used to implement alternative network protocols with
+ all the usual web security policies, privileged internal schemes for
+ displaying user interface compoments or debugging information, sandboxed
+ schemes with extra restrictions, and so on.
+
+ For more information, see \l QWebEngineUrlScheme and \l
+ QWebEngineUrlSchemeHandler.
+
\section1 Drag and Drop
Qt WebEngine supports HTML5 drag and drop.