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

Commits:

4 changed files:

Changes:

  • browser/components/torpreferences/content/builtinBridgeDialog.jsm
    1 1
     "use strict";
    
    2 2
     
    
    3
    -const obs = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
    
    4
    -
    
    5 3
     var EXPORTED_SYMBOLS = ["BuiltinBridgeDialog"];
    
    6 4
     
    
    5
    +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
    
    6
    +
    
    7 7
     const { TorStrings } = ChromeUtils.import("resource:///modules/TorStrings.jsm");
    
    8 8
     
    
    9 9
     const {
    
    10 10
       TorSettings,
    
    11
    -  TorSettingsTopics,
    
    12 11
       TorBridgeSource,
    
    13 12
       TorBuiltinBridgeTypes,
    
    14 13
     } = ChromeUtils.import("resource:///modules/TorSettings.jsm");
    
    15 14
     
    
    16
    -const {
    
    17
    -  TorConnect,
    
    18
    -  TorConnectTopics,
    
    19
    -  TorConnectState,
    
    20
    -} = ChromeUtils.import("resource:///modules/TorConnect.jsm");
    
    15
    +const { TorConnect, TorConnectTopics } = ChromeUtils.import(
    
    16
    +  "resource:///modules/TorConnect.jsm"
    
    17
    +);
    
    21 18
     
    
    22 19
     class BuiltinBridgeDialog {
    
    23 20
       constructor(onSubmit) {
    
    24 21
         this.onSubmit = onSubmit;
    
    25 22
         this._dialog = null;
    
    26
    -    this._window = null;
    
    27 23
         this._acceptButton = null;
    
    28 24
       }
    
    29 25
     
    
    30 26
       static get selectors() {
    
    31 27
         return {
    
    32
    -      header: "#torPreferences-builtinBridge-header",
    
    33 28
           description: "#torPreferences-builtinBridge-description",
    
    34 29
           radiogroup: "#torPreferences-builtinBridge-typeSelection",
    
    35 30
           obfsRadio: "#torPreferences-builtinBridges-radioObfs",
    
    ... ... @@ -38,22 +33,20 @@ class BuiltinBridgeDialog {
    38 33
           snowflakeDescr: "#torPreferences-builtinBridges-descrSnowflake",
    
    39 34
           meekAzureRadio: "#torPreferences-builtinBridges-radioMeekAzure",
    
    40 35
           meekAzureDescr: "#torPreferences-builtinBridges-descrMeekAzure",
    
    41
    -      acceptButton: "accept" /* not really a selector but a key for dialog's getButton */,
    
    42 36
         };
    
    43 37
       }
    
    44 38
     
    
    45 39
       _populateXUL(window, aDialog) {
    
    46 40
         const selectors = BuiltinBridgeDialog.selectors;
    
    47 41
     
    
    48
    -    this._window = window;
    
    49 42
         this._dialog = aDialog;
    
    50 43
         const dialogWin = this._dialog.parentElement;
    
    51 44
         dialogWin.setAttribute("title", TorStrings.settings.builtinBridgeHeader);
    
    52 45
     
    
    53 46
         this._dialog.querySelector(selectors.description).textContent =
    
    54
    -      TorStrings.settings.builtinBridgeDescription;
    
    47
    +      TorStrings.settings.builtinBridgeDescription2;
    
    55 48
     
    
    56
    -    this._acceptButton = this._dialog.getButton(selectors.acceptButton);
    
    49
    +    this._acceptButton = this._dialog.getButton("accept");
    
    57 50
         this.onTorStateChange();
    
    58 51
     
    
    59 52
         let radioGroup = this._dialog.querySelector(selectors.radiogroup);
    
    ... ... @@ -63,19 +56,19 @@ class BuiltinBridgeDialog {
    63 56
             elemRadio: this._dialog.querySelector(selectors.obfsRadio),
    
    64 57
             elemDescr: this._dialog.querySelector(selectors.obfsDescr),
    
    65 58
             label: TorStrings.settings.builtinBridgeObfs4Title,
    
    66
    -        descr: TorStrings.settings.builtinBridgeObfs4Description,
    
    59
    +        descr: TorStrings.settings.builtinBridgeObfs4Description2,
    
    67 60
           },
    
    68 61
           snowflake: {
    
    69 62
             elemRadio: this._dialog.querySelector(selectors.snowflakeRadio),
    
    70 63
             elemDescr: this._dialog.querySelector(selectors.snowflakeDescr),
    
    71 64
             label: TorStrings.settings.builtinBridgeSnowflake,
    
    72
    -        descr: TorStrings.settings.builtinBridgeSnowflakeDescription,
    
    65
    +        descr: TorStrings.settings.builtinBridgeSnowflakeDescription2,
    
    73 66
           },
    
    74 67
           "meek-azure": {
    
    75 68
             elemRadio: this._dialog.querySelector(selectors.meekAzureRadio),
    
    76 69
             elemDescr: this._dialog.querySelector(selectors.meekAzureDescr),
    
    77 70
             label: TorStrings.settings.builtinBridgeMeekAzure,
    
    78
    -        descr: TorStrings.settings.builtinBridgeMeekAzureDescription,
    
    71
    +        descr: TorStrings.settings.builtinBridgeMeekAzureDescription2,
    
    79 72
           },
    
    80 73
         };
    
    81 74
     
    
    ... ... @@ -96,8 +89,8 @@ class BuiltinBridgeDialog {
    96 89
           radioGroup.selectedItem = null;
    
    97 90
         }
    
    98 91
     
    
    99
    -    this._dialog.addEventListener("dialogaccept", e => {
    
    100
    -      this.onSubmit(radioGroup.value);
    
    92
    +    this._dialog.addEventListener("dialogaccept", () => {
    
    93
    +      this.onSubmit(radioGroup.value, TorConnect.canBeginBootstrap);
    
    101 94
         });
    
    102 95
         this._dialog.addEventListener("dialoghelp", e => {
    
    103 96
           window.top.openTrustedLinkIn(
    
    ... ... @@ -110,14 +103,20 @@ class BuiltinBridgeDialog {
    110 103
         this._dialog.style.minWidth = "0";
    
    111 104
         this._dialog.style.minHeight = "0";
    
    112 105
     
    
    113
    -    obs.addObserver(this, TorConnectTopics.StateChange);
    
    106
    +    Services.obs.addObserver(this, TorConnectTopics.StateChange);
    
    114 107
       }
    
    115 108
     
    
    116 109
       onTorStateChange() {
    
    117
    -    if (TorConnect.state === TorConnectState.Configuring) {
    
    118
    -      this._acceptButton.setAttribute("label", TorStrings.settings.bridgeButtonConnect);
    
    110
    +    if (TorConnect.canBeginBootstrap) {
    
    111
    +      this._acceptButton.setAttribute(
    
    112
    +        "label",
    
    113
    +        TorStrings.settings.bridgeButtonConnect
    
    114
    +      );
    
    119 115
         } else {
    
    120
    -      this._acceptButton.setAttribute("label", TorStrings.settings.bridgeButtonAccept);
    
    116
    +      this._acceptButton.setAttribute(
    
    117
    +        "label",
    
    118
    +        TorStrings.settings.bridgeButtonAccept
    
    119
    +      );
    
    121 120
         }
    
    122 121
       }
    
    123 122
     
    
    ... ... @@ -130,25 +129,26 @@ class BuiltinBridgeDialog {
    130 129
     
    
    131 130
       observe(subject, topic, data) {
    
    132 131
         switch (topic) {
    
    133
    -      case TorConnectTopics.StateChange: {
    
    132
    +      case TorConnectTopics.StateChange:
    
    134 133
             this.onTorStateChange();
    
    135 134
             break;
    
    136
    -      }
    
    137 135
         }
    
    138 136
       }
    
    139 137
     
    
    140 138
       close() {
    
    141 139
         // unregister our observer topics
    
    142
    -    obs.removeObserver(this, TorConnectTopics.StateChange);
    
    140
    +    Services.obs.removeObserver(this, TorConnectTopics.StateChange);
    
    143 141
       }
    
    144 142
     
    
    145 143
       openDialog(gSubDialog) {
    
    146 144
         gSubDialog.open(
    
    147 145
           "chrome://browser/content/torpreferences/builtinBridgeDialog.xhtml",
    
    148
    -      { features: "resizable=yes",
    
    146
    +      {
    
    147
    +        features: "resizable=yes",
    
    149 148
             closingCallback: () => {
    
    150 149
               this.close();
    
    151
    -        },},
    
    150
    +        },
    
    151
    +      },
    
    152 152
           this
    
    153 153
         );
    
    154 154
       }
    

  • browser/components/torpreferences/content/connectionPane.js
    ... ... @@ -323,7 +323,7 @@ const gConnectionPane = (function() {
    323 323
           prefpane.querySelector(selectors.bridges.header).innerText =
    
    324 324
             TorStrings.settings.bridgesHeading;
    
    325 325
           prefpane.querySelector(selectors.bridges.description).textContent =
    
    326
    -        TorStrings.settings.bridgesDescription;
    
    326
    +        TorStrings.settings.bridgesDescription2;
    
    327 327
           {
    
    328 328
             const learnMore = prefpane.querySelector(selectors.bridges.learnMore);
    
    329 329
             learnMore.setAttribute("value", TorStrings.settings.learnMore);
    
    ... ... @@ -424,7 +424,8 @@ const gConnectionPane = (function() {
    424 424
             selectors.bridges.currentHeader
    
    425 425
           );
    
    426 426
           bridgeHeader.textContent = TorStrings.settings.bridgeCurrent;
    
    427
    -      prefpane.querySelector(selectors.bridges.switchLabel).textContent = TorStrings.settings.allBridgesEnabled;
    
    427
    +      prefpane.querySelector(selectors.bridges.switchLabel).textContent =
    
    428
    +        TorStrings.settings.allBridgesEnabled;
    
    428 429
           const bridgeSwitch = prefpane.querySelector(selectors.bridges.switch);
    
    429 430
           bridgeSwitch.addEventListener("change", () => {
    
    430 431
             TorSettings.bridges.enabled = bridgeSwitch.checked;
    
    ... ... @@ -887,34 +888,34 @@ const gConnectionPane = (function() {
    887 888
             });
    
    888 889
           }
    
    889 890
     
    
    890
    -      {
    
    891
    -        this._confirmBridgeRemoval = () => {
    
    892
    -          const aParentWindow = Services.wm.getMostRecentWindow("navigator:browser");
    
    893
    -
    
    894
    -          const ps = Services.prompt;
    
    895
    -          const btnFlags =
    
    896
    -            ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING +
    
    897
    -            ps.BUTTON_POS_0_DEFAULT +
    
    898
    -            ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL;
    
    899
    -
    
    900
    -          const notUsed = { value: false };
    
    901
    -          const btnIndex = ps.confirmEx(
    
    902
    -            aParentWindow,
    
    903
    -            TorStrings.settings.bridgeRemoveAllDialogTitle,
    
    904
    -            TorStrings.settings.bridgeRemoveAllDialogDescription,
    
    905
    -            btnFlags,
    
    906
    -            TorStrings.settings.remove,
    
    907
    -            null,
    
    908
    -            null,
    
    909
    -            null,
    
    910
    -            notUsed
    
    911
    -          );
    
    891
    +      this._confirmBridgeRemoval = () => {
    
    892
    +        const aParentWindow = Services.wm.getMostRecentWindow(
    
    893
    +          "navigator:browser"
    
    894
    +        );
    
    912 895
     
    
    913
    -          if (btnIndex === 0) {
    
    914
    -            this.onRemoveAllBridges();
    
    915
    -          }
    
    916
    -        };
    
    917
    -      }
    
    896
    +        const ps = Services.prompt;
    
    897
    +        const btnFlags =
    
    898
    +          ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING +
    
    899
    +          ps.BUTTON_POS_0_DEFAULT +
    
    900
    +          ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL;
    
    901
    +
    
    902
    +        const notUsed = { value: false };
    
    903
    +        const btnIndex = ps.confirmEx(
    
    904
    +          aParentWindow,
    
    905
    +          TorStrings.settings.bridgeRemoveAllDialogTitle,
    
    906
    +          TorStrings.settings.bridgeRemoveAllDialogDescription,
    
    907
    +          btnFlags,
    
    908
    +          TorStrings.settings.remove,
    
    909
    +          null,
    
    910
    +          null,
    
    911
    +          null,
    
    912
    +          notUsed
    
    913
    +        );
    
    914
    +
    
    915
    +        if (btnIndex === 0) {
    
    916
    +          this.onRemoveAllBridges();
    
    917
    +        }
    
    918
    +      };
    
    918 919
     
    
    919 920
           // Advanced setup
    
    920 921
           prefpane.querySelector(selectors.advanced.header).innerText =
    
    ... ... @@ -1058,25 +1059,41 @@ const gConnectionPane = (function() {
    1058 1059
         },
    
    1059 1060
     
    
    1060 1061
         onAddBuiltinBridge() {
    
    1061
    -      const builtinBridgeDialog = new BuiltinBridgeDialog(aBridgeType => {
    
    1062
    -        if (!aBridgeType) {
    
    1063
    -          TorSettings.bridges.enabled = false;
    
    1064
    -          TorSettings.bridges.builtin_type = "";
    
    1065
    -        } else {
    
    1066
    -          TorSettings.bridges.enabled = true;
    
    1067
    -          TorSettings.bridges.source = TorBridgeSource.BuiltIn;
    
    1068
    -          TorSettings.bridges.builtin_type = aBridgeType;
    
    1069
    -        }
    
    1070
    -        TorSettings.saveToPrefs();
    
    1071
    -        TorSettings.applySettings().then(result => {
    
    1062
    +      const builtinBridgeDialog = new BuiltinBridgeDialog(
    
    1063
    +        async (bridgeType, connect) => {
    
    1064
    +          if (!bridgeType) {
    
    1065
    +            TorSettings.bridges.enabled = false;
    
    1066
    +            TorSettings.bridges.builtin_type = "";
    
    1067
    +          } else {
    
    1068
    +            TorSettings.bridges.enabled = true;
    
    1069
    +            TorSettings.bridges.source = TorBridgeSource.BuiltIn;
    
    1070
    +            TorSettings.bridges.builtin_type = bridgeType;
    
    1071
    +          }
    
    1072
    +          TorSettings.saveToPrefs();
    
    1073
    +          await TorSettings.applySettings();
    
    1074
    +
    
    1072 1075
               this._populateBridgeCards();
    
    1073
    -        });
    
    1074
    -        // The bridge dialog button is "connect" when Tor is not bootstrapped,
    
    1075
    -        // so do the connect
    
    1076
    -        if (TorConnect.state == TorConnectState.Configuring) {
    
    1077
    -          TorConnect.openTorConnect({ beginBootstrap: true })
    
    1076
    +
    
    1077
    +          // The bridge dialog button is "connect" when Tor is not bootstrapped,
    
    1078
    +          // so do the connect.
    
    1079
    +          if (connect) {
    
    1080
    +            // Start Bootstrapping, which should use the configured bridges.
    
    1081
    +            // NOTE: We do this regardless of any previous TorConnect Error.
    
    1082
    +            if (TorConnect.canBeginBootstrap) {
    
    1083
    +              TorConnect.beginBootstrap();
    
    1084
    +            }
    
    1085
    +            // Open "about:torconnect".
    
    1086
    +            // FIXME: If there has been a previous bootstrapping error then
    
    1087
    +            // "about:torconnect" will be trying to get the user to use
    
    1088
    +            // AutoBootstrapping. It is not set up to handle a forced direct
    
    1089
    +            // entry to plain Bootstrapping from this dialog so the UI will not
    
    1090
    +            // be aligned. In particular the
    
    1091
    +            // AboutTorConnect.uiState.bootstrapCause will be aligned to
    
    1092
    +            // whatever was shown previously in "about:torconnect" instead.
    
    1093
    +            TorConnect.openTorConnect();
    
    1094
    +          }
    
    1078 1095
             }
    
    1079
    -      });
    
    1096
    +      );
    
    1080 1097
           builtinBridgeDialog.openDialog(gSubDialog);
    
    1081 1098
         },
    
    1082 1099
     
    

  • browser/modules/TorStrings.jsm
    ... ... @@ -94,7 +94,7 @@ const Loader = {
    94 94
           quickstartCheckbox: "Always connect automatically",
    
    95 95
           // Bridge settings
    
    96 96
           bridgesHeading: "Bridges",
    
    97
    -      bridgesDescription:
    
    97
    +      bridgesDescription2:
    
    98 98
             "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.",
    
    99 99
           bridgeLocation: "Your location",
    
    100 100
           bridgeLocationAutomatic: "Automatic",
    
    ... ... @@ -116,7 +116,8 @@ const Loader = {
    116 116
           allBridgesEnabled: "Use current bridges",
    
    117 117
           bridgeRemoveAll: "Remove All Bridges",
    
    118 118
           bridgeRemoveAllDialogTitle: "Remove all bridges?",
    
    119
    -      bridgeRemoveAllDialogDescription: "If these bridges were received from torproject.org or added manually, this action cannot be undone",
    
    119
    +      bridgeRemoveAllDialogDescription:
    
    120
    +        "If these bridges were received from torproject.org or added manually, this action cannot be undone",
    
    120 121
           bridgeAdd: "Add a New Bridge",
    
    121 122
           bridgeSelectBrowserBuiltin:
    
    122 123
             "Choose from one of Tor Browser’s built-in bridges",
    
    ... ... @@ -138,20 +139,18 @@ const Loader = {
    138 139
           // Scan bridge QR dialog
    
    139 140
           scanQrTitle: "Scan the QR code",
    
    140 141
           // Builtin bridges dialog
    
    141
    -      builtinBridgeTitle: "Built-In Bridges",
    
    142 142
           builtinBridgeHeader: "Select a Built-In Bridge",
    
    143
    -      builtinBridgeDescription:
    
    143
    +      builtinBridgeDescription2:
    
    144 144
             "Tor Browser includes some specific types of bridges known as “pluggable transports”, which can help conceal the fact you’re using Tor.",
    
    145
    -      builtinBridgeObfs4: "obfs4",
    
    146 145
           builtinBridgeObfs4Title: "obfs4 (Built-in)",
    
    147
    -      builtinBridgeObfs4Description:
    
    146
    +      builtinBridgeObfs4Description2:
    
    148 147
             "Makes your Tor traffic look like random data. May not work in heavily censored regions.",
    
    149 148
           builtinBridgeSnowflake: "Snowflake",
    
    150
    -      builtinBridgeSnowflakeDescription:
    
    149
    +      builtinBridgeSnowflakeDescription2:
    
    151 150
             "Routes your connection through Snowflake proxies to make it look like you’re placing a video call, for example.",
    
    152 151
           builtinBridgeMeekAzure: "meek-azure",
    
    153
    -      builtinBridgeMeekAzureDescription:
    
    154
    -        "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.",
    
    152
    +      builtinBridgeMeekAzureDescription2:
    
    153
    +        "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.",
    
    155 154
           bridgeButtonConnect: "Connect",
    
    156 155
           bridgeButtonAccept: "OK",
    
    157 156
           // Request bridges dialog
    

  • toolkit/torbutton/chrome/locale/en-US/settings.properties
    ... ... @@ -26,7 +26,9 @@ settings.quickstartCheckbox=Always connect automatically
    26 26
     
    
    27 27
     # Bridge settings
    
    28 28
     settings.bridgesHeading=Bridges
    
    29
    -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.
    
    29
    +# Old description used up to 12.0 - TODO: remove when 12.5 becomes stable:
    
    30
    +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.
    
    31
    +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.
    
    30 32
     settings.bridgeLocation=Your location
    
    31 33
     settings.bridgeLocationAutomatic=Automatic
    
    32 34
     settings.bridgeLocationFrequent=Frequently selected locations
    
    ... ... @@ -72,20 +74,26 @@ settings.cancel=Cancel
    72 74
     settings.scanQrTitle=Scan the QR code
    
    73 75
     
    
    74 76
     # Builtin bridges dialog
    
    75
    -settings.builtinBridgeTitle=Built-In Bridges
    
    76
    -# Bug 41617: Todo - delete builtinBridgeHeader, no longer user
    
    77 77
     settings.builtinBridgeHeader=Select a Built-In Bridge
    
    78
    -settings.builtinBridgeDescription=Tor Browser includes some specific types of bridges known as “pluggable transports”, which can help conceal the fact you’re using Tor.
    
    79
    -settings.builtinBridgeObfs4=obfs4
    
    78
    +settings.builtinBridgeDescription2=Tor Browser includes some specific types of bridges known as “pluggable transports”, which can help conceal the fact you’re using Tor.
    
    80 79
     settings.builtinBridgeObfs4Title=obfs4 (Built-in)
    
    81
    -settings.builtinBridgeObfs4Description=Makes your Tor traffic look like random data. May not work in heavily censored regions.
    
    80
    +settings.builtinBridgeObfs4Description2=Makes your Tor traffic look like random data. May not work in heavily censored regions.
    
    82 81
     settings.builtinBridgeSnowflake=Snowflake
    
    83
    -settings.builtinBridgeSnowflakeDescription=Routes your connection through Snowflake proxies to make it look like you’re placing a video call, for example.
    
    82
    +settings.builtinBridgeSnowflakeDescription2=Routes your connection through Snowflake proxies to make it look like you’re placing a video call, for example.
    
    84 83
     settings.builtinBridgeMeekAzure=meek-azure
    
    85
    -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.
    
    84
    +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.
    
    86 85
     settings.bridgeButtonConnect=Connect
    
    87 86
     settings.bridgeButtonAccept=OK
    
    88 87
     
    
    88
    +# Old dialog strings used up to 12.0 - TODO: remove when 12.5 becomes stable:
    
    89
    +settings.builtinBridgeTitle=Built-In Bridges
    
    90
    +settings.builtinBridgeDescription=Tor Browser includes some specific types of bridges known as “pluggable transports”.
    
    91
    +settings.builtinBridgeObfs4=obfs4
    
    92
    +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.
    
    93
    +settings.builtinBridgeSnowflakeDescription=Snowflake is a built-in bridge that defeats censorship by routing your connection through Snowflake proxies, ran by volunteers.
    
    94
    +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.
    
    95
    +# end
    
    96
    +
    
    89 97
     # Request bridges dialog
    
    90 98
     settings.requestBridgeDialogTitle=Request Bridge
    
    91 99
     settings.submitCaptcha=Submit