richard pushed to branch tor-browser-115.7.0esr-13.5-1 at The Tor Project / Applications / Tor Browser
Commits:
-
bb028644
by Pier Angelo Vendrame at 2024-01-26T11:31:15+01:00
-
a48e4389
by Pier Angelo Vendrame at 2024-01-26T11:35:10+01:00
4 changed files:
- mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java
- toolkit/modules/TorAndroidIntegration.sys.mjs
- toolkit/modules/TorConnect.sys.mjs
- toolkit/modules/TorSettings.sys.mjs
Changes:
| ... | ... | @@ -47,6 +47,8 @@ public class TorIntegrationAndroid implements BundleEventListener { |
| 47 | 47 | private static final String EVENT_BOOTSTRAP_COMPLETE = "GeckoView:Tor:BootstrapComplete";
|
| 48 | 48 | private static final String EVENT_BOOTSTRAP_ERROR = "GeckoView:Tor:BootstrapError";
|
| 49 | 49 | private static final String EVENT_SETTINGS_OPEN = "GeckoView:Tor:OpenSettings";
|
| 50 | + private static final String EVENT_SETTINGS_READY = "GeckoView:Tor:SettingsReady";
|
|
| 51 | + private static final String EVENT_SETTINGS_CHANGED = "GeckoView:Tor:SettingsChanged";
|
|
| 50 | 52 | |
| 51 | 53 | // Events we emit
|
| 52 | 54 | private static final String EVENT_SETTINGS_GET = "GeckoView:Tor:SettingsGet";
|
| ... | ... | @@ -57,7 +59,6 @@ public class TorIntegrationAndroid implements BundleEventListener { |
| 57 | 59 | private static final String EVENT_BOOTSTRAP_BEGIN_AUTO = "GeckoView:Tor:BootstrapBeginAuto";
|
| 58 | 60 | private static final String EVENT_BOOTSTRAP_CANCEL = "GeckoView:Tor:BootstrapCancel";
|
| 59 | 61 | private static final String EVENT_BOOTSTRAP_GET_STATE = "GeckoView:Tor:BootstrapGetState";
|
| 60 | - private static final String EVENT_SETTINGS_READY = "GeckoView:Tor:SettingsReady";
|
|
| 61 | 62 | |
| 62 | 63 | private static final String CONTROL_PORT_FILE = "/control-ipc";
|
| 63 | 64 | private static final String SOCKS_FILE = "/socks-ipc";
|
| ... | ... | @@ -112,6 +113,7 @@ public class TorIntegrationAndroid implements BundleEventListener { |
| 112 | 113 | EVENT_MEEK_START,
|
| 113 | 114 | EVENT_MEEK_STOP,
|
| 114 | 115 | EVENT_SETTINGS_READY,
|
| 116 | + EVENT_SETTINGS_CHANGED,
|
|
| 115 | 117 | EVENT_BOOTSTRAP_STATE_CHANGED,
|
| 116 | 118 | EVENT_BOOTSTRAP_PROGRESS,
|
| 117 | 119 | EVENT_BOOTSTRAP_COMPLETE,
|
| ... | ... | @@ -136,6 +138,14 @@ public class TorIntegrationAndroid implements BundleEventListener { |
| 136 | 138 | } catch(Exception e) {
|
| 137 | 139 | Log.e(TAG, "SettingsLoader error: "+ e.toString());
|
| 138 | 140 | }
|
| 141 | + } else if (EVENT_SETTINGS_CHANGED.equals(event)) {
|
|
| 142 | + GeckoBundle newSettings = message.getBundle("settings");
|
|
| 143 | + if (newSettings != null) {
|
|
| 144 | + // TODO: Should we notify listeners?
|
|
| 145 | + mSettings = new TorSettings(newSettings);
|
|
| 146 | + } else {
|
|
| 147 | + Log.w(TAG, "Ignoring a settings changed event that did not have the new settings.");
|
|
| 148 | + }
|
|
| 139 | 149 | } else if (EVENT_BOOTSTRAP_STATE_CHANGED.equals(event)) {
|
| 140 | 150 | String state = message.getString("state");
|
| 141 | 151 | for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
|
| ... | ... | @@ -124,6 +124,15 @@ class TorAndroidIntegrationImpl { |
| 124 | 124 | settings: lazy.TorSettings.getSettings(),
|
| 125 | 125 | });
|
| 126 | 126 | break;
|
| 127 | + case lazy.TorSettingsTopics.SettingsChanged:
|
|
| 128 | + // For Android we push also the settings object to avoid a round trip on
|
|
| 129 | + // the event dispatcher.
|
|
| 130 | + lazy.EventDispatcher.instance.sendRequest({
|
|
| 131 | + type: EmittedEvents.settingsChanged,
|
|
| 132 | + changes: subj.wrappedJSObject.changes ?? [],
|
|
| 133 | + settings: lazy.TorSettings.getSettings(),
|
|
| 134 | + });
|
|
| 135 | + break;
|
|
| 127 | 136 | }
|
| 128 | 137 | }
|
| 129 | 138 |
| ... | ... | @@ -878,10 +878,11 @@ export const TorConnect = (() => { |
| 878 | 878 | console.log(`TorConnect: Observing topic '${addTopic}'`);
|
| 879 | 879 | };
|
| 880 | 880 | |
| 881 | + TorSettings.initializedPromise.then(() => this._settingsInitialized());
|
|
| 882 | + |
|
| 881 | 883 | // register the Tor topics we always care about
|
| 882 | 884 | observeTopic(TorTopics.ProcessExited);
|
| 883 | 885 | observeTopic(TorTopics.LogHasWarnOrErr);
|
| 884 | - observeTopic(TorSettingsTopics.Ready);
|
|
| 885 | 886 | }
|
| 886 | 887 | },
|
| 887 | 888 | |
| ... | ... | @@ -889,29 +890,6 @@ export const TorConnect = (() => { |
| 889 | 890 | console.log(`TorConnect: Observed ${topic}`);
|
| 890 | 891 | |
| 891 | 892 | switch (topic) {
|
| 892 | - /* We need to wait until TorSettings have been loaded and applied before we can Quickstart */
|
|
| 893 | - case TorSettingsTopics.Ready: {
|
|
| 894 | - // tor-browser#41907: This is only a workaround to avoid users being
|
|
| 895 | - // bounced back to the initial panel without any explanation.
|
|
| 896 | - // Longer term we should disable the clickable elements, or find a UX
|
|
| 897 | - // to prevent this from happening (e.g., allow buttons to be clicked,
|
|
| 898 | - // but show an intermediate starting state, or a message that tor is
|
|
| 899 | - // starting while the butons are disabled, etc...).
|
|
| 900 | - if (this.state !== TorConnectState.Initial) {
|
|
| 901 | - console.warn(
|
|
| 902 | - "TorConnect: Seen the torsettings:ready after the state has already changed, ignoring the notification."
|
|
| 903 | - );
|
|
| 904 | - break;
|
|
| 905 | - }
|
|
| 906 | - if (this.shouldQuickStart) {
|
|
| 907 | - // Quickstart
|
|
| 908 | - this._changeState(TorConnectState.Bootstrapping);
|
|
| 909 | - } else {
|
|
| 910 | - // Configuring
|
|
| 911 | - this._changeState(TorConnectState.Configuring);
|
|
| 912 | - }
|
|
| 913 | - break;
|
|
| 914 | - }
|
|
| 915 | 893 | case TorTopics.LogHasWarnOrErr: {
|
| 916 | 894 | this._logHasWarningOrError = true;
|
| 917 | 895 | break;
|
| ... | ... | @@ -941,6 +919,28 @@ export const TorConnect = (() => { |
| 941 | 919 | }
|
| 942 | 920 | },
|
| 943 | 921 | |
| 922 | + _settingsInitialized() {
|
|
| 923 | + // tor-browser#41907: This is only a workaround to avoid users being
|
|
| 924 | + // bounced back to the initial panel without any explanation.
|
|
| 925 | + // Longer term we should disable the clickable elements, or find a UX
|
|
| 926 | + // to prevent this from happening (e.g., allow buttons to be clicked,
|
|
| 927 | + // but show an intermediate starting state, or a message that tor is
|
|
| 928 | + // starting while the butons are disabled, etc...).
|
|
| 929 | + if (this.state !== TorConnectState.Initial) {
|
|
| 930 | + console.warn(
|
|
| 931 | + "TorConnect: Seen the torsettings:ready after the state has already changed, ignoring the notification."
|
|
| 932 | + );
|
|
| 933 | + return;
|
|
| 934 | + }
|
|
| 935 | + if (this.shouldQuickStart) {
|
|
| 936 | + // Quickstart
|
|
| 937 | + this._changeState(TorConnectState.Bootstrapping);
|
|
| 938 | + } else {
|
|
| 939 | + // Configuring
|
|
| 940 | + this._changeState(TorConnectState.Configuring);
|
|
| 941 | + }
|
|
| 942 | + },
|
|
| 943 | + |
|
| 944 | 944 | /*
|
| 945 | 945 | Various getters
|
| 946 | 946 | */
|
| ... | ... | @@ -992,6 +992,10 @@ class TorSettingsImpl { |
| 992 | 992 | // Hold off on lots of notifications until all settings are changed.
|
| 993 | 993 | this.freezeNotifications();
|
| 994 | 994 | try {
|
| 995 | + if ("quickstart" in settings) {
|
|
| 996 | + this.quickstart.enabled = !!settings.quickstart.enabled;
|
|
| 997 | + }
|
|
| 998 | + |
|
| 995 | 999 | if ("bridges" in settings) {
|
| 996 | 1000 | this.bridges.enabled = !!settings.bridges.enabled;
|
| 997 | 1001 | // Currently, disabling bridges in the UI does not remove the lines,
|