Hello John,

"John J. Foerch" <[email protected]> wrote:
> On Sat, May 28, 2011 at 11:21:21AM +0000, Jörg Sommer wrote:
>> Hello John,
>> 
>> "John J. Foerch" <[email protected]> wrote:
>> > On Mon, May 23, 2011 at 10:44:17AM +0000, Jörg Sommer wrote:
>> >> Hi,
>> >> 
>> >> how can I give the address in the status bar a different color for SSL
>> >> sites? I would like to have a visual effect that shows me when I'm
>> >> leaving a site.
>> >
>> > The experimental branch I'm working on will have a security level
>> > notification in the mode-line.
>> 
>> Is this experimental branch public? I don't see it at
>> <git://repo.or.cz/conkeror.git>.
>
> So far it's only on my website, http://retroj.net/conkeror-decoupling

Here's a dirty hack. It does what I want, but it doesn't do it good.

From 9c86c4721aa766363828b2cfdaec4c38a9098b51 Mon Sep 17 00:00:00 2001
Message-Id: 
<9c86c4721aa766363828b2cfdaec4c38a9098b51.1306628834.git.jo...@alea.gnuu.de>
From: =?UTF-8?q?J=C3=B6rg=20Sommer?= <[email protected]>
Date: Sun, 29 May 2011 02:18:36 +0200
Subject: [PATCH] mode-line: visual indication for secure connection

This is a dirty hack! It must be redone by someone how knows what he
does.

The changes in content-buffer.js where picked form

commit 8d84306253d65c23d0d3584ac3b0a945e9c61e34
Author: John Foerch <[email protected]>
Date:   Sat Feb 5 15:43:58 2011 -0500

    browser: work on webProgressListener

    browser.prototype.loading: fixup

except the ugly attribute securityLevel. The idication should be managed
by proper CSS classes and not direct assignment of a color.
---
 modules/content-buffer.js |   40 ++++++++++++++++++----------------------
 modules/mode-line.js      |    7 +++++++
 2 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/modules/content-buffer.js b/modules/content-buffer.js
index 986827c..f1abfe0 100644
--- a/modules/content-buffer.js
+++ b/modules/content-buffer.js
@@ -20,6 +20,7 @@ 
define_buffer_local_hook("content_buffer_started_loading_hook");
 define_buffer_local_hook("content_buffer_progress_change_hook");
 define_buffer_local_hook("content_buffer_location_change_hook");
 define_buffer_local_hook("content_buffer_status_change_hook");
+define_buffer_local_hook("content_buffer_security_change_hook");
 define_buffer_local_hook("content_buffer_focus_change_hook");
 define_buffer_local_hook("content_buffer_dom_link_added_hook");
 define_buffer_local_hook("content_buffer_popup_blocked_hook");
@@ -28,6 +29,7 @@ 
define_current_buffer_hook("current_content_buffer_finished_loading_hook", "cont
 define_current_buffer_hook("current_content_buffer_progress_change_hook", 
"content_buffer_progress_change_hook");
 define_current_buffer_hook("current_content_buffer_location_change_hook", 
"content_buffer_location_change_hook");
 define_current_buffer_hook("current_content_buffer_status_change_hook", 
"content_buffer_status_change_hook");
+define_current_buffer_hook("current_content_buffer_security_change_hook", 
"content_buffer_security_change_hook");
 define_current_buffer_hook("current_content_buffer_focus_change_hook", 
"content_buffer_focus_change_hook");
 
 
@@ -292,29 +294,23 @@ content_buffer.prototype = {
     },
 
     // This method is called when the security state of the browser changes.
+    securityLevel: "unknown",
     onSecurityChange: function (webProgress, request, state) {
-        /* FIXME: currently this isn't used */
-
-        /*
-        const WPL = Components.interfaces.nsIWebProgressListener;
-
-        if (state & WPL.STATE_IS_INSECURE) {
-            // update visual indicator
-        } else {
-            var level = "unknown";
-            if (state & WPL.STATE_IS_SECURE) {
-                if (state & WPL.STATE_SECURE_HIGH)
-                    level = "high";
-                else if (state & WPL.STATE_SECURE_MED)
-                    level = "medium";
-                else if (state & WPL.STATE_SECURE_LOW)
-                    level = "low";
-            } else if (state & WPL_STATE_IS_BROKEN) {
-                level = "mixed";
-            }
-            // provide a visual indicator of the security state here.
-        }
-        */
+        const wpl = Ci.nsIWebProgressListener;
+        var level = "unknown";
+        if (state & wpl.STATE_IS_INSECURE)
+            level = "insecure";
+        else if (state & wpl.STATE_IS_SECURE) {
+            if (state & wpl.STATE_SECURE_HIGH)
+                level = "secure-high";
+            else if (state & wpl.STATE_SECURE_MED)
+                level = "secure-medium";
+            else if (state & wpl.STATE_SECURE_LOW)
+                level = "secure-low";
+        } else if (state & wpl.STATE_IS_BROKEN)
+            level = "mixed";
+        this.securityLevel = level;
+        content_buffer_security_change_hook.run(this, level);
     },
 
     /* Inherit from buffer */
diff --git a/modules/mode-line.js b/modules/mode-line.js
index 41dce7a..9e025da 100644
--- a/modules/mode-line.js
+++ b/modules/mode-line.js
@@ -140,11 +140,18 @@ function current_buffer_name_widget (window) {
     this.flex = "1";
     this.crop = "end";
     this.add_hook("current_content_buffer_location_change_hook");
+    this.add_hook("current_content_buffer_security_change_hook");
     this.add_hook("select_buffer_hook");
 }
 current_buffer_name_widget.prototype.__proto__ = text_widget.prototype;
 current_buffer_name_widget.prototype.update = function () {
     this.view.text = this.window.buffers.current.description;
+    if (this.window.buffers.current.securityLevel.indexOf("secure-") === 0)
+//        obj.view.element.classList.add("buffer-name-secure");
+        this.view.element.style.backgroundColor = "greenyellow";
+    else
+//        obj.view.element.classList.remove("buffer-name-secure");
+        this.view.element.style.backgroundColor = "";
 };
 
 function current_buffer_scroll_position_widget (window) {
-- 
1.7.5.3

Bye, Jörg.
-- 
Ein Mensch sieht ein und das ist wichtig,
nichts ist ganz falsch und nichts ganz richtig.
                                               (Eugen Roth)
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to