Merge the cookies-accept and third-party-cookie-policy settings

This commit is contained in:
Martin Tournoij 2015-06-05 15:57:43 +02:00
parent 472071c047
commit fc4c7bd2e4
4 changed files with 27 additions and 47 deletions

View File

@ -149,9 +149,8 @@
|<<content-ignore-javascript-alert,ignore-javascript-alert>>|Whether all javascript alerts should be ignored.
|<<content-local-content-can-access-remote-urls,local-content-can-access-remote-urls>>|Whether locally loaded documents are allowed to access remote urls.
|<<content-local-content-can-access-file-urls,local-content-can-access-file-urls>>|Whether locally loaded documents are allowed to access other local urls.
|<<content-cookies-accept,cookies-accept>>|Whether to accept cookies.
|<<content-cookies-accept,cookies-accept>>|Control which cookies to accept.
|<<content-cookies-store,cookies-store>>|Whether to store cookies.
|<<content-third-party-cookie-policy,third-party-cookie-policy>>|Accept cookies from domains other than the main website
|<<content-host-block-lists,host-block-lists>>|List of URLs of lists which contain hosts to block.
|<<content-host-blocking-enabled,host-blocking-enabled>>|Whether host blocking is enabled.
|==============
@ -1317,14 +1316,16 @@ Default: +pass:[true]+
[[content-cookies-accept]]
=== cookies-accept
Whether to accept cookies.
Control which cookies to accept.
Valid values:
* +default+: Default QtWebKit behavior.
* +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.
* +never+: Don't accept cookies at all.
Default: +pass:[default]+
Default: +pass:[no-3rdparty]+
[[content-cookies-store]]
=== cookies-store
@ -1337,18 +1338,6 @@ Valid values:
Default: +pass:[true]+
[[content-third-party-cookie-policy]]
=== third-party-cookie-policy
Accept cookies from domains other than the main website
Valid values:
* +always+: Always accept.
* +never+: Never accept.
* +existing+: Only accept if we already have acookie stored for the domain
Default: +pass:[never]+
[[content-host-block-lists]]
=== host-block-lists
List of URLs of lists which contain hosts to block.

View File

@ -674,17 +674,13 @@ def data(readonly=False):
"local urls."),
('cookies-accept',
SettingValue(typ.AcceptCookies(), 'default'),
"Whether to accept cookies."),
SettingValue(typ.AcceptCookies(), 'no-3rdparty'),
"Control which cookies to accept."),
('cookies-store',
SettingValue(typ.Bool(), 'true'),
"Whether to store cookies."),
('third-party-cookie-policy',
SettingValue(typ.ThirdPartyCookiePolicy(), 'never'),
"Accept cookies from domains other than the main website"),
('host-block-lists',
SettingValue(
typ.UrlList(none_ok=True),

View File

@ -1323,22 +1323,17 @@ class LastClose(BaseType):
class AcceptCookies(BaseType):
"""Whether to accept a cookie."""
"""Control which cookies to accept."""
valid_values = ValidValues(('default', "Default QtWebKit behavior."),
valid_values = ValidValues(('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."),
('never', "Don't accept cookies at all."))
class ThirdPartyCookiePolicy(BaseType):
"""Accept cookies from domains other than the main website."""
valid_values = ValidValues(('always', "Always accept."),
('never', "Never accept."),
('existing', "Only accept if we already have a"
"cookie stored for the domain."))
class ConfirmQuit(List):
"""Whether to display a confirmation when the window is closed."""

View File

@ -238,23 +238,23 @@ class GlobalSetter(Setter):
self._setter(*args)
class ThirdPartyCookies(Base):
class CookiePolicy(Base):
"""The ThirdPartyCookiePolicy setting is different from other settings."""
mapping = (
('always', QWebSettings.AlwaysAllowThirdPartyCookies),
('never', QWebSettings.AlwaysBlockThirdPartyCookies),
('existing', QWebSettings.AllowThirdPartyWithExistingCookies),
)
MAPPING = {
'all': QWebSettings.AlwaysAllowThirdPartyCookies,
'no-3rdparty': QWebSettings.AlwaysBlockThirdPartyCookies,
'never': QWebSettings.AlwaysBlockThirdPartyCookies,
'no-unknown-3rdparty': QWebSettings.AllowThirdPartyWithExistingCookies,
}
def get(self, qws=None):
policy = QWebSettings.globalSettings().thirdPartyCookiePolicy()
return tuple(filter(lambda i: i[1] == policy, self.mapping))[0][0]
return config.get('content', 'cookies-accept')
def _set(self, value, qws=None):
x = filter(lambda i: i[0] == value, self.mapping)
QWebSettings.globalSettings().setThirdPartyCookiePolicy(tuple(x)[0][1])
QWebSettings.globalSettings().setThirdPartyCookiePolicy(
self.MAPPING[value])
MAPPINGS = {
@ -283,8 +283,8 @@ MAPPINGS = {
Attribute(QWebSettings.LocalContentCanAccessRemoteUrls),
'local-content-can-access-file-urls':
Attribute(QWebSettings.LocalContentCanAccessFileUrls),
'third-party-cookie-policy':
ThirdPartyCookies(),
'cookies-accept':
CookiePolicy(),
},
'network': {
'dns-prefetch':