diff options
-rw-r--r-- | browser.py | 26 | ||||
-rw-r--r-- | icons/channel-insecure-symbolic.svg | 59 | ||||
-rw-r--r-- | icons/channel-secure-symbolic.svg | 60 | ||||
-rw-r--r-- | pdfviewer.py | 2 | ||||
-rw-r--r-- | webactivity.py | 2 | ||||
-rw-r--r-- | webtoolbar.py | 21 |
6 files changed, 169 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() diff --git a/icons/channel-insecure-symbolic.svg b/icons/channel-insecure-symbolic.svg new file mode 100644 index 0000000..4c6ee0b --- /dev/null +++ b/icons/channel-insecure-symbolic.svg @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ + <!ENTITY fill_color "#FFFFFF"> + <!ENTITY stroke_color "#010101"> +]> + +<svg + xmlns="http://www.w3.org/2000/svg" + version="1.1" + width="22.16" + height="22.16" + id="svg7384"> + <title + id="title9167">Gnome Symbolic Icon Theme</title> + <g + transform="translate(-101.0002,-390.84)" + id="layer9" + style="display:inline"> + <g + transform="translate(81.0002,121)" + id="g4053-3-8" + style="fill:#bebebe;fill-opacity:1" /> + <g + transform="matrix(1.3,0,0,1.3,-30.225691,-123.93)" + id="g4347"> + <path + d="m 106.0002,397 c -1.64469,0 -3,1.35529 -3,3 l 0,3 2,0 0,-3 c 0,-0.57129 0.42873,-1 1,-1 l 2,0 c 0.57127,0 1,0.42871 1,1 l 0,0.25 c 0.26687,-0.14912 0.55674,-0.25 0.875,-0.25 l 1.125,0 c 0,-1.64471 -1.35531,-3 -3,-3 z m -3.0625,9 c -0.554,0 -1.06473,0.44979 -1,1 l 0,0.53125 0,4.46875 10.0625,0 0,-2 -2.125,0 c -1.01035,0 -1.875,-0.86466 -1.875,-1.875 l 0,-2.125 z" + id="rect4063-6-6" + style="color:#bebebe;fill:&stroke_color;;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible" /> + <path + d="m 109.875,401 c -0.49245,0 -0.875,0.38256 -0.875,0.875 l 0,6.25 c 0,0.49244 0.38255,0.875 0.875,0.875 l 6.25,0 c 0.49245,0 0.875,-0.38256 0.875,-0.875 l 0,-6.25 C 117,401.38256 116.61745,401 116.125,401 z m 2.50204,1 1.24592,0 0,4 -1.24592,0 z m 0,5 1.24592,0 0,1 -1.24592,0 z" + id="path10898-3-1" + style="color:#bebebe;fill:&stroke_color;;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible" /> + </g> + </g> + <g + transform="translate(-101.0002,-390.84)" + id="layer10" /> + <g + transform="translate(-101.0002,-390.84)" + id="layer11" /> + <g + transform="translate(-101.0002,-390.84)" + id="layer12" /> + <g + transform="translate(-101.0002,-390.84)" + id="layer13" /> + <g + transform="translate(-101.0002,-390.84)" + id="layer14" /> + <g + transform="translate(-101.0002,-390.84)" + id="layer15" + style="display:inline" /> + <g + transform="translate(-101.0002,-390.84)" + id="g4953" + style="display:inline" /> +</svg> diff --git a/icons/channel-secure-symbolic.svg b/icons/channel-secure-symbolic.svg new file mode 100644 index 0000000..8405550 --- /dev/null +++ b/icons/channel-secure-symbolic.svg @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ + <!ENTITY fill_color "#FFFFFF"> + <!ENTITY stroke_color "#010101"> +]> + +<svg + xmlns="http://www.w3.org/2000/svg" + version="1.1" + width="22.16" + height="22.16" + id="svg7384"> + <title + id="title9167">Gnome Symbolic Icon Theme</title> + <g + transform="translate(-81.0002,-390.84)" + id="layer9" + style="display:inline"> + <g + transform="matrix(1.3,0,0,1.3,-23.597904,-123.93)" + id="g3526"> + <g + transform="translate(61.0002,121)" + id="g4053-1-5" + style="fill:#bebebe;fill-opacity:1" /> + <path + d="m 85.0002,404 c -0.554,0 -1.18921,0.47931 -1,1 l 0,0.53125 0,4.46875 10,0 0,-4.46875 0,-0.53125 c 0,-0.554 -0.446,-1 -1,-1 z" + id="rect4063-8-6" + style="color:#bebebe;fill:&stroke_color;;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible" /> + <path + d="m 88,399 c -1.644703,0 -3,1.3553 -3,3 l 0,4 c 0,1.6447 1.355297,3 3,3 l 2,0 c 1.644703,0 3,-1.3553 3,-3 l 0,-4 c 0,-1.6447 -1.355297,-3 -3,-3 l -2,0 z m 0,2 2,0 c 0.571297,0 1,0.4287 1,1 l 0,4 c 0,0.5713 -0.428703,1 -1,1 l -2,0 c -0.571297,0 -1,-0.4287 -1,-1 l 0,-4 c 0,-0.5713 0.428703,-1 1,-1 z" + id="rect4291-5-4" + style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#bebebe;fill:&stroke_color;;fill-opacity:1;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans" /> + </g> + </g> + <g + transform="translate(-81.0002,-390.84)" + id="layer10" /> + <g + transform="translate(-81.0002,-390.84)" + id="layer11" /> + <g + transform="translate(-81.0002,-390.84)" + id="layer12" + style="display:inline" /> + <g + transform="translate(-81.0002,-390.84)" + id="layer13" /> + <g + transform="translate(-81.0002,-390.84)" + id="layer14" /> + <g + transform="translate(-81.0002,-390.84)" + id="layer15" + style="display:inline" /> + <g + transform="translate(-81.0002,-390.84)" + id="g4953" + style="display:inline" /> +</svg> diff --git a/pdfviewer.py b/pdfviewer.py index 6ce4fcf..6cfbaed 100644 --- a/pdfviewer.py +++ b/pdfviewer.py @@ -177,6 +177,7 @@ class DummyBrowser(GObject.GObject): 'new-tab': (GObject.SignalFlags.RUN_FIRST, None, ([str])), 'tab-close': (GObject.SignalFlags.RUN_FIRST, None, ([object])), 'selection-changed': (GObject.SignalFlags.RUN_FIRST, None, ([])), + 'security-status-changed': (GObject.SignalFlags.RUN_FIRST, None, ([])), } __gproperties__ = { @@ -194,6 +195,7 @@ class DummyBrowser(GObject.GObject): self._uri = "" self._progress = 0.0 self._load_status = WebKit.LoadStatus.PROVISIONAL + self.security_status = None def do_get_property(self, prop): if prop.name == 'title': diff --git a/webactivity.py b/webactivity.py index 0e3b61b..3c0d337 100644 --- a/webactivity.py +++ b/webactivity.py @@ -156,6 +156,8 @@ class WebActivity(activity.Activity): session = WebKit.get_default_session() session.set_property('accept-language-auto', True) + session.set_property('ssl-use-system-ca-file', True) + session.set_property('ssl-strict', False) # By default, cookies are not stored persistently, we have to # add a cookie jar so that they get saved to disk. We use one 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) |