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

Commits:

4 changed files:

Changes:

  • mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java
    ... ... @@ -46,6 +46,11 @@ public class TorIntegrationAndroid implements BundleEventListener {
    46 46
         private static final String EVENT_TOR_STOP = "GeckoView:Tor:StopTor";
    
    47 47
         private static final String EVENT_MEEK_START = "GeckoView:Tor:StartMeek";
    
    48 48
         private static final String EVENT_MEEK_STOP = "GeckoView:Tor:StopMeek";
    
    49
    +    private static final String EVENT_BOOTSTRAP_STATE_CHANGED = "GeckoView:Tor:BootstrapStateChanged";
    
    50
    +    private static final String EVENT_BOOTSTRAP_PROGRESS = "GeckoView:Tor:BootstrapProgress";
    
    51
    +    private static final String EVENT_BOOTSTRAP_COMPLETE = "GeckoView:Tor:BootstrapComplete";
    
    52
    +    private static final String EVENT_BOOTSTRAP_ERROR = "GeckoView:Tor:BootstrapError";
    
    53
    +    private static final String EVENT_SETTINGS_OPEN = "GeckoView:Tor:OpenSettings";
    
    49 54
     
    
    50 55
         // Events we emit
    
    51 56
         private static final String EVENT_SETTINGS_GET = "GeckoView:Tor:SettingsGet";
    
    ... ... @@ -106,7 +111,12 @@ public class TorIntegrationAndroid implements BundleEventListener {
    106 111
                             EVENT_TOR_START,
    
    107 112
                             EVENT_MEEK_START,
    
    108 113
                             EVENT_MEEK_STOP,
    
    109
    -                        EVENT_SETTINGS_READY);
    
    114
    +                        EVENT_SETTINGS_READY,
    
    115
    +                        EVENT_BOOTSTRAP_STATE_CHANGED,
    
    116
    +                        EVENT_BOOTSTRAP_PROGRESS,
    
    117
    +                        EVENT_BOOTSTRAP_COMPLETE,
    
    118
    +                        EVENT_BOOTSTRAP_ERROR,
    
    119
    +                        EVENT_SETTINGS_OPEN);
    
    110 120
         }
    
    111 121
     
    
    112 122
         @Override // BundleEventListener
    
    ... ... @@ -122,6 +132,32 @@ public class TorIntegrationAndroid implements BundleEventListener {
    122 132
                 stopMeek(message, callback);
    
    123 133
             } else if (EVENT_SETTINGS_READY.equals(event)) {
    
    124 134
                 loadSettings(message);
    
    135
    +        } else if (EVENT_BOOTSTRAP_STATE_CHANGED.equals(event)) {
    
    136
    +            String state = message.getString("state");
    
    137
    +            for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
    
    138
    +                listener.onBootstrapStateChange(state);
    
    139
    +            }
    
    140
    +        } else if (EVENT_BOOTSTRAP_PROGRESS.equals(event)) {
    
    141
    +            double progress = message.getDouble("progress");
    
    142
    +            String status = message.getString("status");
    
    143
    +            boolean hasWarnings = message.getBoolean("hasWarnings");
    
    144
    +            for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
    
    145
    +                listener.onBootstrapProgress(progress, status, hasWarnings);
    
    146
    +            }
    
    147
    +        } else if (EVENT_BOOTSTRAP_COMPLETE.equals(event)) {
    
    148
    +            for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
    
    149
    +                listener.onBootstrapComplete();
    
    150
    +            }
    
    151
    +        } else if (EVENT_BOOTSTRAP_ERROR.equals(event)) {
    
    152
    +            String msg = message.getString("message");
    
    153
    +            String details = message.getString("details");
    
    154
    +            for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
    
    155
    +                listener.onBootstrapError(msg, details);
    
    156
    +            }
    
    157
    +        } else if (EVENT_SETTINGS_OPEN.equals(event)) {
    
    158
    +            for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
    
    159
    +                listener.onSettingsRequested();
    
    160
    +            }
    
    125 161
             }
    
    126 162
         }
    
    127 163
     
    
    ... ... @@ -467,17 +503,12 @@ public class TorIntegrationAndroid implements BundleEventListener {
    467 503
             }
    
    468 504
         }
    
    469 505
     
    
    470
    -    public static class BootstrapState {
    
    471
    -        // FIXME: We can do better than this :)
    
    472
    -        public GeckoBundle mBundle;
    
    473
    -
    
    474
    -        BootstrapState(GeckoBundle bundle) {
    
    475
    -            mBundle = bundle;
    
    476
    -        }
    
    477
    -    }
    
    478
    -
    
    479 506
         public interface BootstrapStateChangeListener {
    
    480
    -        void onBootstrapStateChange(BootstrapState state);
    
    507
    +        void onBootstrapStateChange(String state);
    
    508
    +        void onBootstrapProgress(double progress, String status, boolean hasWarnings);
    
    509
    +        void onBootstrapComplete();
    
    510
    +        void onBootstrapError(String message, String details);
    
    511
    +        void onSettingsRequested();
    
    481 512
         }
    
    482 513
     
    
    483 514
         public @NonNull GeckoResult<GeckoBundle> getSettings() {
    
    ... ... @@ -514,16 +545,6 @@ public class TorIntegrationAndroid implements BundleEventListener {
    514 545
             return EventDispatcher.getInstance().queryVoid(EVENT_BOOTSTRAP_CANCEL);
    
    515 546
         }
    
    516 547
     
    
    517
    -    public @NonNull GeckoResult<BootstrapState> getBootstrapState() {
    
    518
    -        return EventDispatcher.getInstance().queryBundle(EVENT_BOOTSTRAP_GET_STATE).map(new GeckoResult.OnValueMapper<>() {
    
    519
    -            @AnyThread
    
    520
    -            @Nullable
    
    521
    -            public BootstrapState onValue(@Nullable GeckoBundle value) throws Throwable {
    
    522
    -                return new BootstrapState(value);
    
    523
    -            }
    
    524
    -        });
    
    525
    -    }
    
    526
    -
    
    527 548
         public void registerBootstrapStateChangeListener(BootstrapStateChangeListener listener) {
    
    528 549
             mBootstrapStateListeners.add(listener);
    
    529 550
         }
    

  • toolkit/components/tor-launcher/TorProvider.sys.mjs
    ... ... @@ -875,10 +875,7 @@ export class TorProvider {
    875 875
        */
    
    876 876
       #processBootstrapStatus(statusObj, isNotification) {
    
    877 877
         // Notify observers
    
    878
    -    Services.obs.notifyObservers(
    
    879
    -      { wrappedJSObject: statusObj },
    
    880
    -      TorProviderTopics.BootstrapStatus
    
    881
    -    );
    
    878
    +    Services.obs.notifyObservers(statusObj, TorProviderTopics.BootstrapStatus);
    
    882 879
     
    
    883 880
         if (statusObj.PROGRESS === 100) {
    
    884 881
           this.#isBootstrapDone = true;
    

  • toolkit/modules/TorAndroidIntegration.sys.mjs
    ... ... @@ -25,9 +25,13 @@ const logger = new ConsoleAPI({
    25 25
       prefix: "TorAndroidIntegration",
    
    26 26
     });
    
    27 27
     
    
    28
    -const EmittedEvents = Object.freeze( {
    
    28
    +const EmittedEvents = Object.freeze({
    
    29 29
       settingsReady: "GeckoView:Tor:SettingsReady",
    
    30 30
       settingsChanged: "GeckoView:Tor:SettingsChanged",
    
    31
    +  bootstrapStateChanged: "GeckoView:Tor:BootstrapStateChanged",
    
    32
    +  bootstrapProgress: "GeckoView:Tor:BootstrapProgress",
    
    33
    +  bootstrapComplete: "GeckoView:Tor:BootstrapComplete",
    
    34
    +  bootstrapError: "GeckoView:Tor:BootstrapError",
    
    31 35
     });
    
    32 36
     
    
    33 37
     const ListenedEvents = Object.freeze({
    
    ... ... @@ -89,6 +93,30 @@ class TorAndroidIntegrationImpl {
    89 93
             }
    
    90 94
             break;
    
    91 95
           case lazy.TorConnectTopics.StateChange:
    
    96
    +        lazy.EventDispatcher.instance.sendRequest({
    
    97
    +          type: EmittedEvents.bootstrapStateChanged,
    
    98
    +          state: subj.wrappedJSObject.state ?? "",
    
    99
    +        });
    
    100
    +        break;
    
    101
    +      case lazy.TorConnectTopics.BootstrapProgress:
    
    102
    +        lazy.EventDispatcher.instance.sendRequest({
    
    103
    +          type: EmittedEvents.bootstrapProgress,
    
    104
    +          progress: subj.wrappedJSObject.progress ?? "",
    
    105
    +          status: subj.wrappedJSObject.status ?? 0,
    
    106
    +          hasWarnings: subj.wrappedJSObject.hasWarnings ?? false,
    
    107
    +        });
    
    108
    +        break;
    
    109
    +      case lazy.TorConnectTopics.BootstrapComplete:
    
    110
    +        lazy.EventDispatcher.instance.sendRequest({
    
    111
    +          type: EmittedEvents.bootstrapComplete,
    
    112
    +        });
    
    113
    +        break;
    
    114
    +      case lazy.TorConnectTopics.BootstrapError:
    
    115
    +        lazy.EventDispatcher.instance.sendRequest({
    
    116
    +          type: EmittedEvents.bootstrapError,
    
    117
    +          message: subj.wrappedJSObject.message ?? "",
    
    118
    +          details: subj.wrappedJSObject.details ?? "",
    
    119
    +        });
    
    92 120
             break;
    
    93 121
           case lazy.TorSettingsTopics.Ready:
    
    94 122
             lazy.EventDispatcher.instance.sendRequest({
    

  • toolkit/modules/TorConnect.sys.mjs
    ... ... @@ -7,6 +7,7 @@ import { setTimeout, clearTimeout } from "resource://gre/modules/Timer.sys.mjs";
    7 7
     const lazy = {};
    
    8 8
     
    
    9 9
     ChromeUtils.defineESModuleGetters(lazy, {
    
    10
    +  EventDispatcher: "resource://gre/modules/Messaging.sys.mjs",
    
    10 11
       MoatRPC: "resource://gre/modules/Moat.sys.mjs",
    
    11 12
       TorBootstrapRequest: "resource://gre/modules/TorBootstrapRequest.sys.mjs",
    
    12 13
     });
    
    ... ... @@ -1092,6 +1093,12 @@ export const TorConnect = (() => {
    1092 1093
             Further external commands and helper methods
    
    1093 1094
             */
    
    1094 1095
         openTorPreferences() {
    
    1096
    +      if (TorLauncherUtil.isAndroid) {
    
    1097
    +        lazy.EventDispatcher.instance.sendRequest({
    
    1098
    +          type: "GeckoView:Tor:OpenSettings",
    
    1099
    +        });
    
    1100
    +        return;
    
    1101
    +      }
    
    1095 1102
           const win = lazy.BrowserWindowTracker.getTopWindow();
    
    1096 1103
           win.switchToTabHavingURI("about:preferences#connection", true);
    
    1097 1104
         },