From 86200242d8280d64e15df01b605ce6a4a598ac93 Mon Sep 17 00:00:00 2001 From: Ryan Cunningham Date: Wed, 23 Apr 2014 03:27:38 +0000 Subject: Changed browser.py for parental controls --- diff --git a/browser.py b/browser.py index 35c7437..6f4b247 100644 --- a/browser.py +++ b/browser.py @@ -581,6 +581,12 @@ class Browser(WebKit.WebView): self.__mime_type_policy_cb) self.connect('load-error', self.__load_error_cb) + if os.path.isfile(os.path.join(os.environ['SUGAR_HOME'], "perm_sites")): + with open(os.path.join(os.environ['SUGAR_HOME'], "perm_sites")) as f: + for line in f: + if uri = line: + self.emit('load-error') + self._inject_media_style = False ContentInvoker(self) @@ -755,13 +761,33 @@ class Browser(WebKit.WebView): 'title': _('This web page could not be loaded'), 'message': _('"%s" could not be loaded. Please check for ' 'typing errors, and make sure you are connected ' - 'to the Internet.') % uri, + 'to the internet.') % uri, + 'btn_value': _('Try again'), + 'url': uri, + } + controldata = { + 'page_title': _('You\'re not allowed to visit this page'), + 'title': _('You\'re not allowed to visit this page'), + 'message': _('"%s" could not be loaded. Please make sure ' + 'this site has not been blacklisted in your ' + 'parental controls.') % uri, 'btn_value': _('Try again'), 'url': uri, } - html = open(DEFAULT_ERROR_PAGE, 'r').read() % data - web_frame.load_alternate_string(html, uri, uri) + if os.path.isfile(os.path.join(os.environ['SUGAR_HOME'], "nointernet")): + html = open(DEFAULT_ERROR_PAGE, 'r').read() % controldata + web_frame.load_alternate_string(html, uri, uri) + + if os.path.isfile(os.path.join(os.environ['SUGAR_HOME'], "perm_sites")): + with open(os.path.join(os.environ['SUGAR_HOME'], "perm_sites")) as f: + for line in f: + if uri = line: + html = open(DEFAULT_ERROR_PAGE, 'r').read() % controldata + web_frame.load_alternate_string(html, uri, uri) + else: + html = open(DEFAULT_ERROR_PAGE, 'r').read() % data + web_frame.load_alternate_string(html, uri, uri) return True -- cgit v0.9.1