Skip to content
Snippets Groups Projects
Verified Commit 88d31abc authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

fixup! Bug 10760: Integrate TorButton to TorBrowser core

Linted
parent ba6566ab
Branches
Tags
1 merge request!694Bug 41796: Rebased on top of FIREFOX_ESR_115_BASE
......@@ -136,7 +136,7 @@
//onLoad Handler
try {
window.addEventListener("load", torbutton_init, false);
window.addEventListener("load", torbutton_init);
} catch (e) {}
window.addEventListener("MozBeforeInitialXULLayout",
......
......
......@@ -115,8 +115,9 @@ var AboutTorListener = {
onLocaleChange() {
// Set localized "Get Involved" link.
content.document.getElementById("getInvolvedLink").href =
`https://community.torproject.org/${getLocale()}`;
content.document.getElementById(
"getInvolvedLink"
).href = `https://community.torproject.org/${getLocale()}`;
// Display the Tor Browser product name and version.
try {
......
......
File changed. Contains only whitespace changes. Show whitespace changes.
......@@ -181,14 +181,10 @@ var torbutton_new_circuit;
m_tb_wasinited = true;
// Bug 1506 P4: These vars are very important for New Identity
var environ = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
if (environ.exists("TOR_CONTROL_PASSWD")) {
m_tb_control_pass = environ.get("TOR_CONTROL_PASSWD");
} else if (environ.exists("TOR_CONTROL_COOKIE_AUTH_FILE")) {
var cookie_path = environ.get("TOR_CONTROL_COOKIE_AUTH_FILE");
if (Services.env.exists("TOR_CONTROL_PASSWD")) {
m_tb_control_pass = Services.env.get("TOR_CONTROL_PASSWD");
} else if (Services.env.exists("TOR_CONTROL_COOKIE_AUTH_FILE")) {
var cookie_path = Services.env.get("TOR_CONTROL_COOKIE_AUTH_FILE");
try {
if ("" != cookie_path) {
m_tb_control_pass = torbutton_read_authentication_cookie(cookie_path);
......@@ -211,8 +207,8 @@ var torbutton_new_circuit;
} catch (e) {}
if (!m_tb_control_ipc_file) {
if (environ.exists("TOR_CONTROL_PORT")) {
m_tb_control_port = environ.get("TOR_CONTROL_PORT");
if (Services.env.exists("TOR_CONTROL_PORT")) {
m_tb_control_port = Services.env.get("TOR_CONTROL_PORT");
} else {
try {
const kTLControlPortPref = "extensions.torlauncher.control_port";
......@@ -224,8 +220,8 @@ var torbutton_new_circuit;
}
}
if (environ.exists("TOR_CONTROL_HOST")) {
m_tb_control_host = environ.get("TOR_CONTROL_HOST");
if (Services.env.exists("TOR_CONTROL_HOST")) {
m_tb_control_host = Services.env.get("TOR_CONTROL_HOST");
} else {
try {
const kTLControlHostPref = "extensions.torlauncher.control_host";
......@@ -419,13 +415,10 @@ var torbutton_new_circuit;
// perform a check via the control port.
const kEnvSkipControlPortTest = "TOR_SKIP_CONTROLPORTTEST";
const kEnvUseTransparentProxy = "TOR_TRANSPROXY";
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
if (
(m_tb_control_ipc_file || m_tb_control_port) &&
!env.exists(kEnvUseTransparentProxy) &&
!env.exists(kEnvSkipControlPortTest) &&
!Services.env.exists(kEnvUseTransparentProxy) &&
!Services.env.exists(kEnvSkipControlPortTest) &&
m_tb_prefs.getBoolPref("extensions.torbutton.local_tor_check")
) {
if (await torbutton_local_tor_check()) {
......
......
......@@ -18,8 +18,9 @@ XPCOMUtils.defineLazyModuleGetters(this, {
});
// Make the logger available.
let logger = Cc["@torproject.org/torbutton-logger;1"].getService(Ci.nsISupports)
.wrappedJSObject;
let logger = Cc["@torproject.org/torbutton-logger;1"].getService(
Ci.nsISupports
).wrappedJSObject;
// Import crypto object (FF 37+).
Cu.importGlobalProperties(["crypto"]);
......@@ -266,7 +267,7 @@ DomainIsolator.prototype = {
* @param {string} firstPartyDomain - The domain to lookup credentials for.
* @param {integer} userContextId - The ID for the user context.
*
* @return {{ username: string, password: string }?} - The SOCKS credentials,
* @returns {{ username: string, password: string }?} - The SOCKS credentials,
* or null if none are found.
*/
getSocksProxyCredentials(firstPartyDomain, userContextId) {
......
......
......@@ -57,14 +57,14 @@ function StartupObserver() {
this._prefs = Services.prefs;
this.logger.log(3, "Startup Observer created");
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
var prefName = "browser.startup.homepage";
if (env.exists("TOR_DEFAULT_HOMEPAGE")) {
if (Services.env.exists("TOR_DEFAULT_HOMEPAGE")) {
// if the user has set this value in a previous installation, don't override it
if (!this._prefs.prefHasUserValue(prefName)) {
this._prefs.setCharPref(prefName, env.get("TOR_DEFAULT_HOMEPAGE"));
this._prefs.setCharPref(
prefName,
Services.env.get("TOR_DEFAULT_HOMEPAGE")
);
}
}
......@@ -95,10 +95,7 @@ StartupObserver.prototype = {
}
// Bug 1506: Still want to get these env vars
let environ = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
if (environ.exists("TOR_TRANSPROXY")) {
if (Services.env.exists("TOR_TRANSPROXY")) {
this.logger.log(3, "Resetting Tor settings to transproxy");
this._prefs.setBoolPref("network.proxy.socks_remote_dns", false);
this._prefs.setIntPref("network.proxy.type", 0);
......@@ -118,16 +115,16 @@ StartupObserver.prototype = {
socksPortInfo = { ipcFile: undefined, host: undefined, port: 0 };
let isWindows = Services.appinfo.OS === "WINNT";
if (!isWindows && environ.exists("TOR_SOCKS_IPC_PATH")) {
if (!isWindows && Services.env.exists("TOR_SOCKS_IPC_PATH")) {
socksPortInfo.ipcFile = new FileUtils.File(
environ.get("TOR_SOCKS_IPC_PATH")
Services.env.get("TOR_SOCKS_IPC_PATH")
);
} else {
if (environ.exists("TOR_SOCKS_HOST")) {
socksPortInfo.host = environ.get("TOR_SOCKS_HOST");
if (Services.env.exists("TOR_SOCKS_HOST")) {
socksPortInfo.host = Services.env.get("TOR_SOCKS_HOST");
}
if (environ.exists("TOR_SOCKS_PORT")) {
socksPortInfo.port = parseInt(environ.get("TOR_SOCKS_PORT"));
if (Services.env.exists("TOR_SOCKS_PORT")) {
socksPortInfo.port = parseInt(Services.env.get("TOR_SOCKS_PORT"));
}
}
}
......
......
......@@ -39,8 +39,9 @@ const TorTopics = Object.freeze({
// __log__.
// Logging function
let logger = Cc["@torproject.org/torbutton-logger;1"].getService(Ci.nsISupports)
.wrappedJSObject;
let logger = Cc["@torproject.org/torbutton-logger;1"].getService(
Ci.nsISupports
).wrappedJSObject;
let log = x => logger.eclog(3, x.trimRight().replace(/\r\n/g, "\n"));
// ### announce this file
......
......
......@@ -75,16 +75,10 @@ var observe = function(topic, callback) {
// ## Environment variables
// __env__.
// Provides access to process environment variables.
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
// __getEnv(name)__.
// Reads the environment variable of the given name.
var getEnv = function (name) {
return env.exists(name) ? env.get(name) : undefined;
return Services.env.exists(name) ? Services.env.get(name) : undefined;
};
// __getLocale
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment