Merge branch '3rd-party-cookies' of https://github.com/Carpetsmoker/qutebrowser into Carpetsmoker-3rd-party-cookies

This commit is contained in:
Florian Bruhin 2015-06-08 20:38:19 +02:00
commit 3b4fe97dbc
4 changed files with 36 additions and 8 deletions

View File

@ -149,7 +149,7 @@
|<<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-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.
@ -1316,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

View File

@ -675,8 +675,8 @@ 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'),

View File

@ -1337,9 +1337,14 @@ 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."))

View File

@ -238,6 +238,25 @@ class GlobalSetter(Setter):
self._setter(*args)
class CookiePolicy(Base):
"""The ThirdPartyCookiePolicy setting is different from other settings."""
MAPPING = {
'all': QWebSettings.AlwaysAllowThirdPartyCookies,
'no-3rdparty': QWebSettings.AlwaysBlockThirdPartyCookies,
'never': QWebSettings.AlwaysBlockThirdPartyCookies,
'no-unknown-3rdparty': QWebSettings.AllowThirdPartyWithExistingCookies,
}
def get(self, qws=None):
return config.get('content', 'cookies-accept')
def _set(self, value, qws=None):
QWebSettings.globalSettings().setThirdPartyCookiePolicy(
self.MAPPING[value])
MAPPINGS = {
'content': {
'allow-images':
@ -264,6 +283,8 @@ MAPPINGS = {
Attribute(QWebSettings.LocalContentCanAccessRemoteUrls),
'local-content-can-access-file-urls':
Attribute(QWebSettings.LocalContentCanAccessFileUrls),
'cookies-accept':
CookiePolicy(),
},
'network': {
'dns-prefetch':