[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-102.10.0esr-12.5-1] 2 commits: fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in...

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Mon Apr 17 14:47:14 UTC 2023



Pier Angelo Vendrame pushed to branch tor-browser-102.10.0esr-12.5-1 at The Tor Project / Applications / Tor Browser


Commits:
d2c3dcac by Henry Wilkes at 2023-04-17T15:10:44+01:00
fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#connection

Bug 41617 - Tidy up:

- Lint builtinBridgeDialog.jsm and connectionPane.js.
- Use TorConnect.canBeginBootstrap.
- Always start Bootstrapping with the built in bridges, regardless of a
  previous errors.
- Wait until settings have been applied before starting bootstrap.
- Use new string ids for the new strings. Mark the old ones for removal.
- Clean up unused properties.

- - - - -
64ea04a6 by Henry Wilkes at 2023-04-17T15:23:13+01:00
fixup! Add TorStrings module for localization

Bug 41617 - Tidy up:

- Use new string ids for the new strings. Mark the old ones for removal.
- Use "website" rather than "web site".

- - - - -


4 changed files:

- browser/components/torpreferences/content/builtinBridgeDialog.jsm
- browser/components/torpreferences/content/connectionPane.js
- browser/modules/TorStrings.jsm
- toolkit/torbutton/chrome/locale/en-US/settings.properties


Changes:

=====================================
browser/components/torpreferences/content/builtinBridgeDialog.jsm
=====================================
@@ -1,35 +1,30 @@
 "use strict";
 
-const obs = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
-
 var EXPORTED_SYMBOLS = ["BuiltinBridgeDialog"];
 
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 const { TorStrings } = ChromeUtils.import("resource:///modules/TorStrings.jsm");
 
 const {
   TorSettings,
-  TorSettingsTopics,
   TorBridgeSource,
   TorBuiltinBridgeTypes,
 } = ChromeUtils.import("resource:///modules/TorSettings.jsm");
 
-const {
-  TorConnect,
-  TorConnectTopics,
-  TorConnectState,
-} = ChromeUtils.import("resource:///modules/TorConnect.jsm");
+const { TorConnect, TorConnectTopics } = ChromeUtils.import(
+  "resource:///modules/TorConnect.jsm"
+);
 
 class BuiltinBridgeDialog {
   constructor(onSubmit) {
     this.onSubmit = onSubmit;
     this._dialog = null;
-    this._window = null;
     this._acceptButton = null;
   }
 
   static get selectors() {
     return {
-      header: "#torPreferences-builtinBridge-header",
       description: "#torPreferences-builtinBridge-description",
       radiogroup: "#torPreferences-builtinBridge-typeSelection",
       obfsRadio: "#torPreferences-builtinBridges-radioObfs",
@@ -38,22 +33,20 @@ class BuiltinBridgeDialog {
       snowflakeDescr: "#torPreferences-builtinBridges-descrSnowflake",
       meekAzureRadio: "#torPreferences-builtinBridges-radioMeekAzure",
       meekAzureDescr: "#torPreferences-builtinBridges-descrMeekAzure",
-      acceptButton: "accept" /* not really a selector but a key for dialog's getButton */,
     };
   }
 
   _populateXUL(window, aDialog) {
     const selectors = BuiltinBridgeDialog.selectors;
 
-    this._window = window;
     this._dialog = aDialog;
     const dialogWin = this._dialog.parentElement;
     dialogWin.setAttribute("title", TorStrings.settings.builtinBridgeHeader);
 
     this._dialog.querySelector(selectors.description).textContent =
-      TorStrings.settings.builtinBridgeDescription;
+      TorStrings.settings.builtinBridgeDescription2;
 
-    this._acceptButton = this._dialog.getButton(selectors.acceptButton);
+    this._acceptButton = this._dialog.getButton("accept");
     this.onTorStateChange();
 
     let radioGroup = this._dialog.querySelector(selectors.radiogroup);
@@ -63,19 +56,19 @@ class BuiltinBridgeDialog {
         elemRadio: this._dialog.querySelector(selectors.obfsRadio),
         elemDescr: this._dialog.querySelector(selectors.obfsDescr),
         label: TorStrings.settings.builtinBridgeObfs4Title,
-        descr: TorStrings.settings.builtinBridgeObfs4Description,
+        descr: TorStrings.settings.builtinBridgeObfs4Description2,
       },
       snowflake: {
         elemRadio: this._dialog.querySelector(selectors.snowflakeRadio),
         elemDescr: this._dialog.querySelector(selectors.snowflakeDescr),
         label: TorStrings.settings.builtinBridgeSnowflake,
-        descr: TorStrings.settings.builtinBridgeSnowflakeDescription,
+        descr: TorStrings.settings.builtinBridgeSnowflakeDescription2,
       },
       "meek-azure": {
         elemRadio: this._dialog.querySelector(selectors.meekAzureRadio),
         elemDescr: this._dialog.querySelector(selectors.meekAzureDescr),
         label: TorStrings.settings.builtinBridgeMeekAzure,
-        descr: TorStrings.settings.builtinBridgeMeekAzureDescription,
+        descr: TorStrings.settings.builtinBridgeMeekAzureDescription2,
       },
     };
 
@@ -96,8 +89,8 @@ class BuiltinBridgeDialog {
       radioGroup.selectedItem = null;
     }
 
-    this._dialog.addEventListener("dialogaccept", e => {
-      this.onSubmit(radioGroup.value);
+    this._dialog.addEventListener("dialogaccept", () => {
+      this.onSubmit(radioGroup.value, TorConnect.canBeginBootstrap);
     });
     this._dialog.addEventListener("dialoghelp", e => {
       window.top.openTrustedLinkIn(
@@ -110,14 +103,20 @@ class BuiltinBridgeDialog {
     this._dialog.style.minWidth = "0";
     this._dialog.style.minHeight = "0";
 
-    obs.addObserver(this, TorConnectTopics.StateChange);
+    Services.obs.addObserver(this, TorConnectTopics.StateChange);
   }
 
   onTorStateChange() {
-    if (TorConnect.state === TorConnectState.Configuring) {
-      this._acceptButton.setAttribute("label", TorStrings.settings.bridgeButtonConnect);
+    if (TorConnect.canBeginBootstrap) {
+      this._acceptButton.setAttribute(
+        "label",
+        TorStrings.settings.bridgeButtonConnect
+      );
     } else {
-      this._acceptButton.setAttribute("label", TorStrings.settings.bridgeButtonAccept);
+      this._acceptButton.setAttribute(
+        "label",
+        TorStrings.settings.bridgeButtonAccept
+      );
     }
   }
 
@@ -130,25 +129,26 @@ class BuiltinBridgeDialog {
 
   observe(subject, topic, data) {
     switch (topic) {
-      case TorConnectTopics.StateChange: {
+      case TorConnectTopics.StateChange:
         this.onTorStateChange();
         break;
-      }
     }
   }
 
   close() {
     // unregister our observer topics
-    obs.removeObserver(this, TorConnectTopics.StateChange);
+    Services.obs.removeObserver(this, TorConnectTopics.StateChange);
   }
 
   openDialog(gSubDialog) {
     gSubDialog.open(
       "chrome://browser/content/torpreferences/builtinBridgeDialog.xhtml",
-      { features: "resizable=yes",
+      {
+        features: "resizable=yes",
         closingCallback: () => {
           this.close();
-        },},
+        },
+      },
       this
     );
   }


=====================================
browser/components/torpreferences/content/connectionPane.js
=====================================
@@ -323,7 +323,7 @@ const gConnectionPane = (function() {
       prefpane.querySelector(selectors.bridges.header).innerText =
         TorStrings.settings.bridgesHeading;
       prefpane.querySelector(selectors.bridges.description).textContent =
-        TorStrings.settings.bridgesDescription;
+        TorStrings.settings.bridgesDescription2;
       {
         const learnMore = prefpane.querySelector(selectors.bridges.learnMore);
         learnMore.setAttribute("value", TorStrings.settings.learnMore);
@@ -424,7 +424,8 @@ const gConnectionPane = (function() {
         selectors.bridges.currentHeader
       );
       bridgeHeader.textContent = TorStrings.settings.bridgeCurrent;
-      prefpane.querySelector(selectors.bridges.switchLabel).textContent = TorStrings.settings.allBridgesEnabled;
+      prefpane.querySelector(selectors.bridges.switchLabel).textContent =
+        TorStrings.settings.allBridgesEnabled;
       const bridgeSwitch = prefpane.querySelector(selectors.bridges.switch);
       bridgeSwitch.addEventListener("change", () => {
         TorSettings.bridges.enabled = bridgeSwitch.checked;
@@ -887,34 +888,34 @@ const gConnectionPane = (function() {
         });
       }
 
-      {
-        this._confirmBridgeRemoval = () => {
-          const aParentWindow = Services.wm.getMostRecentWindow("navigator:browser");
-
-          const ps = Services.prompt;
-          const btnFlags =
-            ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING +
-            ps.BUTTON_POS_0_DEFAULT +
-            ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL;
-
-          const notUsed = { value: false };
-          const btnIndex = ps.confirmEx(
-            aParentWindow,
-            TorStrings.settings.bridgeRemoveAllDialogTitle,
-            TorStrings.settings.bridgeRemoveAllDialogDescription,
-            btnFlags,
-            TorStrings.settings.remove,
-            null,
-            null,
-            null,
-            notUsed
-          );
+      this._confirmBridgeRemoval = () => {
+        const aParentWindow = Services.wm.getMostRecentWindow(
+          "navigator:browser"
+        );
 
-          if (btnIndex === 0) {
-            this.onRemoveAllBridges();
-          }
-        };
-      }
+        const ps = Services.prompt;
+        const btnFlags =
+          ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING +
+          ps.BUTTON_POS_0_DEFAULT +
+          ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL;
+
+        const notUsed = { value: false };
+        const btnIndex = ps.confirmEx(
+          aParentWindow,
+          TorStrings.settings.bridgeRemoveAllDialogTitle,
+          TorStrings.settings.bridgeRemoveAllDialogDescription,
+          btnFlags,
+          TorStrings.settings.remove,
+          null,
+          null,
+          null,
+          notUsed
+        );
+
+        if (btnIndex === 0) {
+          this.onRemoveAllBridges();
+        }
+      };
 
       // Advanced setup
       prefpane.querySelector(selectors.advanced.header).innerText =
@@ -1058,25 +1059,41 @@ const gConnectionPane = (function() {
     },
 
     onAddBuiltinBridge() {
-      const builtinBridgeDialog = new BuiltinBridgeDialog(aBridgeType => {
-        if (!aBridgeType) {
-          TorSettings.bridges.enabled = false;
-          TorSettings.bridges.builtin_type = "";
-        } else {
-          TorSettings.bridges.enabled = true;
-          TorSettings.bridges.source = TorBridgeSource.BuiltIn;
-          TorSettings.bridges.builtin_type = aBridgeType;
-        }
-        TorSettings.saveToPrefs();
-        TorSettings.applySettings().then(result => {
+      const builtinBridgeDialog = new BuiltinBridgeDialog(
+        async (bridgeType, connect) => {
+          if (!bridgeType) {
+            TorSettings.bridges.enabled = false;
+            TorSettings.bridges.builtin_type = "";
+          } else {
+            TorSettings.bridges.enabled = true;
+            TorSettings.bridges.source = TorBridgeSource.BuiltIn;
+            TorSettings.bridges.builtin_type = bridgeType;
+          }
+          TorSettings.saveToPrefs();
+          await TorSettings.applySettings();
+
           this._populateBridgeCards();
-        });
-        // The bridge dialog button is "connect" when Tor is not bootstrapped,
-        // so do the connect
-        if (TorConnect.state == TorConnectState.Configuring) {
-          TorConnect.openTorConnect({ beginBootstrap: true })
+
+          // The bridge dialog button is "connect" when Tor is not bootstrapped,
+          // so do the connect.
+          if (connect) {
+            // Start Bootstrapping, which should use the configured bridges.
+            // NOTE: We do this regardless of any previous TorConnect Error.
+            if (TorConnect.canBeginBootstrap) {
+              TorConnect.beginBootstrap();
+            }
+            // Open "about:torconnect".
+            // FIXME: If there has been a previous bootstrapping error then
+            // "about:torconnect" will be trying to get the user to use
+            // AutoBootstrapping. It is not set up to handle a forced direct
+            // entry to plain Bootstrapping from this dialog so the UI will not
+            // be aligned. In particular the
+            // AboutTorConnect.uiState.bootstrapCause will be aligned to
+            // whatever was shown previously in "about:torconnect" instead.
+            TorConnect.openTorConnect();
+          }
         }
-      });
+      );
       builtinBridgeDialog.openDialog(gSubDialog);
     },
 


=====================================
browser/modules/TorStrings.jsm
=====================================
@@ -94,7 +94,7 @@ const Loader = {
       quickstartCheckbox: "Always connect automatically",
       // Bridge settings
       bridgesHeading: "Bridges",
-      bridgesDescription:
+      bridgesDescription2:
         "Bridges help you securely access the Tor Network in places where Tor is blocked. Depending on where you are, one bridge may work better than another.",
       bridgeLocation: "Your location",
       bridgeLocationAutomatic: "Automatic",
@@ -116,7 +116,8 @@ const Loader = {
       allBridgesEnabled: "Use current bridges",
       bridgeRemoveAll: "Remove All Bridges",
       bridgeRemoveAllDialogTitle: "Remove all bridges?",
-      bridgeRemoveAllDialogDescription: "If these bridges were received from torproject.org or added manually, this action cannot be undone",
+      bridgeRemoveAllDialogDescription:
+        "If these bridges were received from torproject.org or added manually, this action cannot be undone",
       bridgeAdd: "Add a New Bridge",
       bridgeSelectBrowserBuiltin:
         "Choose from one of Tor Browser’s built-in bridges",
@@ -138,20 +139,18 @@ const Loader = {
       // Scan bridge QR dialog
       scanQrTitle: "Scan the QR code",
       // Builtin bridges dialog
-      builtinBridgeTitle: "Built-In Bridges",
       builtinBridgeHeader: "Select a Built-In Bridge",
-      builtinBridgeDescription:
+      builtinBridgeDescription2:
         "Tor Browser includes some specific types of bridges known as “pluggable transports”, which can help conceal the fact you’re using Tor.",
-      builtinBridgeObfs4: "obfs4",
       builtinBridgeObfs4Title: "obfs4 (Built-in)",
-      builtinBridgeObfs4Description:
+      builtinBridgeObfs4Description2:
         "Makes your Tor traffic look like random data. May not work in heavily censored regions.",
       builtinBridgeSnowflake: "Snowflake",
-      builtinBridgeSnowflakeDescription:
+      builtinBridgeSnowflakeDescription2:
         "Routes your connection through Snowflake proxies to make it look like you’re placing a video call, for example.",
       builtinBridgeMeekAzure: "meek-azure",
-      builtinBridgeMeekAzureDescription:
-        "Makes it look like you’re connected to a Microsoft web site, instead of using Tor. May work in heavily censored regions, but is usually very slow.",
+      builtinBridgeMeekAzureDescription2:
+        "Makes it look like you’re connected to a Microsoft website, instead of using Tor. May work in heavily censored regions, but is usually very slow.",
       bridgeButtonConnect: "Connect",
       bridgeButtonAccept: "OK",
       // Request bridges dialog


=====================================
toolkit/torbutton/chrome/locale/en-US/settings.properties
=====================================
@@ -26,7 +26,9 @@ settings.quickstartCheckbox=Always connect automatically
 
 # Bridge settings
 settings.bridgesHeading=Bridges
-settings.bridgesDescription=Bridges help you securely access the Tor Network in places where Tor is blocked. Depending on where you are, one bridge may work better than another.
+# Old description used up to 12.0 - TODO: remove when 12.5 becomes stable:
+settings.bridgesDescription=Bridges help you access the Tor Network in places where Tor is blocked. Depending on where you are, one bridge may work better than another.
+settings.bridgesDescription2=Bridges help you securely access the Tor Network in places where Tor is blocked. Depending on where you are, one bridge may work better than another.
 settings.bridgeLocation=Your location
 settings.bridgeLocationAutomatic=Automatic
 settings.bridgeLocationFrequent=Frequently selected locations
@@ -72,20 +74,26 @@ settings.cancel=Cancel
 settings.scanQrTitle=Scan the QR code
 
 # Builtin bridges dialog
-settings.builtinBridgeTitle=Built-In Bridges
-# Bug 41617: Todo - delete builtinBridgeHeader, no longer user
 settings.builtinBridgeHeader=Select a Built-In Bridge
-settings.builtinBridgeDescription=Tor Browser includes some specific types of bridges known as “pluggable transports”, which can help conceal the fact you’re using Tor.
-settings.builtinBridgeObfs4=obfs4
+settings.builtinBridgeDescription2=Tor Browser includes some specific types of bridges known as “pluggable transports”, which can help conceal the fact you’re using Tor.
 settings.builtinBridgeObfs4Title=obfs4 (Built-in)
-settings.builtinBridgeObfs4Description=Makes your Tor traffic look like random data. May not work in heavily censored regions.
+settings.builtinBridgeObfs4Description2=Makes your Tor traffic look like random data. May not work in heavily censored regions.
 settings.builtinBridgeSnowflake=Snowflake
-settings.builtinBridgeSnowflakeDescription=Routes your connection through Snowflake proxies to make it look like you’re placing a video call, for example.
+settings.builtinBridgeSnowflakeDescription2=Routes your connection through Snowflake proxies to make it look like you’re placing a video call, for example.
 settings.builtinBridgeMeekAzure=meek-azure
-settings.builtinBridgeMeekAzureDescription=Makes it look like you’re connected to a Microsoft web site, instead of using Tor. May work in heavily censored regions, but is usually very slow.
+settings.builtinBridgeMeekAzureDescription2=Makes it look like you’re connected to a Microsoft website, instead of using Tor. May work in heavily censored regions, but is usually very slow.
 settings.bridgeButtonConnect=Connect
 settings.bridgeButtonAccept=OK
 
+# Old dialog strings used up to 12.0 - TODO: remove when 12.5 becomes stable:
+settings.builtinBridgeTitle=Built-In Bridges
+settings.builtinBridgeDescription=Tor Browser includes some specific types of bridges known as “pluggable transports”.
+settings.builtinBridgeObfs4=obfs4
+settings.builtinBridgeObfs4Description=obfs4 is a type of built-in bridge that makes your Tor traffic look random. They are also less likely to be blocked than their predecessors, obfs3 bridges.
+settings.builtinBridgeSnowflakeDescription=Snowflake is a built-in bridge that defeats censorship by routing your connection through Snowflake proxies, ran by volunteers.
+settings.builtinBridgeMeekAzureDescription=meek-azure is a built-in bridge that makes it look like you are using a Microsoft web site instead of using Tor.
+# end
+
 # Request bridges dialog
 settings.requestBridgeDialogTitle=Request Bridge
 settings.submitCaptcha=Submit



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/f0df6486ac9dc44ee4706e8ea3956a9f4668b85b...64ea04a6aff7c15c457817b998224da0e8289bcf

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/f0df6486ac9dc44ee4706e8ea3956a9f4668b85b...64ea04a6aff7c15c457817b998224da0e8289bcf
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20230417/eafade6b/attachment-0001.htm>


More information about the tor-commits mailing list