Allow 'yes' value for geolocation/notifications.

Fixes #655.
This commit is contained in:
Florian Bruhin 2015-05-06 22:21:11 +02:00
parent deb3c31f2f
commit 9a5839650c
3 changed files with 7 additions and 31 deletions

View File

@ -325,7 +325,8 @@ class BrowserPage(QWebPage):
QWebPage.Notifications: ('content', 'notifications'), QWebPage.Notifications: ('content', 'notifications'),
QWebPage.Geolocation: ('content', 'geolocation'), QWebPage.Geolocation: ('content', 'geolocation'),
} }
if config.get(*options[feature]) == 'ask': config_val = config.get(*options[feature])
if config_val == 'ask':
bridge = objreg.get('message-bridge', scope='window', bridge = objreg.get('message-bridge', scope='window',
window=self._win_id) window=self._win_id)
q = usertypes.Question(bridge) q = usertypes.Question(bridge)
@ -361,6 +362,9 @@ class BrowserPage(QWebPage):
self.loadStarted.connect(q.abort) self.loadStarted.connect(q.abort)
bridge.ask(q, blocking=False) bridge.ask(q, blocking=False)
elif config_val:
self.setFeaturePermission(frame, feature,
QWebPage.PermissionGrantedByUser)
else: else:
self.setFeaturePermission(frame, feature, self.setFeaturePermission(frame, feature,
QWebPage.PermissionDeniedByUser) QWebPage.PermissionDeniedByUser)

View File

@ -606,11 +606,11 @@ def data(readonly=False):
"are not affected by this setting."), "are not affected by this setting."),
('geolocation', ('geolocation',
SettingValue(typ.NoAsk(), 'ask'), SettingValue(typ.BoolAsk(), 'ask'),
"Allow websites to request geolocations."), "Allow websites to request geolocations."),
('notifications', ('notifications',
SettingValue(typ.NoAsk(), 'ask'), SettingValue(typ.BoolAsk(), 'ask'),
"Allow websites to show notifications."), "Allow websites to show notifications."),
#('allow-java', #('allow-java',

View File

@ -266,34 +266,6 @@ class BoolAsk(Bool):
super().validate(value) super().validate(value)
class NoAsk(BaseType):
"""A no/ask question."""
valid_values = ValidValues('false', 'ask')
def transform(self, value):
if value.lower() == 'ask':
return 'ask'
else:
return BOOLEAN_STATES[value.lower()]
def validate(self, value):
if not value:
if self._none_ok:
return
else:
raise configexc.ValidationError(value, "may not be empty!")
if value.lower() == 'ask':
return
try:
v = BOOLEAN_STATES[value.lower()]
if v:
raise configexc.ValidationError(value, "must be ask/false!")
except KeyError:
raise configexc.ValidationError(value, "must be ask/false!")
class Int(BaseType): class Int(BaseType):
"""Base class for an integer setting. """Base class for an integer setting.