Commit 18e72267 authored by Alex Catarineu's avatar Alex Catarineu
Browse files

Fix components and modules, and minor style changes

parent 2a501682
// # Security Settings User Interface for Mobile
// Utilities
let { utils: Cu } = Components;
let { getBoolPref, getIntPref, setBoolPref, setIntPref, getCharPref } =
Cu.import("resource://gre/modules/Services.jsm", {}).Services.prefs;
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { getBoolPref, getIntPref, setBoolPref, setIntPref, getCharPref }
= Services.prefs;
let { getLocale, show_torbrowser_manual } =
Cu.import("resource://torbutton/modules/utils.js", {});
ChromeUtils.import("resource://torbutton/modules/utils.js", {});
// Description elements have the follow names.
const descNames =
......@@ -64,7 +64,7 @@ function torbutton_set_learn_more_links() {
locale = getLocale();
}
let links = linkNames.map(name => document.getElementById(name));
links.forEach(link => {;
links.forEach(link => {
if (show_manual && locale != "") {
link.href= "https:/tb-manual.torproject.org/" + locale +
"/security-slider.html";
......
......@@ -26,18 +26,17 @@ let createTorCircuitDisplay = (function () {
"use strict";
// Mozilla utilities
const { Cu : utils , Ci : interfaces } = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
// Import the controller code.
let { controller } = Cu.import("resource://torbutton/modules/tor-control-port.js", {});
let { controller } = ChromeUtils.import("resource://torbutton/modules/tor-control-port.js", {});
// Utility functions
let { bindPrefAndInit, observe, getLocale, getDomainForBrowser } = Cu.import("resource://torbutton/modules/utils.js", {});
let { bindPrefAndInit, observe, getLocale, getDomainForBrowser } = ChromeUtils.import("resource://torbutton/modules/utils.js", {});
// Make the TorButton logger available.
let logger = Cc["@torproject.org/torbutton-logger;1"]
.getService(Components.interfaces.nsISupports).wrappedJSObject;
.getService(Ci.nsISupports).wrappedJSObject;
// ## Circuit/stream credentials and node monitoring
......@@ -209,18 +208,13 @@ let uiString = function (shortName) {
return torbuttonBundle.GetStringFromName("torbutton.circuit_display." + shortName);
};
// __regionBundle__.
// A list of localized region (country) names.
let regionBundle = Services.strings.createBundle(
"chrome://global/locale/regionNames.properties");
// __localizedCountryNameFromCode(countryCode)__.
// Convert a country code to a localized country name.
// Example: `'de'` -> `'Deutschland'` in German locale.
let localizedCountryNameFromCode = function (countryCode) {
if (!countryCode) return uiString("unknown_country");
try {
return regionBundle.GetStringFromName(countryCode.toLowerCase());
return Services.intl.getRegionDisplayNames(undefined, [countryCode])[0];
} catch (e) {
return countryCode.toUpperCase();
}
......@@ -363,7 +357,7 @@ let setupGuardNote = function () {
["div", {},
noteBefore, ["span", {class: "circuit-guard-name"}, name],
noteAfter, " ",
["span", {onclick: `gBrowser.selectedTab = gBrowser.addTab('https://support.torproject.org/${localeCode}/tbb/tbb-2/');`,
["span", {onclick: `gBrowser.selectedTab = gBrowser.addTab('https://support.torproject.org/${localeCode}/tbb/tbb-2/', {triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()});`,
class: "circuit-link"},
learnMoreString]]);
};
......
This diff is collapsed.
......@@ -3,8 +3,9 @@
// code directly. I don't see any of them as essential for 1506,
// really.
var m_tb_torlog = Components.classes["@torproject.org/torbutton-logger;1"]
.getService(Components.interfaces.nsISupports).wrappedJSObject;
// let { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
var m_tb_torlog = Cc["@torproject.org/torbutton-logger;1"]
.getService(Ci.nsISupports).wrappedJSObject;
var m_tb_string_bundle = torbutton_get_stringbundle();
......@@ -28,10 +29,8 @@ function torbutton_get_prefbranch(branch_name) {
var o_branch = false;
torbutton_log(1, "called get_prefbranch()");
o_prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
if (!o_prefs)
{
o_prefs = Services.prefs;
if (!o_prefs) {
torbutton_log(5, "Failed to get preferences-service!");
return false;
}
......@@ -52,8 +51,7 @@ function torbutton_get_stringbundle()
var o_stringbundle = false;
try {
var oBundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var oBundle = Services.strings;
o_stringbundle = oBundle.createBundle("chrome://torbutton/locale/torbutton.properties");
} catch(err) {
o_stringbundle = false;
......
......@@ -14,20 +14,15 @@ const kMODULE_CID = Components.ID("84d47da6-79c3-4661-aa9f-8049476f7bf5");
const kAboutTorURL = "chrome://torbutton/content/aboutTor/aboutTor.xhtml";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function AboutTor()
{
}
function AboutTor() {}
AboutTor.prototype =
{
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIAboutModule]),
// nsIClassInfo implementation:
classDescription: kMODULE_NAME,
......@@ -35,11 +30,9 @@ AboutTor.prototype =
contractID: kMODULE_CONTRACTID,
// nsIAboutModule implementation:
newChannel: function(aURI, aLoadInfo)
{
let ioSvc = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
let uri = ioSvc.newURI(kAboutTorURL, null, null);
newChannel(aURI, aLoadInfo) {
let ioSvc = Services.io;
let uri = ioSvc.newURI(kAboutTorURL);
let channel = ioSvc.newChannelFromURIWithLoadInfo(uri, aLoadInfo);
channel.originalURI = aURI;
......
......@@ -18,12 +18,11 @@ const kMODULE_NAME = "Cookie Jar Selector";
const kMODULE_CONTRACTID = "@torproject.org/cookie-jar-selector;1";
const kMODULE_CID = Components.ID("e6204253-b690-4159-bfe8-d4eedab6b3be");
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://torbutton/modules/default-prefs.js", {})
ChromeUtils.import("resource://torbutton/modules/default-prefs.js", {})
.ensureDefaultPrefs();
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
// XXX: Must match the definition in torcookie.js :/
function Cookie(number,name,value,isDomain,host,rawHost,HttpOnly,path,isSecure,isSession,
expires,isProtected) {
......@@ -42,73 +41,32 @@ function Cookie(number,name,value,isDomain,host,rawHost,HttpOnly,path,isSecure,i
}
function CookieJarSelector() {
var Cc = Components.classes;
var Ci = Components.interfaces;
this.logger = Components.classes["@torproject.org/torbutton-logger;1"]
.getService(Components.interfaces.nsISupports).wrappedJSObject;
this.logger = Cc["@torproject.org/torbutton-logger;1"]
.getService(Ci.nsISupports).wrappedJSObject;
this.logger.log(3, "Component Load 5: New CookieJarSelector "+kMODULE_CONTRACTID);
this.logger.log(3, "Component Load 5: New CookieJarSelector " + kMODULE_CONTRACTID);
this.prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
this.prefs = Services.prefs;
var getProfileFile = function(filename) {
var loc = "ProfD"; // profile directory
var file =
Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
var loc = "ProfD"; // profile directory
var file = Services.dirsvc
.get(loc, Ci.nsIFile)
.clone();
file.append(filename);
return file;
};
var copyProfileFile = function(src, dest) {
var srcfile = getProfileFile(src);
var destfile = getProfileFile(dest);
if (srcfile.exists()) {
// XXX: Permissions issue with Vista roaming profiles?
// Maybe file locking?
try {
if (destfile.exists()) {
destfile.remove(false);
}
} catch(e) {
this.logger.log(4, "Cookie file deletion exception: "+e);
}
try {
srcfile.copyTo(null, dest);
} catch(e) {
this.logger.log(5, "Cookie file copy exception: "+e);
}
}
};
var moveProfileFile = function(src, dest) { // FIXME: Why does this not work?
var srcfile = getProfileFile(src);
var destfile = getProfileFile(dest);
if (srcfile.exists()) {
if (destfile.exists()) {
destfile.remove(false);
}
srcfile.moveTo(null, dest);
}
};
this.clearCookies = function() {
try {
Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager)
.removeAll();
} catch(e) {
this.logger.log(4, "Cookie clearing exception: "+e);
Services.cookies.removeAll();
} catch (e) {
this.logger.log(4, "Cookie clearing exception: " + e);
}
};
this._cookiesToJS = function(getSession) {
var cookieManager =
Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager);
var cookieManager = Services.cookies;
var cookiesEnum = cookieManager.enumerator;
var cookiesAsJS = [];
var count = 0;
......@@ -353,7 +311,7 @@ function CookieJarSelector() {
var nextCookie = enumerator.getNext();
if (!nextCookie) break;
nextCookie = nextCookie.QueryInterface(Components.interfaces.nsICookie);
nextCookie = nextCookie.QueryInterface(Ci.nsICookie);
for (var i = 0; i < protCookies.length; i++) {
protcookie = protcookie || (nextCookie.host == protCookies[i].host &&
nextCookie.name == protCookies[i].name &&
......@@ -371,7 +329,7 @@ function CookieJarSelector() {
}
// Emit cookie-changed event. This instructs other components to clear their identifiers
// (Specifically DOM storage and safe browsing, but possibly others)
var obsSvc = Components.classes["@mozilla.org/observer-service;1"].getService(nsIObserverService);
var obsSvc = Cc["@mozilla.org/observer-service;1"].getService(nsIObserverService);
obsSvc.notifyObservers(this, "cookie-changed", "cleared");
} catch (e) {
this.logger.log(5, "Error deleting unprotected cookies: " + e);
......@@ -410,10 +368,8 @@ function CookieJarSelector() {
};
// Check firefox version to know filename
var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo);
var versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator);
// var appInfo = Services.appinfo;
// var versionChecker = Services.vc;
// This JSObject is exported directly to chrome
this.wrappedJSObject = this;
......@@ -424,15 +380,8 @@ function CookieJarSelector() {
this.timerCallback = {
cookie_changed: false,
QueryInterface: function(iid) {
if (!iid.equals(Component.interfaces.nsISupports) &&
!iid.equals(Component.interfaces.nsITimer)) {
Components.returnCode = Cr.NS_ERROR_NO_INTERFACE;
return null;
}
return this;
},
notify: function() {
QueryInterface: ChromeUtils.generateQI(["nsITimer"]),
notify() {
// this refers to timerCallback object. use jarThis to reference
// CookieJarSelector object.
if(!this.cookie_changed) {
......@@ -450,27 +399,18 @@ function CookieJarSelector() {
}
const nsISupports = Components.interfaces.nsISupports;
const nsIClassInfo = Components.interfaces.nsIClassInfo;
const nsIObserver = Components.interfaces.nsIObserver;
const nsITimer = Components.interfaces.nsITimer;
const nsIComponentRegistrar = Components.interfaces.nsIComponentRegistrar;
const nsIObserverService = Components.interfaces.nsIObserverService;
const nsICategoryManager = Components.interfaces.nsICategoryManager;
const nsISupports = Ci.nsISupports;
const nsIClassInfo = Ci.nsIClassInfo;
const nsIObserver = Ci.nsIObserver;
const nsITimer = Ci.nsITimer;
const nsIComponentRegistrar = Ci.nsIComponentRegistrar;
const nsIObserverService = Ci.nsIObserverService;
const nsICategoryManager = Ci.nsICategoryManager;
// Start1506: You may or may not care about this:
CookieJarSelector.prototype =
{
QueryInterface: function(iid)
{
if (!iid.equals(nsIClassInfo) &&
!iid.equals(nsIObserver) &&
!iid.equals(nsISupports)) {
Components.returnCode = Cr.NS_ERROR_NO_INTERFACE;
return null;
}
return this;
},
QueryInterface: ChromeUtils.generateQI(["nsIClassInfo", "nsIObserver"]),
wrappedJSObject: null, // Initialized by constructor
......@@ -496,19 +436,18 @@ CookieJarSelector.prototype =
observe : function(aSubject, aTopic, aData) {
switch(aTopic) {
case "cookie-changed":
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var prefs = Services.prefs;
this.timerCallback.cookie_changed = true;
if (aData == "added"
&& prefs.getBoolPref("extensions.torbutton.cookie_auto_protect")
&& !prefs.getBoolPref("extensions.torbutton.tor_memory_jar"))
{
this.addProtectedCookie(aSubject.QueryInterface(Components.interfaces.nsICookie2));//protect the new cookie!
&& !prefs.getBoolPref("extensions.torbutton.tor_memory_jar")) {
this.addProtectedCookie(aSubject.QueryInterface(Ci.nsICookie2));// protect the new cookie!
}
break;
case "profile-after-change":
var obsSvc = Components.classes["@mozilla.org/observer-service;1"].getService(nsIObserverService);
obsSvc.addObserver(this, "cookie-changed", false);
var obsSvc = Cc["@mozilla.org/observer-service;1"].getService(nsIObserverService);
obsSvc.addObserver(this, "cookie-changed");
// after profil loading, initialize a timer to call timerCallback
// at a specified interval
this.timer.initWithCallback(this.timerCallback, 60 * 1000, nsITimer.TYPE_REPEATING_SLACK); // 1 minute
......@@ -517,7 +456,7 @@ CookieJarSelector.prototype =
}
},
timer: Components.classes["@mozilla.org/timer;1"].createInstance(nsITimer),
timer: Cc["@mozilla.org/timer;1"].createInstance(nsITimer),
}
......@@ -525,7 +464,7 @@ CookieJarSelector.prototype =
* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
*/
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
if (XPCOMUtils.generateNSGetFactory)
var NSGetFactory = XPCOMUtils.generateNSGetFactory([CookieJarSelector]);
else
......
......@@ -6,21 +6,19 @@
// call earlier functions). The code file can be processed
// with docco.js to provide clear documentation.
/* jshint esversion: 6 */
/* global Components, console, XPCOMUtils */
// ### Abbreviations
const Cc = Components.classes, Ci = Components.interfaces, Cu = Components.utils;
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
// Make the logger available.
let logger = Cc["@torproject.org/torbutton-logger;1"]
.getService(Components.interfaces.nsISupports).wrappedJSObject;
.getService(Ci.nsISupports).wrappedJSObject;
let { ensureDefaultPrefs } = Cu.import("resource://torbutton/modules/default-prefs.js", {});
let { ensureDefaultPrefs } = ChromeUtils.import("resource://torbutton/modules/default-prefs.js", {});
ensureDefaultPrefs();
// Import Services object
Cu.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
// Import crypto object (FF 37+).
Cu.importGlobalProperties(["crypto"]);
......@@ -82,6 +80,8 @@ tor.socksProxyCredentials = function (originalProxy, domain) {
proxy.port,
domain, // username
tor.noncesForDomains[domain], // password
"", // aProxyAuthorizationHeader
"", // aConnectionIsolationKey
proxy.flags,
proxy.failoverTimeout,
proxy.failoverProxy);
......@@ -138,7 +138,6 @@ tor.isolateCircuitsByDomain = function () {
}
try {
let channel = aChannel.QueryInterface(Ci.nsIChannel),
proxy = aProxy.QueryInterface(Ci.nsIProxyInfo),
firstPartyDomain = channel.loadInfo.originAttributes.firstPartyDomain;
if (firstPartyDomain === "") {
firstPartyDomain = "--unknown--";
......@@ -165,7 +164,7 @@ const kMODULE_CONTRACTID = "@torproject.org/domain-isolator;1";
const kMODULE_CID = Components.ID("e33fd6d4-270f-475f-a96f-ff3140279f68");
// Import XPCOMUtils object.
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
// DomainIsolator object.
function DomainIsolator() {
......@@ -174,7 +173,7 @@ function DomainIsolator() {
// Firefox component requirements
DomainIsolator.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
QueryInterface: ChromeUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
classDescription: kMODULE_NAME,
classID: kMODULE_CID,
contractID: kMODULE_CONTRACTID,
......
......@@ -5,13 +5,11 @@
* access to URLs (a potential proxy bypass vector).
*************************************************************************/
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://torbutton/modules/default-prefs.js", {}).ensureDefaultPrefs();
ChromeUtils.import("resource://torbutton/modules/default-prefs.js", {}).ensureDefaultPrefs();
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
// Module specific constants
const kMODULE_NAME = "Torbutton Drag and Drop Handler";
......@@ -26,17 +24,15 @@ function DragDropFilter() {
this.logger.log(3, "Component Load 0: New DragDropFilter.");
try {
var observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
observerService.addObserver(this, "on-datatransfer-available", false);
} catch(e) {
Services.obs.addObserver(this, "on-datatransfer-available");
} catch (e) {
this.logger.log(5, "Failed to register drag observer");
}
}
DragDropFilter.prototype =
{
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
QueryInterface: ChromeUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
// make this an nsIClassInfo object
flags: Ci.nsIClassInfo.DOM_OBJECT,
......
......@@ -12,14 +12,9 @@
* handle an URL (e.g., when the user clicks on a mailto: URL).
*************************************************************************/
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/SharedPromptUtils.jsm");
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const {PromptUtils} = ChromeUtils.import("resource://gre/modules/SharedPromptUtils.jsm");
// Module specific constants
const kMODULE_NAME = "Torbutton External App Handler";
......@@ -38,7 +33,7 @@ ExternalAppBlocker.prototype =
{
_helperAppLauncher: undefined,
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver,
QueryInterface: ChromeUtils.generateQI([Ci.nsISupports, Ci.nsIObserver,
Ci.nsIHelperAppWarningDialog]),
// make this an nsIClassInfo object
......
......@@ -7,16 +7,13 @@
* Tor check service
*************************************************************************/
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
// Module specific constants
const kMODULE_NAME = "Torbutton Tor Check Service";
const kMODULE_CONTRACTID = "@torproject.org/torbutton-torCheckService;1";
const kMODULE_CID = Components.ID("5d57312b-5d8c-4169-b4af-e80d6a28a72e");
const Cr = Components.results;
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
function TBTorCheckService() {
this._logger = Cc["@torproject.org/torbutton-logger;1"]
.getService(Ci.nsISupports).wrappedJSObject;
......@@ -28,15 +25,7 @@ function TBTorCheckService() {
TBTorCheckService.prototype =
{
QueryInterface: function(iid) {
if (!iid.equals(Ci.nsIClassInfo) &&
!iid.equals(Ci.nsISupports)) {
Components.returnCode = Cr.NS_ERROR_NO_INTERFACE;
return null;
}
return this;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsISupports, Ci.nsIClassInfo]),
kCheckNotInitiated: 0, // Possible values for statusOfTorCheck.
kCheckSuccessful: 1,
......@@ -79,10 +68,8 @@ TBTorCheckService.prototype =
{
Cu.importGlobalProperties(["XMLHttpRequest"]);
let req = new XMLHttpRequest();
let prefs = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefBranch);
let url = prefs.getCharPref("extensions.torbutton.test_url");
req.open('GET', url, aAsync);
let url = Services.prefs.getCharPref("extensions.torbutton.test_url");
req.open("GET", url, aAsync);
req.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
req.overrideMimeType("text/xml");
req.timeout = 120000; // Wait at most two minutes for a response.
......@@ -140,8 +127,8 @@ TBTorCheckService.prototype =
}
return ret;
}
},
};
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
var NSGetFactory = XPCOMUtils.generateNSGetFactory([TBTorCheckService]);
......@@ -13,31 +13,25 @@ const kMODULE_NAME = "Torbutton Logger";
const kMODULE_CONTRACTID = "@torproject.org/torbutton-logger;1";
const kMODULE_CID = Components.ID("f36d72c9-9718-4134-b550-e109638331d7");
const Cr = Components.results;
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
ChromeUtils.import("resource://torbutton/modules/default-prefs.js", {}).ensureDefaultPrefs();
Cu.import("resource://torbutton/modules/default-prefs.js", {}).ensureDefaultPrefs();
Cu.import("resource://gre/modules/Services.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
function TorbuttonLogger() {
// Register observer
Services.prefs.addObserver("extensions.torbutton", this, false);
Services.prefs.addObserver("extensions.torbutton", this);
this.loglevel = Services.prefs.getIntPref("extensions.torbutton.loglevel");
this.logmethod = Services.prefs.getIntPref("extensions.torbutton.logmethod");
try {
var logMngr = Components.classes["@mozmonkey.com/debuglogger/manager;1"]
.getService(Components.interfaces.nsIDebugLoggerManager);
var logMngr = Cc["@mozmonkey.com/debuglogger/manager;1"]
.getService(Ci.nsIDebugLoggerManager);
this._debuglog = logMngr.registerLogger("torbutton");