parent
093f07f552
commit
3b0c8e46a3
@ -34,6 +34,8 @@ 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 `content.cookies.accept` with third-party cookies
|
||||
blocked by default (requires Qt 5.11).
|
||||
- QtWebEngine: New settings:
|
||||
* Support for requesting persistent storage via
|
||||
`navigator.webkitPersistentStorage.requestQuota` with a new
|
||||
|
@ -1540,12 +1540,12 @@ Valid values:
|
||||
|
||||
* +all+: Accept all cookies.
|
||||
* +no-3rdparty+: Accept cookies from the same origin only.
|
||||
* +no-unknown-3rdparty+: Accept cookies from the same origin only, unless a cookie is already set for the domain.
|
||||
* +no-unknown-3rdparty+: Accept cookies from the same origin only, unless a cookie is already set for the domain. On QtWebEngine, this is the same as no-3rdparty.
|
||||
* +never+: Don't accept cookies at all.
|
||||
|
||||
Default: +pass:[no-3rdparty]+
|
||||
|
||||
This setting is only available with the QtWebKit backend.
|
||||
On QtWebEngine, this setting requires Qt 5.11 or newer.
|
||||
|
||||
[[content.cookies.store]]
|
||||
=== content.cookies.store
|
||||
|
48
qutebrowser/browser/webengine/cookies.py
Normal file
48
qutebrowser/browser/webengine/cookies.py
Normal file
@ -0,0 +1,48 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Filter for QtWebEngine cookies."""
|
||||
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.utils import utils
|
||||
|
||||
|
||||
def _accept_cookie(request):
|
||||
"""Check whether the given cookie should be accepted."""
|
||||
accept = config.val.content.cookies.accept
|
||||
if accept == 'all':
|
||||
return True
|
||||
elif accept in ['no-3rdparty', 'no-unknown-3rdparty']:
|
||||
return not request.thirdParty
|
||||
elif accept == 'never':
|
||||
return False
|
||||
else:
|
||||
raise utils.Unreachable
|
||||
|
||||
|
||||
def install_filter(profile):
|
||||
"""Install the cookie filter on the given profile.
|
||||
|
||||
On Qt < 5.11, the filter isn't installed.
|
||||
"""
|
||||
store = profile.cookieStore()
|
||||
try:
|
||||
store.setCookieFilter(_accept_cookie)
|
||||
except AttributeError:
|
||||
pass
|
@ -37,7 +37,7 @@ from qutebrowser.config import configdata, config
|
||||
from qutebrowser.browser import browsertab, mouse, shared
|
||||
from qutebrowser.browser.webengine import (webview, webengineelem, tabhistory,
|
||||
interceptor, webenginequtescheme,
|
||||
webenginedownloads,
|
||||
cookies, webenginedownloads,
|
||||
webenginesettings)
|
||||
from qutebrowser.misc import miscwidgets
|
||||
from qutebrowser.utils import (usertypes, qtutils, log, javascript, utils,
|
||||
@ -74,6 +74,10 @@ def init():
|
||||
download_manager.install(webenginesettings.private_profile)
|
||||
objreg.register('webengine-download-manager', download_manager)
|
||||
|
||||
log.init.debug("Initializing cookie filter...")
|
||||
cookies.install_filter(webenginesettings.default_profile)
|
||||
cookies.install_filter(webenginesettings.private_profile)
|
||||
|
||||
# Clear visited links on web history clear
|
||||
hist = objreg.get('web-history')
|
||||
for p in [webenginesettings.default_profile,
|
||||
|
@ -281,14 +281,17 @@ content.cache.appcache:
|
||||
|
||||
content.cookies.accept:
|
||||
default: no-3rdparty
|
||||
backend: QtWebKit
|
||||
backend:
|
||||
QtWebKit: true
|
||||
QtWebEngine: Qt 5.11
|
||||
type:
|
||||
name: String
|
||||
valid_values:
|
||||
- all: "Accept all cookies."
|
||||
- no-3rdparty: "Accept cookies from the same origin only."
|
||||
- no-unknown-3rdparty: "Accept cookies from the same origin only, unless
|
||||
a cookie is already set for the domain."
|
||||
a cookie is already set for the domain. On QtWebEngine, this is the
|
||||
same as no-3rdparty."
|
||||
- never: "Don't accept cookies at all."
|
||||
desc: Which cookies to accept.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user