Add support for navigator.registerProtocolHandler

See #3010
This commit is contained in:
Florian Bruhin 2018-06-11 16:51:18 +02:00
parent c020160f75
commit 4186577928
4 changed files with 43 additions and 3 deletions

View File

@ -34,9 +34,9 @@ Added
* New `{audio}` field for `window.title_format` and `tabs.title.format` which
displays `[M]`/`[A]` for muted/recently audible tabs.
* New `:tab-mute` command (bound to `<Alt-m>`) to mute/unmute a tab.
- QtWebEngine: Support for `navigator.webkitPersistentStorage.requestQuota`
* New `content.persistent_storage` setting to allow/deny requests (default:
ask).
- QtWebEngine: Support for new permissions, including new settings (true/false/ask):
* `navigator.webkitPersistentStorage.requestQuota` with a new `content.persistent_storage` setting.
* `navigator.registerProtocolHandler` with a new `content.register_protocol_handler` setting.
Changed
~~~~~~~

View File

@ -150,6 +150,7 @@
|<<content.private_browsing,content.private_browsing>>|Open new windows in private browsing mode which does not record visited pages.
|<<content.proxy,content.proxy>>|Proxy to use.
|<<content.proxy_dns_requests,content.proxy_dns_requests>>|Send DNS requests over the configured proxy.
|<<content.register_protocol_handler,content.register_protocol_handler>>|Allow websites to register protocol handlers via `navigator.registerProtocolHandler`.
|<<content.ssl_strict,content.ssl_strict>>|Validate SSL handshakes.
|<<content.user_stylesheets,content.user_stylesheets>>|List of user stylesheet filenames to use.
|<<content.webgl,content.webgl>>|Enable WebGL.
@ -1930,6 +1931,24 @@ Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[content.register_protocol_handler]]
=== content.register_protocol_handler
Allow websites to register protocol handlers via `navigator.registerProtocolHandler`.
Type: <<types,BoolAsk>>
Valid values:
* +true+
* +false+
* +ask+
Default: +pass:[ask]+
On QtWebEngine, this setting requires Qt 5.11 or newer.
On QtWebKit, this setting is unavailable.
[[content.ssl_strict]]
=== content.ssl_strict
Validate SSL handshakes.

View File

@ -1057,6 +1057,16 @@ class WebEngineTab(browsertab.AbstractTab):
abort_on=[self.shutting_down, self.load_started],
blocking=True)
@pyqtSlot('QWebEngineRegisterProtocolHandlerRequest')
def _on_register_protocol_handler_requested(self, request):
shared.feature_permission(
url=request.origin(),
option='content.register_protocol_handler',
msg='open all {} links'.format(request.scheme()),
yes_action=request.accept, no_action=request.reject,
abort_on=[self.shutting_down, self.load_started],
blocking=True)
@pyqtSlot()
def _on_load_started(self):
"""Clear search when a new load is started if needed."""
@ -1217,6 +1227,8 @@ class WebEngineTab(browsertab.AbstractTab):
self._on_feature_permission_requested)
try:
page.quotaRequested.connect(self._on_quota_requested)
page.registerProtocolHandlerRequested.connect(
self._on_register_protocol_handler_requested)
except AttributeError:
# Added in Qt 5.11
pass

View File

@ -644,6 +644,15 @@ content.proxy_dns_requests:
backend: QtWebKit
desc: Send DNS requests over the configured proxy.
content.register_protocol_handler:
default: ask
type: BoolAsk
backend:
QtWebKit: false
QtWebEngine: Qt 5.11
desc: Allow websites to register protocol handlers via
`navigator.registerProtocolHandler`.
content.ssl_strict:
default: ask
type: BoolAsk