diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index e732e9347..aead63169 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -25,6 +25,7 @@ Added - link:https://github.com/annulen/webkit/wiki[QtWebKit Reloaded] (also called QtWebKit-NG) is now supported. - Printing support for QtWebEngine with Qt >= 5.8 - Proxy support for QtWebEngine with Qt >= 5.8 +- Support for the `content -> cookies-store` option with QtWebEngine Changed ~~~~~~~ diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 122203d93..0e815b0e0 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -172,7 +172,7 @@ |<>|Whether locally loaded documents are allowed to access remote urls. |<>|Whether locally loaded documents are allowed to access other local urls. |<>|Control which cookies to accept. -|<>|Whether to store cookies. +|<>|Whether to store cookies. Note this option needs a restart with QtWebEngine. |<>|List of URLs of lists which contain hosts to block. |<>|Whether host blocking is enabled. |<>|List of domains that should always be loaded, despite being ad-blocked. @@ -1594,7 +1594,7 @@ This setting is only available with the QtWebKit backend. [[content-cookies-store]] === cookies-store -Whether to store cookies. +Whether to store cookies. Note this option needs a restart with QtWebEngine. Valid values: @@ -1603,8 +1603,6 @@ Valid values: Default: +pass:[true]+ -This setting is only available with the QtWebKit backend. - [[content-host-block-lists]] === host-block-lists List of URLs of lists which contain hosts to block. diff --git a/qutebrowser/browser/webengine/webenginesettings.py b/qutebrowser/browser/webengine/webenginesettings.py index 196d9c8d9..d428fb371 100644 --- a/qutebrowser/browser/webengine/webenginesettings.py +++ b/qutebrowser/browser/webengine/webenginesettings.py @@ -32,7 +32,7 @@ from PyQt5.QtWebEngineWidgets import (QWebEngineSettings, QWebEngineProfile, # pylint: enable=no-name-in-module,import-error,useless-suppression from qutebrowser.browser import shared -from qutebrowser.config import websettings +from qutebrowser.config import config, websettings from qutebrowser.utils import objreg, utils, standarddir, javascript @@ -65,6 +65,21 @@ class StaticSetter(websettings.StaticSetter): GLOBAL_SETTINGS = QWebEngineSettings.globalSettings +class PersistentCookiePolicy(websettings.Base): + + """The cookies -> store setting is different from other settings.""" + + def get(self, settings=None): + return config.get('content', 'cookies-store') + + def _set(self, value, settings=None): + utils.unused(settings) + QWebEngineProfile.defaultProfile().setPersistentCookiesPolicy( + QWebEngineProfile.AllowPersistentCookies if value else + QWebEngineProfile.NoPersistentCookies + ) + + def _init_stylesheet(profile): """Initialize custom stylesheets. @@ -121,6 +136,9 @@ def init(args): profile = QWebEngineProfile.defaultProfile() _init_profile(profile) _init_stylesheet(profile) + # We need to do this here as a WORKAROUND for + # https://bugreports.qt.io/browse/QTBUG-58650 + PersistentCookiePolicy().set(config.get('content', 'cookies-store')) websettings.init_mappings(MAPPINGS) objreg.get('config').changed.connect(update_settings) @@ -169,6 +187,9 @@ MAPPINGS = { Attribute(QWebEngineSettings.LocalContentCanAccessRemoteUrls), 'local-content-can-access-file-urls': Attribute(QWebEngineSettings.LocalContentCanAccessFileUrls), + # https://bugreports.qt.io/browse/QTBUG-58650 + # 'cookies-store': + # PersistentCookiePolicy(), }, 'input': { 'spatial-navigation': diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index f68e6cad5..6a5f9d6d8 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -891,9 +891,9 @@ def data(readonly=False): "Control which cookies to accept."), ('cookies-store', - SettingValue(typ.Bool(), 'true', - backends=[usertypes.Backend.QtWebKit]), - "Whether to store cookies."), + SettingValue(typ.Bool(), 'true'), + "Whether to store cookies. Note this option needs a restart with " + "QtWebEngine."), ('host-block-lists', SettingValue(