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 'webtoolbar.py') diff --git a/webtoolbar.py b/webtoolbar.py index 642b310..dc0b3de 100644 --- a/webtoolbar.py +++ b/webtoolbar.py @@ -337,6 +337,7 @@ class PrimaryToolbar(ToolbarBase): self._progress_changed_hid = None self._session_history_changed_hid = None self._uri_changed_hid = None + self._security_status_changed_hid = None if tabbed_view.get_n_pages(): self._connect_to_browser(tabbed_view.props.current_browser) @@ -355,6 +356,7 @@ class PrimaryToolbar(ToolbarBase): self._browser.disconnect(self._uri_changed_hid) self._browser.disconnect(self._progress_changed_hid) self._browser.disconnect(self._loading_changed_hid) + self._browser.disconnect(self._security_status_changed_hid) self._browser = browser if not isinstance(self._browser, DummyBrowser): @@ -364,6 +366,7 @@ class PrimaryToolbar(ToolbarBase): self._set_address(address) self._set_progress(self._browser.props.progress) self._set_status(self._browser.props.load_status) + self._set_security_status(self._browser.security_status) is_webkit_browser = isinstance(self._browser, Browser) self.entry.props.editable = is_webkit_browser @@ -374,18 +377,36 @@ class PrimaryToolbar(ToolbarBase): 'notify::progress', self.__progress_changed_cb) self._loading_changed_hid = self._browser.connect( 'notify::load-status', self.__loading_changed_cb) + self._security_status_changed_hid = self._browser.connect( + 'security-status-changed', self.__security_status_changed_cb) self._update_navigation_buttons() def __loading_changed_cb(self, widget, param): self._set_status(widget.get_load_status()) + def __security_status_changed_cb(self, widget): + self._set_security_status(widget.security_status) + def __progress_changed_cb(self, widget, param): self._set_progress(widget.get_progress()) def _set_status(self, status): self._set_loading(status < WebKit.LoadStatus.FINISHED) + def _set_security_status(self, security_status): + # Display security status as a lock icon in the left side of + # the URL entry. + if security_status is None: + self.entry.set_icon_from_pixbuf( + iconentry.ICON_ENTRY_PRIMARY, None) + elif security_status == Browser.SECURITY_STATUS_SECURE: + self.entry.set_icon_from_name( + iconentry.ICON_ENTRY_PRIMARY, 'channel-secure-symbolic') + elif security_status == Browser.SECURITY_STATUS_INSECURE: + self.entry.set_icon_from_name( + iconentry.ICON_ENTRY_PRIMARY, 'channel-insecure-symbolic') + def _set_progress(self, progress): if progress == 1.0: self.entry.set_progress_fraction(0.0) -- cgit v0.9.1