From c020160f75fc76b2a97d246ce6a4292288c04a59 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 11 Jun 2018 16:40:12 +0200 Subject: [PATCH] Add support for navigator.webkitPersistentStorage.requestQuota See #3010 --- doc/changelog.asciidoc | 3 +++ doc/help/settings.asciidoc | 19 +++++++++++++++++++ qutebrowser/browser/webengine/webenginetab.py | 16 ++++++++++++++++ qutebrowser/config/configdata.yml | 9 +++++++++ 4 files changed, 47 insertions(+) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 369ad76ff..92fa2d9e7 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -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 ``) to mute/unmute a tab. +- QtWebEngine: Support for `navigator.webkitPersistentStorage.requestQuota` + * New `content.persistent_storage` setting to allow/deny requests (default: + ask). Changed ~~~~~~~ diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 67f599fe4..b3f0e995f 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -144,6 +144,7 @@ |<>|Netrc-file for HTTP authentication. |<>|Allow websites to show notifications. |<>|Allow pdf.js to view PDF files in the browser. +|<>|Allow websites to request persistent storage quota via `navigator.webkitPersistentStorage.requestQuota`. |<>|Enable plugins in Web pages. |<>|Draw the background color and images also when the page is printed. |<>|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: <> + +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. diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 4b6ba7f91..9b2c85240 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -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) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 5c084bc5c..d858f6079 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -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