Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Commit

Permalink
cleanup; fix right-align in Add-ons bar
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinhungry committed Mar 10, 2013
1 parent c49c0c6 commit b1ac230
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 76 deletions.
129 changes: 67 additions & 62 deletions content/cipherfox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

var cipherFox = (function() {
var CipherFox = (function() {
'use strict';

var certDb = Cc['@mozilla.org/security/x509certdb;1'].getService(Ci.nsIX509CertDB);
var certDlg = Cc['@mozilla.org/nsCertificateDialogs;1'].getService(Ci.nsICertificateDialogs);
var certDlg = Cc['@mozilla.org/nsCertificateDialogs;1'].getService(Ci.nsICertificateDialogs);
var pipnss = Cc['@mozilla.org/intl/stringbundle;1'].getService(Ci.nsIStringBundleService)
.createBundle('chrome://pipnss/locale/pipnss.properties');

Expand All @@ -22,15 +22,36 @@ var cipherFox = (function() {
// XUL DOM elements
var cfToggle, cfPanel, cfButton, cfCerts, cfBCerts, cfPSep;

// unused functions must be defined
var updateListener = {
onStateChange: function() {},
onProgressChange: function() {},
onLocationChange: function() {},
onStatusChange: function() {},
onSecurityChange: function(webProgress, request, state) { updateCipher(); }
var hideIdentityPopup = function() {
gIdentityHandler.hideIdentityPopup();
};

// show dialog for cert in database
var viewCertByDBKey = function(e) {
hideIdentityPopup();

var dbkey = e.target.getAttribute('dbkey');
var cert = certDb.findCertByDBKey(dbkey, null);
certDlg.viewCert(window, cert);
};

// update RC4 settings to reflect current preference
var setRC4 = function() {
for (var i = 0, len = rc4.length; i < len; i++) {
if (rc4Enabled) {
try { prefService.clearUserPref('security.ssl3.' + rc4[i]); }
catch(e) {}
} else {
prefService.setBoolPref('security.ssl3.' + rc4[i], false);
}
}
};

var toggleRC4 = function() {
rc4Enabled = !rc4Enabled;
cfToggle.setAttribute('checked', rc4Enabled);
setRC4();
};

// get existing preferences
var loadPrefs = function() {
Expand All @@ -48,32 +69,6 @@ var cipherFox = (function() {
cfToggle.setAttribute('checked', rc4Enabled);
};


var updateCipher = function() {
gIdentityHandler.hideIdentityPopup();

var currentBrowser = gBrowser.selectedBrowser;
var panelLabel = null;
var hidden = true;

var ui = currentBrowser.securityUI;
if (ui instanceof Ci.nsISecureBrowserUI) {
var status = ui.QueryInterface(Ci.nsISSLStatusProvider).SSLStatus;
var isPartial = (ui.state & Ci.nsIWebProgressListener.STATE_IS_BROKEN);

if (status instanceof Ci.nsISSLStatus) {
panelLabel = formatLabel(status);
hidden = !(panelLabel && (!isPartial || prefs.show_partial));
populateCertChain(status);
}
}

cfPanel.label = cfButton.label = panelLabel;
cfPanel.hidden = hidden || !prefs.show_panel;
cfButton.hidden = hidden || !prefs.show_button;
};


// get all certs and update
var populateCertChain = function(status) {

Expand All @@ -98,7 +93,7 @@ var cipherFox = (function() {
var certItem = document.createElement('menuitem');

if (cert.tokenName === 'Builtin Object Token' && cert.certType === Ci.nsIX509Cert.CA_CERT) {
if (!prefs.show_builtin) { continue; }
if (!prefs.show_builtin) { continue; }
certItem.setAttribute('builtin', true);
}

Expand Down Expand Up @@ -126,7 +121,6 @@ var cipherFox = (function() {
}
};


var formatLabel = function(obj) {
var cert, label;

Expand Down Expand Up @@ -198,35 +192,38 @@ var cipherFox = (function() {
return label;
};

var updateCipher = function() {
hideIdentityPopup();

// show dialog for cert in database
var viewCertByDBKey = function(e) {
var dbkey = e.target.getAttribute('dbkey');
var cert = certDb.findCertByDBKey(dbkey, null);
certDlg.viewCert(window, cert);
};


var toggleRC4 = function() {
rc4Enabled = !rc4Enabled;
cfToggle.setAttribute('checked', rc4Enabled);
setRC4();
};
var currentBrowser = gBrowser.selectedBrowser;
var panelLabel = null;
var hidden = true;

var ui = currentBrowser.securityUI;
if (ui instanceof Ci.nsISecureBrowserUI) {
var status = ui.QueryInterface(Ci.nsISSLStatusProvider).SSLStatus;
var isPartial = (ui.state & Ci.nsIWebProgressListener.STATE_IS_BROKEN);

// update RC4 settings to reflect current preference
var setRC4 = function() {
for (var i = 0; i < rc4.length; i++) {
if (rc4Enabled) {
try {
prefService.clearUserPref('security.ssl3.' + rc4[i]);
} catch(e) {}
} else {
prefService.setBoolPref('security.ssl3.' + rc4[i], false);
if (status instanceof Ci.nsISSLStatus) {
panelLabel = formatLabel(status);
hidden = !(panelLabel && (!isPartial || prefs.show_partial));
populateCertChain(status);
}
}

cfPanel.label = cfButton.label = panelLabel;
cfPanel.hidden = hidden || !prefs.show_panel;
cfButton.hidden = hidden || !prefs.show_button;
};

// unused functions must be defined
var updateListener = {
onStateChange: function(){},
onProgressChange: function(){},
onLocationChange: function(){},
onStatusChange: function(){},
onSecurityChange: function(webProgress, request, state) { updateCipher(); }
};

// exposed methods
return {
Expand All @@ -242,9 +239,17 @@ var cipherFox = (function() {
var moreInfo = document.getElementById('identity-popup-more-info-button');
if (moreInfo instanceof XULElement) {
moreInfo.removeAttribute('onblur');
moreInfo.addEventListener('command', gIdentityHandler.hideIdentityPopup, false);
moreInfo.addEventListener('command', hideIdentityPopup, false);
}

cfCerts.addEventListener('popupshowing', function() {
cfPanel.setAttribute('popupopen', true);
}, false);

cfCerts.addEventListener('popuphiding', function() {
cfPanel.removeAttribute('popupopen');
}, false);

// quick RC4 toggle
cfToggle.addEventListener('command', toggleRC4, false);

Expand All @@ -266,7 +271,7 @@ var cipherFox = (function() {
prefService.removeObserver('extensions.cipherfox.', this);
gBrowser.removeProgressListener(updateListener);
},

// update state when prefs change
observe: function(subject, topic, data) {
if (topic === 'nsPref:changed') {
Expand All @@ -275,7 +280,7 @@ var cipherFox = (function() {
if (data === 'extensions.cipherfox.disable_rc4') { setRC4(); }
}
},

// Qualys SSL Labs Server Test
testDomain: function() {
gBrowser.addTab('https://www.ssllabs.com/ssldb/analyze.html?d='
Expand Down
12 changes: 6 additions & 6 deletions content/cipherfox.xul
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<script type='application/javascript' src='cipherfox.js'/>
<script type='application/javascript'>
window.addEventListener('load', function() { cipherFox.onLoad(); }, false);
window.addEventListener('unload', function() { cipherFox.onUnload(); }, false);
window.addEventListener('load', function() { CipherFox.onLoad(); }, false);
window.addEventListener('unload', function() { CipherFox.onUnload(); }, false);
</script>

<menupopup id='menu_ToolsPopup'>
Expand All @@ -26,21 +26,21 @@
<menupopup id='cipherfox-button-certs'>
<menuseparator id='cipherfox-prefs-seperator'/>
<menuitem label='&qualys.label;' accesskey='&qualys.accesskey;'
oncommand='cipherFox.testDomain()'/>
oncommand='CipherFox.testDomain()'/>
<menuitem label='&prefs.label;' accesskey='&prefs.accesskey;'
oncommand='window.openDialog("chrome://cipherfox/content/prefs.xul")'/>
</menupopup>
</button>
</vbox>

<statusbar id='status-bar'>
<statusbar id='status-bar'>
<statusbarpanel id='cipherfox-panel' label='&cipherfox.title;' insertbefore='security-button'
hidden='true' popup='cipherfox-certs' context='cipherfox-context'/>

<menupopup id='cipherfox-certs' position='before_start'/>
<menupopup id='cipherfox-certs' position='before_end'/>
<menupopup id='cipherfox-context'>
<menuitem label='&qualys.label;' accesskey='&qualys.accesskey;'
oncommand='cipherFox.testDomain()'/>
oncommand='CipherFox.testDomain()'/>
<menuitem label='&prefs.label;' accesskey='&prefs.accesskey;'
oncommand='window.openDialog("chrome://cipherfox/content/prefs.xul")'/>
</menupopup>
Expand Down
2 changes: 1 addition & 1 deletion content/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

var cipherFox_prefs = {
var CipherFox_prefs = {

onLoad: function() {
var Cc = Components.classes;
Expand Down
8 changes: 4 additions & 4 deletions content/prefs.xul
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<script type='application/javascript' src='prefs.js'/>
<script type='application/javascript'>
window.addEventListener('load', function() { cipherFox_prefs.onLoad(); }, false);
window.addEventListener('load', function() { CipherFox_prefs.onLoad(); }, false);
</script>

<prefpane id='cipherfox-prefpane' flex='1'>
Expand All @@ -42,7 +42,7 @@
</box>
<box>
<checkbox label='&disableRC4.label;' preference='pref_disable_rc4'
oncommand='return cipherFox_prefs.confirmRC4(this)'/>
oncommand='return CipherFox_prefs.confirmRC4(this)'/>
</box>
</groupbox>

Expand All @@ -68,12 +68,12 @@
<row align='center'>
<label value='&cipher.label;:'/>
<textbox preference='pref_base_format'/>
<button label='&default.label;' oncommand='cipherFox_prefs.baseFormat.reset();'/>
<button label='&default.label;' oncommand='CipherFox_prefs.baseFormat.reset();'/>
</row>
<row align='center'>
<label value='&cert.label;:'/>
<textbox preference='pref_cert_format'/>
<button label='&default.label;' oncommand='cipherFox_prefs.certFormat.reset();'/>
<button label='&default.label;' oncommand='CipherFox_prefs.certFormat.reset();'/>
</row>
</rows>
</grid>
Expand Down
10 changes: 7 additions & 3 deletions skin/overlay.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
padding: 0;
margin-top: -1px;
margin-bottom: -2px;
-moz-padding-start: 3px;
-moz-margin-start: 4px;
background: url('chrome://cipherfox/skin/arrow-up.png') left center no-repeat;
-moz-padding-end: 3px;
-moz-margin-end: 4px;
background: url('chrome://cipherfox/skin/arrow-up.png') right center no-repeat;
}

#cipherfox-panel[popupopen] {
Expand Down Expand Up @@ -46,6 +46,10 @@
display: none;
}

#cipherfox-certs {
text-align: end;
}

#cipherfox-certs menuitem[first],
#cipherfox-button-certs menuitem[first] {
font-weight: bold;
Expand Down

0 comments on commit b1ac230

Please sign in to comment.