clairehurst pushed to branch tor-browser-158.0a1-17.0-2 at The Tor Project / Applications / Tor Browser

Commits:

5 changed files:

Changes:

  • mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
    ... ... @@ -2874,8 +2874,13 @@ public class GeckoSession {
    2874 2874
        * @return The circuit information as a {@link GeckoResult} object.
    
    2875 2875
        */
    
    2876 2876
       @AnyThread
    
    2877
    -  public @NonNull GeckoResult<GeckoBundle> getTorCircuits() {
    
    2878
    -    return mEventDispatcher.queryBundle("GeckoView:GetTorCircuits");
    
    2877
    +  public @NonNull GeckoResult<JSONObject> getTorCircuits() {
    
    2878
    +    return mEventDispatcher.queryString("GeckoView:GetTorCircuits").map(value -> {
    
    2879
    +      if (value == null) {
    
    2880
    +        return null;
    
    2881
    +      }
    
    2882
    +      return new JSONObject(value);
    
    2883
    +    });
    
    2879 2884
       }
    
    2880 2885
     
    
    2881 2886
       /**
    

  • mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorAndroidIntegration.java
    ... ... @@ -47,6 +47,7 @@ public class TorAndroidIntegration implements BundleEventListener {
    47 47
       private static final String EVENT_SETTINGS_READY = "GeckoView:Tor:SettingsReady";
    
    48 48
       private static final String EVENT_SETTINGS_CHANGED = "GeckoView:Tor:SettingsChanged";
    
    49 49
       private static final String EVENT_SECURITY_LEVEL_CUSTOM = "GeckoView:Tor:SecurityLevelCustom";
    
    50
    +  private static final String EVENT_TOR_CIRCUIT_CHANGE = "GeckoView:Tor:TorCircuitChange";
    
    50 51
     
    
    51 52
       // Events we emit
    
    52 53
       private static final String EVENT_SECURITY_LEVEL_GET = "GeckoView:Tor:SecurityLevelGet";
    
    ... ... @@ -132,6 +133,7 @@ public class TorAndroidIntegration implements BundleEventListener {
    132 133
                 EVENT_SETTINGS_READY,
    
    133 134
                 EVENT_SETTINGS_CHANGED,
    
    134 135
                 EVENT_SECURITY_LEVEL_CUSTOM,
    
    136
    +            EVENT_TOR_CIRCUIT_CHANGE,
    
    135 137
                 EVENT_CONNECT_STAGE_CHANGED,
    
    136 138
                 EVENT_BOOTSTRAP_PROGRESS,
    
    137 139
                 EVENT_TOR_LOGS);
    
    ... ... @@ -176,6 +178,10 @@ public class TorAndroidIntegration implements BundleEventListener {
    176 178
           } else {
    
    177 179
             _isTorSecurityLevelCustom.setValue(new CustomSecurityLevelNotificationObject(false, null));
    
    178 180
           }
    
    181
    +    } else if (EVENT_TOR_CIRCUIT_CHANGE.equals(event)) {
    
    182
    +      for (TorCircuitChangeListener listener : new HashSet<TorCircuitChangeListener>(mTorCircuitChangeListeners)) {
    
    183
    +        listener.onTorCircuitChange();
    
    184
    +      }
    
    179 185
         } else if (EVENT_CONNECT_STAGE_CHANGED.equals(event)) {
    
    180 186
           TorConnectStage stage = new TorConnectStage(message.getBundle("stage"));
    
    181 187
           _lastKnownStage.setValue(stage);
    
    ... ... @@ -651,6 +657,10 @@ public class TorAndroidIntegration implements BundleEventListener {
    651 657
         }
    
    652 658
       }
    
    653 659
     
    
    660
    +  public interface TorCircuitChangeListener {
    
    661
    +    void onTorCircuitChange();
    
    662
    +  }
    
    663
    +
    
    654 664
       public interface BootstrapStateChangeListener {
    
    655 665
         void onBootstrapStageChange(@NonNull TorConnectStage stage); // new upgrade
    
    656 666
     
    
    ... ... @@ -781,6 +791,16 @@ public class TorAndroidIntegration implements BundleEventListener {
    781 791
         return EventDispatcher.getInstance().queryVoid(EVENT_BOOTSTRAP_CANCEL);
    
    782 792
       }
    
    783 793
     
    
    794
    +  public synchronized void registerTorCircuitChangeListener(TorCircuitChangeListener listener) {
    
    795
    +    mTorCircuitChangeListeners.add(listener);
    
    796
    +  }
    
    797
    +
    
    798
    +  public synchronized void unregisterTorCircuitChangeListener(TorCircuitChangeListener listener) {
    
    799
    +    mTorCircuitChangeListeners.remove(listener);
    
    800
    +  }
    
    801
    +
    
    802
    +  private final HashSet<TorCircuitChangeListener> mTorCircuitChangeListeners = new HashSet<>();
    
    803
    +
    
    784 804
       public synchronized void registerBootstrapStateChangeListener(BootstrapStateChangeListener listener) {
    
    785 805
         mBootstrapStateListeners.add(listener);
    
    786 806
       }
    

  • mobile/shared/modules/geckoview/GeckoViewContent.sys.mjs
    ... ... @@ -32,7 +32,7 @@ export class GeckoViewContent extends GeckoViewModule {
    32 32
           "GeckoView:GetWebCompatInfo",
    
    33 33
           "GeckoView:SendGleanBrokenSiteReport",
    
    34 34
           "GeckoView:SendMoreWebCompatInfo",
    
    35
    -      "GeckoView:GetTorCircuit",
    
    35
    +      "GeckoView:GetTorCircuits",
    
    36 36
           "GeckoView:NewTorCircuit",
    
    37 37
         ]);
    
    38 38
       }
    
    ... ... @@ -509,7 +509,7 @@ export class GeckoViewContent extends GeckoViewModule {
    509 509
             domain,
    
    510 510
             this.browser.contentPrincipal.originAttributes.userContextId
    
    511 511
           );
    
    512
    -      aCallback?.onSuccess({ domain, circuits });
    
    512
    +      aCallback?.onSuccess(JSON.stringify({ domain, circuits }));
    
    513 513
         } else {
    
    514 514
           aCallback?.onSuccess(null);
    
    515 515
         }
    

  • toolkit/components/tor-launcher/TorDomainIsolator.sys.mjs
    ... ... @@ -47,7 +47,7 @@ const NON_TOR_PROXY_PREF = "extensions.torbutton.use_nontor_proxy";
    47 47
     // The topic of new identity, to observe to cleanup all the nonces.
    
    48 48
     const NEW_IDENTITY_TOPIC = "new-identity-requested";
    
    49 49
     
    
    50
    -// The topic on which we broacast circuit change notifications.
    
    50
    +// The topic on which we broadcast circuit change notifications.
    
    51 51
     const TOR_CIRCUIT_TOPIC = "TorCircuitChange";
    
    52 52
     
    
    53 53
     // We have an interval to delete circuits that are not reclaimed by any browser.
    

  • toolkit/modules/TorAndroidIntegration.sys.mjs
    ... ... @@ -19,6 +19,13 @@ ChromeUtils.defineESModuleGetters(lazy, {
    19 19
         "moz-src:///toolkit/components/securitylevel/SecurityLevel.sys.mjs",
    
    20 20
     });
    
    21 21
     
    
    22
    +/**
    
    23
    + * The topic on which circuit changes are broadcast.
    
    24
    + *
    
    25
    + * @type {string}
    
    26
    + */
    
    27
    +const TOR_CIRCUIT_TOPIC = "TorCircuitChange";
    
    28
    +
    
    22 29
     const Prefs = Object.freeze({
    
    23 30
       logLevel: "browser.tor_android.log_level",
    
    24 31
     });
    
    ... ... @@ -31,6 +38,7 @@ const logger = console.createInstance({
    31 38
     const EmittedEvents = Object.freeze({
    
    32 39
       settingsReady: "GeckoView:Tor:SettingsReady",
    
    33 40
       settingsChanged: "GeckoView:Tor:SettingsChanged",
    
    41
    +  torCircuitChange: "GeckoView:Tor:TorCircuitChange",
    
    34 42
       connectStageChanged: "GeckoView:Tor:ConnectStageChanged",
    
    35 43
       bootstrapProgress: "GeckoView:Tor:BootstrapProgress",
    
    36 44
       bootstrapComplete: "GeckoView:Tor:BootstrapComplete",
    
    ... ... @@ -89,6 +97,8 @@ class TorAndroidIntegrationImpl {
    89 97
           Services.obs.addObserver(this, lazy.TorSettingsTopics[topic]);
    
    90 98
         }
    
    91 99
     
    
    100
    +    Services.obs.addObserver(this, TOR_CIRCUIT_TOPIC);
    
    101
    +
    
    92 102
         // Match the initialisation order from desktop's TorStartupService.
    
    93 103
         lazy.TorSettings.init().catch(error => {
    
    94 104
           logger.error("Cannot initailize TorSettings", error);
    
    ... ... @@ -159,6 +169,12 @@ class TorAndroidIntegrationImpl {
    159 169
               }
    
    160 170
             );
    
    161 171
             break;
    
    172
    +      case TOR_CIRCUIT_TOPIC:
    
    173
    +        lazy.EventDispatcher.instance.sendRequest(
    
    174
    +          EmittedEvents.torCircuitChange,
    
    175
    +          {}
    
    176
    +        );
    
    177
    +        break;
    
    162 178
         }
    
    163 179
       }
    
    164 180