Pier Angelo Vendrame pushed to branch tor-browser-102.12.0esr-12.5-1 at The Tor Project / Applications / Tor Browser
Commits:
-
0d458af9
by Henry Wilkes at 2023-06-14T10:18:34+01:00
3 changed files:
- browser/components/torpreferences/content/builtinBridgeDialog.jsm
- browser/components/torpreferences/content/connectionPane.js
- browser/components/torpreferences/content/provideBridgeDialog.jsm
Changes:
... | ... | @@ -26,6 +26,7 @@ class BuiltinBridgeDialog { |
26 | 26 | constructor(onSubmit) {
|
27 | 27 | this._onSubmit_ = onSubmit;
|
28 | 28 | this._acceptButton = null;
|
29 | + this._radioGroup = null;
|
|
29 | 30 | }
|
30 | 31 | |
31 | 32 | _populateXUL(window, dialog) {
|
... | ... | @@ -36,7 +37,7 @@ class BuiltinBridgeDialog { |
36 | 37 | "#torPreferences-builtinBridge-description"
|
37 | 38 | ).textContent = TorStrings.settings.builtinBridgeDescription2;
|
38 | 39 | |
39 | - const radioGroup = dialog.querySelector(
|
|
40 | + this._radioGroup = dialog.querySelector(
|
|
40 | 41 | "#torPreferences-builtinBridge-typeSelection"
|
41 | 42 | );
|
42 | 43 | |
... | ... | @@ -60,13 +61,8 @@ class BuiltinBridgeDialog { |
60 | 61 | TorSettings.bridges.source == TorBridgeSource.BuiltIn
|
61 | 62 | ? TorSettings.bridges.builtin_type
|
62 | 63 | : null;
|
63 | - if (currentBuiltinType) {
|
|
64 | - radioGroup.value = currentBuiltinType;
|
|
65 | - } else {
|
|
66 | - radioGroup.selectedItem = null;
|
|
67 | - }
|
|
68 | 64 | |
69 | - for (const optionEl of radioGroup.querySelectorAll(
|
|
65 | + for (const optionEl of this._radioGroup.querySelectorAll(
|
|
70 | 66 | ".builtin-bridges-option"
|
71 | 67 | )) {
|
72 | 68 | const radio = optionEl.querySelector("radio");
|
... | ... | @@ -85,8 +81,15 @@ class BuiltinBridgeDialog { |
85 | 81 | );
|
86 | 82 | }
|
87 | 83 | |
84 | + if (currentBuiltinType) {
|
|
85 | + this._radioGroup.value = currentBuiltinType;
|
|
86 | + } else {
|
|
87 | + this._radioGroup.selectedItem = null;
|
|
88 | + }
|
|
89 | + |
|
90 | + this._radioGroup.addEventListener("select", () => this.onSelectChange());
|
|
88 | 91 | dialog.addEventListener("dialogaccept", () => {
|
89 | - this.onSubmit(radioGroup.value, TorConnect.canBeginBootstrap);
|
|
92 | + this.onSubmit(this._radioGroup.value, TorConnect.canBeginBootstrap);
|
|
90 | 93 | });
|
91 | 94 | dialog.addEventListener("dialoghelp", e => {
|
92 | 95 | window.top.openTrustedLinkIn(
|
... | ... | @@ -102,9 +105,15 @@ class BuiltinBridgeDialog { |
102 | 105 | this._acceptButton = dialog.getButton("accept");
|
103 | 106 | |
104 | 107 | Services.obs.addObserver(this, TorConnectTopics.StateChange);
|
108 | + |
|
109 | + this.onSelectChange();
|
|
105 | 110 | this.onAcceptStateChange();
|
106 | 111 | }
|
107 | 112 | |
113 | + onSelectChange() {
|
|
114 | + this._acceptButton.disabled = !this._radioGroup.value;
|
|
115 | + }
|
|
116 | + |
|
108 | 117 | onAcceptStateChange() {
|
109 | 118 | this._acceptButton.setAttribute(
|
110 | 119 | "label",
|
... | ... | @@ -1088,14 +1088,9 @@ const gConnectionPane = (function() { |
1088 | 1088 | onAddBuiltinBridge() {
|
1089 | 1089 | const builtinBridgeDialog = new BuiltinBridgeDialog(
|
1090 | 1090 | (bridgeType, connect) => {
|
1091 | - if (!bridgeType) {
|
|
1092 | - TorSettings.bridges.enabled = false;
|
|
1093 | - TorSettings.bridges.builtin_type = "";
|
|
1094 | - } else {
|
|
1095 | - TorSettings.bridges.enabled = true;
|
|
1096 | - TorSettings.bridges.source = TorBridgeSource.BuiltIn;
|
|
1097 | - TorSettings.bridges.builtin_type = bridgeType;
|
|
1098 | - }
|
|
1091 | + TorSettings.bridges.enabled = true;
|
|
1092 | + TorSettings.bridges.source = TorBridgeSource.BuiltIn;
|
|
1093 | + TorSettings.bridges.builtin_type = bridgeType;
|
|
1099 | 1094 | |
1100 | 1095 | this.saveBridgeSettings(connect);
|
1101 | 1096 | }
|
... | ... | @@ -1124,15 +1119,9 @@ const gConnectionPane = (function() { |
1124 | 1119 | onAddBridgeManually() {
|
1125 | 1120 | const provideBridgeDialog = new ProvideBridgeDialog(
|
1126 | 1121 | (aBridgeString, connect) => {
|
1127 | - if (aBridgeString) {
|
|
1128 | - TorSettings.bridges.enabled = true;
|
|
1129 | - TorSettings.bridges.source = TorBridgeSource.UserProvided;
|
|
1130 | - TorSettings.bridges.bridge_strings = aBridgeString;
|
|
1131 | - } else {
|
|
1132 | - TorSettings.bridges.enabled = false;
|
|
1133 | - TorSettings.bridges.source = TorBridgeSource.Invalid;
|
|
1134 | - TorSettings.bridges.bridge_strings = "";
|
|
1135 | - }
|
|
1122 | + TorSettings.bridges.enabled = true;
|
|
1123 | + TorSettings.bridges.source = TorBridgeSource.UserProvided;
|
|
1124 | + TorSettings.bridges.bridge_strings = aBridgeString;
|
|
1136 | 1125 | |
1137 | 1126 | this.saveBridgeSettings(connect);
|
1138 | 1127 | }
|
... | ... | @@ -56,32 +56,35 @@ class ProvideBridgeDialog { |
56 | 56 | "placeholder",
|
57 | 57 | TorStrings.settings.provideBridgePlaceholder
|
58 | 58 | );
|
59 | - this._textarea.addEventListener("input", () => {
|
|
60 | - this.onAcceptStateChange();
|
|
61 | - });
|
|
59 | + |
|
60 | + this._textarea.addEventListener("input", () => this.onValueChange());
|
|
62 | 61 | if (TorSettings.bridges.source == TorBridgeSource.UserProvided) {
|
63 | 62 | this._textarea.value = TorSettings.bridges.bridge_strings.join("\n");
|
64 | 63 | }
|
65 | 64 | |
66 | 65 | this._dialog.addEventListener("dialogaccept", e => {
|
67 | - let value = this._textarea.value;
|
|
68 | - if (!value.trim()) {
|
|
69 | - value = null;
|
|
70 | - }
|
|
71 | - this.onSubmit(value, value && TorConnect.canBeginBootstrap);
|
|
66 | + this.onSubmit(this._textarea.value, TorConnect.canBeginBootstrap);
|
|
72 | 67 | });
|
73 | 68 | this._dialog.addEventListener("dialoghelp", openHelp);
|
74 | 69 | |
75 | 70 | this._acceptButton = this._dialog.getButton("accept");
|
76 | 71 | |
77 | 72 | Services.obs.addObserver(this, TorConnectTopics.StateChange);
|
73 | + |
|
74 | + this.onValueChange();
|
|
78 | 75 | this.onAcceptStateChange();
|
79 | 76 | }
|
80 | 77 | |
78 | + onValueChange() {
|
|
79 | + // TODO: Do some proper value parsing and error reporting. See
|
|
80 | + // tor-browser#40552.
|
|
81 | + this._acceptButton.disabled = !this._textarea.value.trim();
|
|
82 | + }
|
|
83 | + |
|
81 | 84 | onAcceptStateChange() {
|
82 | 85 | this._acceptButton.setAttribute(
|
83 | 86 | "label",
|
84 | - this._textarea.value.trim() && TorConnect.canBeginBootstrap
|
|
87 | + TorConnect.canBeginBootstrap
|
|
85 | 88 | ? TorStrings.settings.bridgeButtonConnect
|
86 | 89 | : TorStrings.settings.bridgeButtonAccept
|
87 | 90 | );
|