From dcb5f998b24f359d7c3e1980da3c58b6f6e2331a Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Wed, 28 Nov 2012 14:53:59 +0000 Subject: 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 Acked-by: Manuel Kaufmann --- (limited to 'browser.py') diff --git a/browser.py b/browser.py index 8b986ad..7419d2d 100644 --- a/browser.py +++ b/browser.py @@ -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() -- cgit v0.9.1