[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [torbutton/master] Remove more old toggle code.
commit 27e21ca1c60a776b0bb640202e1259f737c4ed9f
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Tue Feb 5 16:36:25 2013 -0800
Remove more old toggle code.
---
src/chrome/content/torbutton.js | 414 +--------------------------------------
1 files changed, 1 insertions(+), 413 deletions(-)
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index f3c098f..b9a34f2 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -1951,10 +1951,6 @@ function torbutton_update_status(mode, force_update) {
}
}
- if (m_tb_prefs.getBoolPref('extensions.torbutton.clear_history')) {
- torbutton_clear_history();
- }
-
if(mode) {
if(m_tb_prefs.getBoolPref('extensions.torbutton.block_thwrite')) {
torbutton_setIntPref("browser.download.manager.retention",
@@ -2140,10 +2136,6 @@ function torbutton_update_status(mode, force_update) {
}
}
- if (m_tb_prefs.getBoolPref('extensions.torbutton.jar_certs')) {
- torbutton_jar_certs(mode);
- }
-
if (m_tb_prefs.getBoolPref('extensions.torbutton.clear_cookies')) {
torbutton_clear_cookies();
} else if (m_tb_prefs.getBoolPref('extensions.torbutton.cookie_jars')
@@ -2300,39 +2292,6 @@ function torbutton_browser_proxy_prefs_init()
}
// -------------- HISTORY & COOKIES ---------------------
-// Bug 1506 P0: Only used by toggle. Kill it.
-function torbutton_clear_history() {
- torbutton_log(2, 'called torbutton_clear_history');
- var hist = Components.classes["@mozilla.org/browser/global-history;2"]
- .getService(Components.interfaces.nsIBrowserHistory);
- hist.removeAllPages();
-
- // Clear individual session histories also
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var enumerator = wm.getEnumerator("navigator:browser");
- var js_enabled = m_tb_prefs.getBoolPref("javascript.enabled");
- torbutton_log(2, "Clearing browser session history");
- while(enumerator.hasMoreElements()) {
- var win = enumerator.getNext();
- var browser = win.getBrowser();
- if(!browser) {
- torbutton_log(5, "No browser for history window");
- continue;
- }
-
- var browsers = browser.browsers;
-
- for (var i = 0; i < browsers.length; ++i) {
- var b = browser.browsers[i];
-
- if(b.webNavigation.sessionHistory.count) {
- b.webNavigation.sessionHistory.PurgeHistory(
- b.webNavigation.sessionHistory.count);
- }
- }
- }
-}
// Bug 1506 P4: Used by New Identity if cookie protections are
// not in use.
@@ -2376,377 +2335,6 @@ function torbutton_jar_cookies(mode) {
}
}
-// Bug 1506 P0: Toggle-only. Kill it.
-function torbutton_jar_cert_type(mode, treeView, name, type) {
- var certdb = Components.classes["@mozilla.org/security/x509certdb;1"]
- .getService(Components.interfaces.nsIX509CertDB2);
- certdb.QueryInterface(Components.interfaces.nsIX509CertDB);
- var outFile = Components.classes["@mozilla.org/file/local;1"].
- createInstance(Components.interfaces.nsILocalFile);
- var outList = [];
- var outIndexList = [];
-
- torbutton_log(2, "Jaring "+name+" certificates: "+mode);
-
- if(type == Components.interfaces.nsIX509Cert.CA_CERT) {
- try {
- var bundles = Components.classes["@mozilla.org/intl/stringbundle;1"]
- .getService(Components.interfaces.nsIStringBundleService);
- var pipnss_bundle = bundles.createBundle("chrome://pipnss/locale/pipnss.properties");
- var internalToken = pipnss_bundle.GetStringFromName("InternalToken");
- } catch(err) {
- torbutton_log(5, "No String bundle for NSS: "+err);
- }
- }
-
- for(var i = 0; i < treeView.rowCount; i++) {
- var cert = treeView.getCert(i);
- // HACK alert
- // There is no real way to differentiate user added
- // CA certificates from builtin ones, aside from the
- // token name string (which is localized)
- if(!cert || (type == Components.interfaces.nsIX509Cert.CA_CERT
- && cert.tokenName != internalToken)) {
- continue;
- }
-
- outList.push(cert);
- outIndexList.push(i);
- }
-
- // Write current certs to certjar-tor
- // clear certs
- // load certs from certjar-nontor (if exists)
-
- var dir = Components.classes["@mozilla.org/file/directory_service;1"]
- .getService(Components.interfaces.nsIProperties)
- .get("ProfD", Components.interfaces.nsIFile);
-
- if(mode) {
- // http://developer.mozilla.org/en/docs/Code_snippets:File_I/O#Getting_special_files
- outFile.initWithPath(dir.path);
- outFile.append("certs-"+name+".nottor");
- } else {
- // http://developer.mozilla.org/en/docs/Code_snippets:File_I/O#Getting_special_files
- outFile.initWithPath(dir.path);
- outFile.append("certs-"+name+".tor");
- }
-
- // this prompts for a password..
- //certdb.exportPKCS12File(null, outFile, outList.length, outList);
-
- if(outFile.exists()) {
- outFile.remove(false);
- }
-
- if(outList.length) {
- outFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
-
- var stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
- .createInstance(Components.interfaces.nsIFileOutputStream);
- stream.init(outFile, 0x04 | 0x08 | 0x20, 0600, 0); // write, create, truncate
-
- var bstream = Components.classes["@mozilla.org/binaryoutputstream;1"]
- .createInstance(Components.interfaces.nsIBinaryOutputStream);
- bstream.setOutputStream(stream);
-
- var binaryCerts = [];
- var bitList = [];
-
- for(var i = outList.length-1; i>=0; i--) {
- if(outList[i]) {
- var len = new Object();
- var data = outList[i].getRawDER(len);
- //torbutton_log(2, "Delete: "+certdb.deleteCertificate(outList[i]));
- torbutton_log(2, "Delete: "+outList[i].organization+" "+outList[i].tokenName);
- // Need to save trustbits somehow.. They are not saved.
- var bits = 0;
- if(certdb.isCertTrusted(outList[i], type, certdb.TRUSTED_SSL)) {
- bits |= certdb.TRUSTED_SSL;
- }
- if(certdb.isCertTrusted(outList[i], type, certdb.TRUSTED_EMAIL)) {
- bits |= certdb.TRUSTED_EMAIL;
- }
- if(certdb.isCertTrusted(outList[i], type, certdb.TRUSTED_OBJSIGN)) {
- bits |= certdb.TRUSTED_OBJSIGN;
- }
-
- treeView.removeCert(outIndexList[i]);
- certdb.deleteCertificate(outList[i]);
-
- bitList.push(bits);
- binaryCerts.push(data);
- }
- }
-
- bstream.write32(binaryCerts.length);
- for(var i = 0; i < binaryCerts.length; i++) {
- bstream.write32(binaryCerts[i].length);
- bstream.write32(bitList[i]);
- bstream.writeByteArray(binaryCerts[i], binaryCerts[i].length);
- }
-
- bstream.close();
- stream.close();
- }
-
- torbutton_log(2, "Wrote "+outList.length+" "+name+" certificates to "+outFile.path);
-}
-
-// Bug 1506 P0: Toggle-only. Kill it.
-function torbutton_bytearray_to_string(ba) {
- var ret = "";
- for(var i = 0; i < ba.length; i++) {
- ret = ret + String.fromCharCode(ba[i]);
- }
- return ret;
-}
-
-// Bug 1506 P0: Toggle-only. Kill it.
-function torbutton_unjar_cert_type(mode, treeView, name, type) {
- var unjared_certs = 0;
- var certdb = Components.classes["@mozilla.org/security/x509certdb;1"]
- .getService(Components.interfaces.nsIX509CertDB2);
- certdb.QueryInterface(Components.interfaces.nsIX509CertDB);
-
- var inFile = Components.classes["@mozilla.org/file/local;1"].
- createInstance(Components.interfaces.nsILocalFile);
-
- var dir = Components.classes["@mozilla.org/file/directory_service;1"]
- .getService(Components.interfaces.nsIProperties)
- .get("ProfD", Components.interfaces.nsIFile);
-
- if(mode) {
- inFile.initWithPath(dir.path);
- inFile.append("certs-"+name+".tor");
- } else {
- inFile.initWithPath(dir.path);
- inFile.append("certs-"+name+".nottor");
- }
-
- torbutton_log(2, "Checking for certificates from "+inFile.path);
-
- if(!inFile.exists()) {
- return;
- }
- torbutton_log(2, "Reading certificates from "+inFile.path);
-
- var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
- .createInstance(Components.interfaces.nsIFileInputStream);
- istream.init(inFile, -1, -1, false);
-
- var bstream = Components.classes["@mozilla.org/binaryinputstream;1"]
- .createInstance(Components.interfaces.nsIBinaryInputStream);
- bstream.setInputStream(istream);
-
- if(bstream.available()) {
- var certs = bstream.read32();
-
- if(type == Components.interfaces.nsIX509Cert.CA_CERT) {
- m_tb_prefs.setBoolPref("extensions.torbutton.block_cert_dialogs",
- true);
- }
-
- for(var i = 0; i < certs; i++) {
- var len = bstream.read32();
- var trustBits = bstream.read32();
- var bytes = bstream.readByteArray(len);
-
- // This just for the trustBits, which seem to be lost
- // in the BER translation. sucks..
- var base64 = window.btoa(torbutton_bytearray_to_string(bytes));
- var checkCert = certdb.constructX509FromBase64(base64);
- torbutton_log(2, "Made Cert: "+checkCert.organization);
-
- try {
- switch(type) {
- case Components.interfaces.nsIX509Cert.EMAIL_CERT:
- certdb.importEmailCertificate(bytes, bytes.length, null);
- break;
- case Components.interfaces.nsIX509Cert.SERVER_CERT:
- certdb.importServerCertificate(bytes, bytes.length, null);
- break;
- case Components.interfaces.nsIX509Cert.USER_CERT:
- certdb.importUserCertificate(bytes, bytes.length, null);
- break;
- case Components.interfaces.nsIX509Cert.CA_CERT:
- certdb.importCertificates(bytes, bytes.length, type, null);
- break;
- }
-
- certdb.setCertTrust(checkCert, type, trustBits);
-
- } catch(e) {
- torbutton_log(5, "Failed to import cert: "+checkCert.organization+": "+e);
- }
-
- unjared_certs++;
- }
- if(type == Components.interfaces.nsIX509Cert.CA_CERT) {
- m_tb_prefs.setBoolPref("extensions.torbutton.block_cert_dialogs",
- false);
- }
-
- torbutton_log(2, "Read "+unjared_certs+" "+name+" certificates from "+inFile.path);
- }
-
- bstream.close();
- istream.close();
-
- return unjared_certs;
-}
-
-// Bug 1506 P0: Toggle-only. Kill it.
-function torbutton_jar_certs(mode) {
- var tot_certs = 0;
- var certCache =
- Components.classes["@mozilla.org/security/nsscertcache;1"]
- .getService(Components.interfaces.nsINSSCertCache);
-
- var serverTreeView =
- Components.classes["@mozilla.org/security/nsCertTree;1"]
- .createInstance(Components.interfaces.nsICertTree);
- var emailTreeView = Components.classes["@mozilla.org/security/nsCertTree;1"]
- .createInstance(Components.interfaces.nsICertTree);
- var userTreeView = Components.classes["@mozilla.org/security/nsCertTree;1"]
- .createInstance(Components.interfaces.nsICertTree);
- var caTreeView = Components.classes["@mozilla.org/security/nsCertTree;1"]
- .createInstance(Components.interfaces.nsICertTree);
-
- torbutton_log(3, "Jaring certificates: "+mode);
-
- // backup cert8.db just in case..
- // XXX: Verify it actually is cert8.db on windows
-
- var dbfile = Components.classes["@mozilla.org/file/local;1"].
- createInstance(Components.interfaces.nsILocalFile);
-
- var dir = Components.classes["@mozilla.org/file/directory_service;1"]
- .getService(Components.interfaces.nsIProperties)
- .get("ProfD", Components.interfaces.nsIFile);
-
- dbfile.initWithPath(dir.path);
- dbfile.append("cert8.db.bak");
-
- if(!dbfile.exists()) {
- torbutton_log(4, "Backing up certificates from "+dbfile.path);
- dbfile.initWithPath(dir.path);
- dbfile.append("cert8.db");
- dbfile.copyTo(dir, "cert8.db.bak");
- torbutton_log(4, "Backed up certificates to "+dbfile.path+".bak");
- }
-
- certCache.cacheAllCerts();
- serverTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.SERVER_CERT);
- emailTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.EMAIL_CERT);
- userTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.USER_CERT);
- caTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.CA_CERT);
-
- if(m_tb_prefs.getBoolPref("extensions.torbutton.jar_ca_certs")) {
- torbutton_jar_cert_type(mode, caTreeView, "ca",
- Components.interfaces.nsIX509Cert.CA_CERT);
- }
- torbutton_jar_cert_type(mode, userTreeView, "user",
- Components.interfaces.nsIX509Cert.USER_CERT);
- torbutton_jar_cert_type(mode, emailTreeView, "email",
- Components.interfaces.nsIX509Cert.EMAIL_CERT);
- torbutton_jar_cert_type(mode, serverTreeView, "server",
- Components.interfaces.nsIX509Cert.SERVER_CERT);
-
- certCache.cacheAllCerts();
- serverTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.SERVER_CERT);
- if(serverTreeView.selection)
- serverTreeView.selection.clearSelection();
-
- emailTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.EMAIL_CERT);
- if(emailTreeView.selection)
- emailTreeView.selection.clearSelection();
-
- userTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.USER_CERT);
- if(userTreeView.selection)
- userTreeView.selection.clearSelection();
-
- caTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.CA_CERT);
- if(caTreeView.selection)
- caTreeView.selection.clearSelection();
-
- var certdb = Components.classes["@mozilla.org/security/x509certdb;1"]
- .getService(Components.interfaces.nsIX509CertDB2);
- certdb.QueryInterface(Components.interfaces.nsIX509CertDB);
-
- certCache.cacheAllCerts();
- serverTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.SERVER_CERT);
- if(serverTreeView.selection)
- serverTreeView.selection.clearSelection();
-
- emailTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.EMAIL_CERT);
- if(emailTreeView.selection)
- emailTreeView.selection.clearSelection();
-
- userTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.USER_CERT);
- if(userTreeView.selection)
- userTreeView.selection.clearSelection();
-
- caTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.CA_CERT);
- if(caTreeView.selection)
- caTreeView.selection.clearSelection();
-
-
- if(m_tb_prefs.getBoolPref("extensions.torbutton.jar_ca_certs")) {
- if(torbutton_unjar_cert_type(mode, caTreeView, "ca",
- Components.interfaces.nsIX509Cert.CA_CERT) == 0) {
- // arma thinks this not worth even asking. He is probably right.
- m_tb_prefs.setBoolPref("extensions.torbutton.jar_ca_certs",
- false);
- }
- }
- torbutton_unjar_cert_type(mode, userTreeView, "user",
- Components.interfaces.nsIX509Cert.USER_CERT);
- torbutton_unjar_cert_type(mode, emailTreeView, "email",
- Components.interfaces.nsIX509Cert.EMAIL_CERT);
-
- // XXX: on FF3, somehow CA certs get loaded into server pane on
- // reload
- torbutton_unjar_cert_type(mode, serverTreeView, "server",
- Components.interfaces.nsIX509Cert.SERVER_CERT);
-
-
- certCache.cacheAllCerts();
- serverTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.SERVER_CERT);
- if(serverTreeView.selection)
- serverTreeView.selection.clearSelection();
-
- emailTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.EMAIL_CERT);
- if(emailTreeView.selection)
- emailTreeView.selection.clearSelection();
-
- userTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.USER_CERT);
- if(userTreeView.selection)
- userTreeView.selection.clearSelection();
-
- caTreeView.loadCertsFromCache(certCache,
- Components.interfaces.nsIX509Cert.CA_CERT);
- if(caTreeView.selection)
- caTreeView.selection.clearSelection();
-
-}
-
-
// -------------- JS/PLUGIN HANDLING CODE ---------------------
// Bug 1506 P3: Defense in depth. Disables JS and events for New Identity.
function torbutton_disable_browser_js(browser) {
@@ -2948,7 +2536,7 @@ function torbutton_do_main_window_startup()
Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
// Wrap Google search service.
- torbutton_wrap_search_service();
+ //torbutton_wrap_search_service();
torbutton_unique_pref_observer.register();
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits