Add support for navigator.webkitPersistentStorage.requestQuota

See #3010
This commit is contained in:
Florian Bruhin 2018-06-11 16:40:12 +02:00
parent 4ea957b68b
commit c020160f75
4 changed files with 47 additions and 0 deletions

View File

@ -34,6 +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).
Changed
~~~~~~~

View File

@ -144,6 +144,7 @@
|<<content.netrc_file,content.netrc_file>>|Netrc-file for HTTP authentication.
|<<content.notifications,content.notifications>>|Allow websites to show notifications.
|<<content.pdfjs,content.pdfjs>>|Allow pdf.js to view PDF files in the browser.
|<<content.persistent_storage,content.persistent_storage>>|Allow websites to request persistent storage quota via `navigator.webkitPersistentStorage.requestQuota`.
|<<content.plugins,content.plugins>>|Enable plugins in Web pages.
|<<content.print_element_backgrounds,content.print_element_backgrounds>>|Draw the background color and images also when the page is printed.
|<<content.private_browsing,content.private_browsing>>|Open new windows in private browsing mode which does not record visited pages.
@ -1857,6 +1858,24 @@ Default: +pass:[false]+
This setting is only available with the QtWebKit backend.
[[content.persistent_storage]]
=== content.persistent_storage
Allow websites to request persistent storage quota via `navigator.webkitPersistentStorage.requestQuota`.
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.plugins]]
=== content.plugins
Enable plugins in Web pages.

View File

@ -1046,6 +1046,17 @@ class WebEngineTab(browsertab.AbstractTab):
# aborted after a loadStarted signal.
pass
@pyqtSlot('QWebEngineQuotaRequest')
def _on_quota_requested(self, request):
size = utils.format_size(request.requestedSize())
shared.feature_permission(
url=request.origin(),
option='content.persistent_storage',
msg='use {} of persistent storage'.format(size),
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."""
@ -1204,6 +1215,11 @@ class WebEngineTab(browsertab.AbstractTab):
page.navigation_request.connect(self._on_navigation_request)
page.featurePermissionRequested.connect(
self._on_feature_permission_requested)
try:
page.quotaRequested.connect(self._on_quota_requested)
except AttributeError:
# Added in Qt 5.11
pass
view.titleChanged.connect(self.title_changed)
view.urlChanged.connect(self._on_url_changed)

View File

@ -598,6 +598,15 @@ content.pdfjs:
Note that the files can still be downloaded by clicking the download button
in the pdf.js viewer.
content.persistent_storage:
default: ask
type: BoolAsk
backend:
QtWebKit: false
QtWebEngine: Qt 5.11
desc: Allow websites to request persistent storage quota via
`navigator.webkitPersistentStorage.requestQuota`.
content.plugins:
default: false
type: Bool