Ticket #4245: 0001-Display-security-as-a-lock-icon-for-secured-pages-SL.patch
File 0001-Display-security-as-a-lock-icon-for-secured-pages-SL.patch, 12.9 KB (added by manuq, 11 years ago) |
---|
-
browser.py
From 3e0191ad2af2ed09d967dbb22cd093d56b9fdea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org> Date: Wed, 28 Nov 2012 11:53:59 -0300 Subject: [PATCH browse] Display security as a lock icon for secured pages - SL #4245 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mail-Followup-To: <sugar-devel@lists.sugarlabs.org> 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> --- browser.py | 26 +++++++++++++++- icons/channel-insecure-symbolic.svg | 59 ++++++++++++++++++++++++++++++++++++ icons/channel-secure-symbolic.svg | 60 +++++++++++++++++++++++++++++++++++++ pdfviewer.py | 2 ++ webactivity.py | 2 ++ webtoolbar.py | 21 +++++++++++++ 6 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 icons/channel-insecure-symbolic.svg create mode 100644 icons/channel-secure-symbolic.svg diff --git a/browser.py b/browser.py index 8b986ad..7419d2d 100644
a b class Browser(WebKit.WebView): 513 513 'open-pdf': (GObject.SignalFlags.RUN_FIRST, 514 514 None, 515 515 ([str])), 516 'security-status-changed': (GObject.SignalFlags.RUN_FIRST, 517 None, 518 ([])), 516 519 } 517 520 518 521 CURRENT_SUGAR_VERSION = '0.98' 519 522 523 SECURITY_STATUS_SECURE = 1 524 SECURITY_STATUS_INSECURE = 2 525 520 526 def __init__(self): 521 527 WebKit.WebView.__init__(self) 522 528 … … class Browser(WebKit.WebView): 545 551 # presses Enter on the URL Entry 546 552 self.loading_uri = None 547 553 554 self.security_status = None 555 548 556 # Reference to the global history and callbacks to handle it: 549 557 self._global_history = globalhistory.get_global_history() 550 558 self.connect('notify::load-status', self.__load_status_changed_cb) … … class Browser(WebKit.WebView): 648 656 return True 649 657 650 658 def __load_status_changed_cb(self, widget, param): 651 """Add the url to the global history or update it."""652 659 status = widget.get_load_status() 653 660 if status <= WebKit.LoadStatus.COMMITTED: 661 # Add the url to the global history or update it. 654 662 uri = self.get_uri() 655 663 self._global_history.add_page(uri) 656 664 665 if status == WebKit.LoadStatus.COMMITTED: 666 # Update the security status. 667 response = widget.get_main_frame().get_network_response() 668 message = response.get_message() 669 if message: 670 use_https, certificate, tls_errors = message.get_https_status() 671 672 if use_https: 673 if tls_errors == 0: 674 self.security_status = self.SECURITY_STATUS_SECURE 675 else: 676 self.security_status = self.SECURITY_STATUS_INSECURE 677 else: 678 self.security_status = None 679 self.emit('security-status-changed') 680 657 681 def __title_changed_cb(self, widget, param): 658 682 """Update title in global history.""" 659 683 uri = self.get_uri() -
new file icons/channel-insecure-symbolic.svg
diff --git a/icons/channel-insecure-symbolic.svg b/icons/channel-insecure-symbolic.svg new file mode 100644 index 0000000..4c6ee0b
- + 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ 3 <!ENTITY fill_color "#FFFFFF"> 4 <!ENTITY stroke_color "#010101"> 5 ]> 6 7 <svg 8 xmlns="http://www.w3.org/2000/svg" 9 version="1.1" 10 width="22.16" 11 height="22.16" 12 id="svg7384"> 13 <title 14 id="title9167">Gnome Symbolic Icon Theme</title> 15 <g 16 transform="translate(-101.0002,-390.84)" 17 id="layer9" 18 style="display:inline"> 19 <g 20 transform="translate(81.0002,121)" 21 id="g4053-3-8" 22 style="fill:#bebebe;fill-opacity:1" /> 23 <g 24 transform="matrix(1.3,0,0,1.3,-30.225691,-123.93)" 25 id="g4347"> 26 <path 27 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" 28 id="rect4063-6-6" 29 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" /> 30 <path 31 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" 32 id="path10898-3-1" 33 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" /> 34 </g> 35 </g> 36 <g 37 transform="translate(-101.0002,-390.84)" 38 id="layer10" /> 39 <g 40 transform="translate(-101.0002,-390.84)" 41 id="layer11" /> 42 <g 43 transform="translate(-101.0002,-390.84)" 44 id="layer12" /> 45 <g 46 transform="translate(-101.0002,-390.84)" 47 id="layer13" /> 48 <g 49 transform="translate(-101.0002,-390.84)" 50 id="layer14" /> 51 <g 52 transform="translate(-101.0002,-390.84)" 53 id="layer15" 54 style="display:inline" /> 55 <g 56 transform="translate(-101.0002,-390.84)" 57 id="g4953" 58 style="display:inline" /> 59 </svg> -
new file icons/channel-secure-symbolic.svg
diff --git a/icons/channel-secure-symbolic.svg b/icons/channel-secure-symbolic.svg new file mode 100644 index 0000000..8405550
- + 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ 3 <!ENTITY fill_color "#FFFFFF"> 4 <!ENTITY stroke_color "#010101"> 5 ]> 6 7 <svg 8 xmlns="http://www.w3.org/2000/svg" 9 version="1.1" 10 width="22.16" 11 height="22.16" 12 id="svg7384"> 13 <title 14 id="title9167">Gnome Symbolic Icon Theme</title> 15 <g 16 transform="translate(-81.0002,-390.84)" 17 id="layer9" 18 style="display:inline"> 19 <g 20 transform="matrix(1.3,0,0,1.3,-23.597904,-123.93)" 21 id="g3526"> 22 <g 23 transform="translate(61.0002,121)" 24 id="g4053-1-5" 25 style="fill:#bebebe;fill-opacity:1" /> 26 <path 27 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" 28 id="rect4063-8-6" 29 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" /> 30 <path 31 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" 32 id="rect4291-5-4" 33 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" /> 34 </g> 35 </g> 36 <g 37 transform="translate(-81.0002,-390.84)" 38 id="layer10" /> 39 <g 40 transform="translate(-81.0002,-390.84)" 41 id="layer11" /> 42 <g 43 transform="translate(-81.0002,-390.84)" 44 id="layer12" 45 style="display:inline" /> 46 <g 47 transform="translate(-81.0002,-390.84)" 48 id="layer13" /> 49 <g 50 transform="translate(-81.0002,-390.84)" 51 id="layer14" /> 52 <g 53 transform="translate(-81.0002,-390.84)" 54 id="layer15" 55 style="display:inline" /> 56 <g 57 transform="translate(-81.0002,-390.84)" 58 id="g4953" 59 style="display:inline" /> 60 </svg> -
pdfviewer.py
diff --git a/pdfviewer.py b/pdfviewer.py index 6ce4fcf..6cfbaed 100644
a b class DummyBrowser(GObject.GObject): 177 177 'new-tab': (GObject.SignalFlags.RUN_FIRST, None, ([str])), 178 178 'tab-close': (GObject.SignalFlags.RUN_FIRST, None, ([object])), 179 179 'selection-changed': (GObject.SignalFlags.RUN_FIRST, None, ([])), 180 'security-status-changed': (GObject.SignalFlags.RUN_FIRST, None, ([])), 180 181 } 181 182 182 183 __gproperties__ = { … … class DummyBrowser(GObject.GObject): 194 195 self._uri = "" 195 196 self._progress = 0.0 196 197 self._load_status = WebKit.LoadStatus.PROVISIONAL 198 self.security_status = None 197 199 198 200 def do_get_property(self, prop): 199 201 if prop.name == 'title': -
webactivity.py
diff --git a/webactivity.py b/webactivity.py index 0e3b61b..3c0d337 100644
a b class WebActivity(activity.Activity): 156 156 157 157 session = WebKit.get_default_session() 158 158 session.set_property('accept-language-auto', True) 159 session.set_property('ssl-use-system-ca-file', True) 160 session.set_property('ssl-strict', False) 159 161 160 162 # By default, cookies are not stored persistently, we have to 161 163 # add a cookie jar so that they get saved to disk. We use one -
webtoolbar.py
diff --git a/webtoolbar.py b/webtoolbar.py index 642b310..dc0b3de 100644
a b class PrimaryToolbar(ToolbarBase): 337 337 self._progress_changed_hid = None 338 338 self._session_history_changed_hid = None 339 339 self._uri_changed_hid = None 340 self._security_status_changed_hid = None 340 341 341 342 if tabbed_view.get_n_pages(): 342 343 self._connect_to_browser(tabbed_view.props.current_browser) … … class PrimaryToolbar(ToolbarBase): 355 356 self._browser.disconnect(self._uri_changed_hid) 356 357 self._browser.disconnect(self._progress_changed_hid) 357 358 self._browser.disconnect(self._loading_changed_hid) 359 self._browser.disconnect(self._security_status_changed_hid) 358 360 359 361 self._browser = browser 360 362 if not isinstance(self._browser, DummyBrowser): … … class PrimaryToolbar(ToolbarBase): 364 366 self._set_address(address) 365 367 self._set_progress(self._browser.props.progress) 366 368 self._set_status(self._browser.props.load_status) 369 self._set_security_status(self._browser.security_status) 367 370 368 371 is_webkit_browser = isinstance(self._browser, Browser) 369 372 self.entry.props.editable = is_webkit_browser … … class PrimaryToolbar(ToolbarBase): 374 377 'notify::progress', self.__progress_changed_cb) 375 378 self._loading_changed_hid = self._browser.connect( 376 379 'notify::load-status', self.__loading_changed_cb) 380 self._security_status_changed_hid = self._browser.connect( 381 'security-status-changed', self.__security_status_changed_cb) 377 382 378 383 self._update_navigation_buttons() 379 384 380 385 def __loading_changed_cb(self, widget, param): 381 386 self._set_status(widget.get_load_status()) 382 387 388 def __security_status_changed_cb(self, widget): 389 self._set_security_status(widget.security_status) 390 383 391 def __progress_changed_cb(self, widget, param): 384 392 self._set_progress(widget.get_progress()) 385 393 386 394 def _set_status(self, status): 387 395 self._set_loading(status < WebKit.LoadStatus.FINISHED) 388 396 397 def _set_security_status(self, security_status): 398 # Display security status as a lock icon in the left side of 399 # the URL entry. 400 if security_status is None: 401 self.entry.set_icon_from_pixbuf( 402 iconentry.ICON_ENTRY_PRIMARY, None) 403 elif security_status == Browser.SECURITY_STATUS_SECURE: 404 self.entry.set_icon_from_name( 405 iconentry.ICON_ENTRY_PRIMARY, 'channel-secure-symbolic') 406 elif security_status == Browser.SECURITY_STATUS_INSECURE: 407 self.entry.set_icon_from_name( 408 iconentry.ICON_ENTRY_PRIMARY, 'channel-insecure-symbolic') 409 389 410 def _set_progress(self, progress): 390 411 if progress == 1.0: 391 412 self.entry.set_progress_fraction(0.0)