diff options
author | Manuel Quiñones <manuq@laptop.org> | 2012-11-28 14:53:59 (GMT) |
---|---|---|
committer | Manuel Quiñones <manuq@laptop.org> | 2012-11-29 11:44:08 (GMT) |
commit | dcb5f998b24f359d7c3e1980da3c58b6f6e2331a (patch) | |
tree | ca0910a3870cf42430b6551067789b307f379c19 /browser.py | |
parent | ee7b2113802f313549622e2af014c78ba42df356 (diff) |
Display security as a lock icon for secured pages - SL #4245
For pages using the https protocol, display a) a lock icon if there
were no errors in the certification, or b) a broken lock icon if the
certification failed.
Use the same logic as Epiphany:
http://git.gnome.org/browse/epiphany/tree/embed/ephy-web-view.c#n2321
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Manuel Kaufmann <humitos@gmail.com>
Diffstat (limited to 'browser.py')
-rw-r--r-- | browser.py | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -513,10 +513,16 @@ class Browser(WebKit.WebView): 'open-pdf': (GObject.SignalFlags.RUN_FIRST, None, ([str])), + 'security-status-changed': (GObject.SignalFlags.RUN_FIRST, + None, + ([])), } CURRENT_SUGAR_VERSION = '0.98' + SECURITY_STATUS_SECURE = 1 + SECURITY_STATUS_INSECURE = 2 + def __init__(self): WebKit.WebView.__init__(self) @@ -545,6 +551,8 @@ class Browser(WebKit.WebView): # presses Enter on the URL Entry self.loading_uri = None + self.security_status = None + # Reference to the global history and callbacks to handle it: self._global_history = globalhistory.get_global_history() self.connect('notify::load-status', self.__load_status_changed_cb) @@ -648,12 +656,28 @@ class Browser(WebKit.WebView): return True def __load_status_changed_cb(self, widget, param): - """Add the url to the global history or update it.""" status = widget.get_load_status() if status <= WebKit.LoadStatus.COMMITTED: + # Add the url to the global history or update it. uri = self.get_uri() self._global_history.add_page(uri) + if status == WebKit.LoadStatus.COMMITTED: + # Update the security status. + response = widget.get_main_frame().get_network_response() + message = response.get_message() + if message: + use_https, certificate, tls_errors = message.get_https_status() + + if use_https: + if tls_errors == 0: + self.security_status = self.SECURITY_STATUS_SECURE + else: + self.security_status = self.SECURITY_STATUS_INSECURE + else: + self.security_status = None + self.emit('security-status-changed') + def __title_changed_cb(self, widget, param): """Update title in global history.""" uri = self.get_uri() |