commit a339c6ec84d612d37eb409eca1b36706a89c9486
Author: Richard Pospesel <richard(a)torproject.org>
Date: Wed Oct 23 13:43:41 2019 -0700
fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#tor
Fixes bug 32210 (hiding the tor pane when using system tor)
---
browser/components/preferences/in-content/preferences.js | 9 ++++++++-
browser/components/torpreferences/content/torCategory.inc.xul | 3 ++-
browser/components/torpreferences/content/torPane.js | 5 +++++
browser/components/torpreferences/content/torPane.xul | 3 ++-
browser/modules/TorProtocolService.jsm | 10 ++++++++++
5 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/browser/components/preferences/in-content/preferences.js b/browser/components/preferences/in-content/preferences.js
index 04e4f53b312a..9c97c33a8b2a 100644
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -93,7 +93,14 @@ function init_all() {
document.getElementById("template-paneSync").remove();
}
register_module("paneSearchResults", gSearchResultsPane);
- register_module("paneTor", gTorPane);
+ if (gTorPane.enabled) {
+ document.getElementById("category-tor").hidden = false;
+ register_module("paneTor", gTorPane);
+ } else {
+ // Remove the pane from the DOM so it doesn't get incorrectly included in search results.
+ document.getElementById("template-paneTor").remove();
+ }
+
gSearchResultsPane.init();
gMainPane.preInit();
diff --git a/browser/components/torpreferences/content/torCategory.inc.xul b/browser/components/torpreferences/content/torCategory.inc.xul
index 746059358d5f..abe56200f571 100644
--- a/browser/components/torpreferences/content/torCategory.inc.xul
+++ b/browser/components/torpreferences/content/torCategory.inc.xul
@@ -2,7 +2,8 @@
class="category"
value="paneTor"
helpTopic="prefs-tor"
- align="center">
+ align="center"
+ hidden="true">
<image class="category-icon"/>
<label id="torPreferences-labelCategory" class="category-name" flex="1" value="Tor"/>
</richlistitem>
diff --git a/browser/components/torpreferences/content/torPane.js b/browser/components/torpreferences/content/torPane.js
index 08de0613e1d4..334155e91a59 100644
--- a/browser/components/torpreferences/content/torPane.js
+++ b/browser/components/torpreferences/content/torPane.js
@@ -478,6 +478,11 @@ const gTorPane = (function() {
this._populateXUL();
},
+ // whether the page should be present in about:preferences
+ get enabled() {
+ return TorProtocolService.ownsTorDaemon;
+ },
+
//
// Callbacks
//
diff --git a/browser/components/torpreferences/content/torPane.xul b/browser/components/torpreferences/content/torPane.xul
index b384ce9f9489..5d8451554eb9 100644
--- a/browser/components/torpreferences/content/torPane.xul
+++ b/browser/components/torpreferences/content/torPane.xul
@@ -2,7 +2,7 @@
<script type="application/javascript"
src="chrome://browser/content/torpreferences/torPane.js"/>
-
+<html:template id="template-paneTor">
<hbox id="torPreferencesCategory"
class="subcategory"
hidden="true"
@@ -117,3 +117,4 @@
<button id="torPreferences-buttonTorLogs" class="torMarginFix" oncommand="gTorPane.onViewTorLogs();"/>
</hbox>
</groupbox>
+</html:template>
\ No newline at end of file
diff --git a/browser/modules/TorProtocolService.jsm b/browser/modules/TorProtocolService.jsm
index 48ae2e14ec64..b4e6ed9a3253 100644
--- a/browser/modules/TorProtocolService.jsm
+++ b/browser/modules/TorProtocolService.jsm
@@ -2,10 +2,15 @@
var EXPORTED_SYMBOLS = ["TorProtocolService"];
+const { TorLauncherUtil } = ChromeUtils.import(
+ "resource://torlauncher/modules/tl-util.jsm"
+);
+
var TorProtocolService = {
_tlps: Cc["@torproject.org/torlauncher-protocol-service;1"].getService(
Ci.nsISupports
).wrappedJSObject,
+
// maintain a map of tor settings set by Tor Browser so that we don't
// repeatedly set the same key/values over and over
// this map contains string keys to primitive or array values
@@ -199,4 +204,9 @@ var TorProtocolService = {
let torLog = this._tlps.TorGetLog(countObj);
return torLog;
},
+
+ // true if we launched and control tor, false if using system tor
+ get ownsTorDaemon() {
+ return TorLauncherUtil.shouldStartAndOwnTor;
+ },
};