@@ -74,6 +74,14 @@ const StatusLine = Module("statusline", {
74
74
this . _statuslineWidget = document . getElementById ( "liberator-status" ) ;
75
75
// initialize setVisibility static variables
76
76
this . setVisibility ( - 1 ) ;
77
+ // In case of insecure login forms, connection icon is updated after page load.
78
+ const VERSION = Services . appinfo . platformVersion ;
79
+ if ( services . get ( "vc" ) . compare ( VERSION , "51" ) >= 0 ) {
80
+ gBrowser . addEventListener ( "InsecureLoginFormsStateChange" ,
81
+ function ( ) {
82
+ statusline . updateField ( 'ssl' , null ) ;
83
+ } ) ;
84
+ }
77
85
} ,
78
86
79
87
/**
@@ -241,37 +249,63 @@ const StatusLine = Module("statusline", {
241
249
} ) ;
242
250
statusline . addField ( "ssl" , "The currently SSL status" , "liberator-status-ssl" ,
243
251
function updateSSLState ( node , state ) {
244
- var className = "notSecure" ;
245
- var tooltip = gNavigatorBundle . getString ( "identity.unknown.tooltip" ) ;
246
- if ( ! state ) {
247
- let securityUI = config . tabbrowser . securityUI ;
248
- if ( securityUI )
249
- state = securityUI . state || 0 ;
250
- }
251
- const WPL = Components . interfaces . nsIWebProgressListener ;
252
- if ( state & WPL . STATE_IDENTITY_EV_TOPLEVEL ) {
253
- className = "verifiedIdentity" ;
254
- if ( state & WPL . STATE_BLOCKED_MIXED_ACTIVE_CONTENT )
255
- className = "mixedActiveBlocked" ;
256
- tooltip = gNavigatorBundle . getFormattedString (
257
- "identity.identified.verifier" ,
258
- [ gIdentityHandler . getIdentityData ( ) . caOrg ] ) ;
259
- } else if ( state & WPL . STATE_IS_SECURE ) {
260
- className = "verifiedDomain" ;
261
- if ( state & WPL . STATE_BLOCKED_MIXED_ACTIVE_CONTENT )
262
- className = "mixedActiveBlocked" ;
263
- tooltip = gNavigatorBundle . getFormattedString (
264
- "identity.identified.verifier" ,
265
- [ gIdentityHandler . getIdentityData ( ) . caOrg ] ) ;
266
- } else if ( state & WPL . STATE_IS_BROKEN ) {
267
- if ( state & WPL . STATE_LOADED_MIXED_ACTIVE_CONTENT )
268
- className = "mixedActiveContent" ;
252
+ const VERSION = Services . appinfo . platformVersion ;
253
+ if ( services . get ( "vc" ) . compare ( VERSION , "51" ) >= 0 ) {
254
+ conn_icon = document . getElementById ( "connection-icon" ) ;
255
+ node . style . listStyleImage = window . getComputedStyle ( conn_icon ) . getPropertyValue ( "list-style-image" ) ;
256
+ if ( node . style . listStyleImage === "none" )
257
+ node . style . listStyleImage = "url(chrome://browser/skin/identity-icon.svg#normal)" ;
258
+
259
+ // Get color of bottombar set by ":highlight Normal background: …" as rgb() string
260
+ let bbBackgroundColorRGB = window . getComputedStyle ( document . getElementById ( "liberator-bottombar" ) . firstChild ) . getPropertyValue ( "background-color" ) ;
261
+ // Split string into RGB array
262
+ let bbBackgroundColor = bbBackgroundColorRGB . substring ( 4 , bbBackgroundColorRGB . length - 1 ) . replace ( / / g, '' ) . split ( ',' ) ;
263
+ // Calculate (standard) luminance
264
+ let bbBackgroundLuminance = 0.2126 * bbBackgroundColor [ 0 ] + 0.7152 * bbBackgroundColor [ 1 ] + 0.0722 * bbBackgroundColor [ 2 ] ;
265
+ // Arbitrary threshold to switch to white-on-black icon
266
+ let iconcolor = bbBackgroundLuminance < 128 ? "white" : "black" ;
267
+ node . style . listStyleImage = node . style . listStyleImage . replace ( / ( # [ a - z A - Z - ] + ) ( - w h i t e | - b l a c k ) ? / , "$1-" + iconcolor ) ;
268
+
269
+ node . style . visibility = "visible" ;
270
+
271
+ var tooltip = conn_icon . tooltipText ;
272
+ if ( tooltip )
273
+ node . setAttribute ( "tooltiptext" , tooltip ) ;
269
274
else
270
- className = "mixedDisplayContent" ;
271
- tooltip = gNavigatorBundle . getString ( "identity.unknown.tooltip" ) ;
275
+ node . removeAttribute ( "tooltiptext" ) ;
276
+ } else {
277
+ var className = "notSecure" ;
278
+ var tooltip = gNavigatorBundle . getString ( "identity.unknown.tooltip" ) ;
279
+ if ( ! state ) {
280
+ let securityUI = config . tabbrowser . securityUI ;
281
+ if ( securityUI )
282
+ state = securityUI . state || 0 ;
283
+ }
284
+ const WPL = Components . interfaces . nsIWebProgressListener ;
285
+ if ( state & WPL . STATE_IDENTITY_EV_TOPLEVEL ) {
286
+ className = "verifiedIdentity" ;
287
+ if ( state & WPL . STATE_BLOCKED_MIXED_ACTIVE_CONTENT )
288
+ className = "mixedActiveBlocked" ;
289
+ tooltip = gNavigatorBundle . getFormattedString (
290
+ "identity.identified.verifier" ,
291
+ [ gIdentityHandler . getIdentityData ( ) . caOrg ] ) ;
292
+ } else if ( state & WPL . STATE_IS_SECURE ) {
293
+ className = "verifiedDomain" ;
294
+ if ( state & WPL . STATE_BLOCKED_MIXED_ACTIVE_CONTENT )
295
+ className = "mixedActiveBlocked" ;
296
+ tooltip = gNavigatorBundle . getFormattedString (
297
+ "identity.identified.verifier" ,
298
+ [ gIdentityHandler . getIdentityData ( ) . caOrg ] ) ;
299
+ } else if ( state & WPL . STATE_IS_BROKEN ) {
300
+ if ( state & WPL . STATE_LOADED_MIXED_ACTIVE_CONTENT )
301
+ className = "mixedActiveContent" ;
302
+ else
303
+ className = "mixedDisplayContent" ;
304
+ tooltip = gNavigatorBundle . getString ( "identity.unknown.tooltip" ) ;
305
+ }
306
+ node . className = className ;
307
+ node . setAttribute ( "tooltiptext" , tooltip ) ;
272
308
}
273
- node . className = className ;
274
- node . setAttribute ( "tooltiptext" , tooltip ) ;
275
309
} , {
276
310
openPopup : function ( anchor ) {
277
311
var handler = window . gIdentityHandler ;
0 commit comments