[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-153.0esr-16.0-1] 2 commits: fixup! Tor Browser strings



Title: GitLab

henry pushed to branch tor-browser-153.0esr-16.0-1 at The Tor Project / Applications / Tor Browser

Commits:

  • 87ad933f
    by Henry Wilkes at 2026-07-30T16:37:03+00:00
    fixup! Tor Browser strings
    
    TB 45051: Add notification strings.
    
  • 1676ad67
    by Henry Wilkes at 2026-07-30T16:37:03+00:00
    TB 45051: Add an external tor provider notification.
    

4 changed files:

Changes:

  • browser/components/BrowserComponents.manifest
    ... ... @@ -64,6 +64,7 @@ category browser-window-delayed-startup resource:///modules/HomePage.sys.mjs Hom
    64 64
     category browser-window-delayed-startup moz-src:///browser/components/reportbrokensite/ReportBrokenSite.sys.mjs ReportBrokenSite.init
    
    65 65
     category browser-window-delayed-startup moz-src:///browser/components/search/SearchUIUtils.sys.mjs SearchUIUtils.init
    
    66 66
     category browser-window-delayed-startup resource:///modules/taskbartabs/TaskbarTabsPageAction.sys.mjs TaskbarTabsPageAction.init
    
    67
    +category browser-window-delayed-startup moz-src:///browser/modules/TorProviderExternalNotification.sys.mjs TorProviderExternalNotification.delayedStartup
    
    67 68
     
    
    68 69
     category browser-window-location-change chrome://browser/content/browser-places.js BookmarkingUI.onLocationChange
    
    69 70
     category browser-window-location-change chrome://browser/content/browser-sitePermissionPanel.js gPermissionPanel.onLocationChange
    
    ... ... @@ -93,6 +94,7 @@ category browser-window-unload chrome://browser/content/browser.js#CombinedStopR
    93 94
     category browser-window-unload chrome://browser/content/browser-addons.js gUnifiedExtensions.uninit
    
    94 95
     category browser-window-unload chrome://browser/content/browser.js#FirefoxViewHandler FirefoxViewHandler.uninit
    
    95 96
     category browser-window-unload moz-src:///browser/components/tabbrowser/NewTabPagePreloading.sys.mjs NewTabPagePreloading.removePreloadedBrowser
    
    97
    +category browser-window-unload moz-src:///browser/modules/TorProviderExternalNotification.sys.mjs TorProviderExternalNotification.unload
    
    96 98
     
    
    97 99
     # The category below is specific to Tabbrowser destruction. For consumers that need to uninitialize during
    
    98 100
     # window unload, use 'browser-window-unload' instead.
    

  • browser/modules/TorProviderExternalNotification.sys.mjs
    1
    +/* This Source Code Form is subject to the terms of the Mozilla Public
    
    2
    + * License, v. 2.0. If a copy of the MPL was not distributed with this
    
    3
    + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
    
    4
    +
    
    5
    +const lazy = {};
    
    6
    +
    
    7
    +ChromeUtils.defineESModuleGetters(lazy, {
    
    8
    +  BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
    
    9
    +  TorConnect: "moz-src:///toolkit/modules/TorConnect.sys.mjs",
    
    10
    +  TorProviderBuilder:
    
    11
    +    "moz-src:///toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs",
    
    12
    +  TorProviderState:
    
    13
    +    "moz-src:///toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs",
    
    14
    +  TorProviderTopics:
    
    15
    +    "moz-src:///toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs",
    
    16
    +});
    
    17
    +
    
    18
    +export const TorProviderExternalNotification = {
    
    19
    +  /**
    
    20
    +   * Whether we have been initialized.
    
    21
    +   *
    
    22
    +   * @type {boolean}
    
    23
    +   */
    
    24
    +  _initialized: false,
    
    25
    +
    
    26
    +  /**
    
    27
    +   * Callback for browser-window-delayed-startup.
    
    28
    +   *
    
    29
    +   * @param {Window} win - The browser window that was just loaded.
    
    30
    +   */
    
    31
    +  delayedStartup(win) {
    
    32
    +    if (lazy.TorConnect.enabled) {
    
    33
    +      // Let TorConnect handle the ProviderStateChanged.
    
    34
    +      return;
    
    35
    +    }
    
    36
    +
    
    37
    +    if (!this._initialized) {
    
    38
    +      this._initialized = true;
    
    39
    +      this._setProviderState(lazy.TorProviderBuilder.currentState());
    
    40
    +      Services.obs.addObserver(
    
    41
    +        this,
    
    42
    +        lazy.TorProviderTopics.ProviderStateChanged
    
    43
    +      );
    
    44
    +    } else {
    
    45
    +      // Maybe show the notification in the new window.
    
    46
    +      this._updateNotification(win);
    
    47
    +    }
    
    48
    +  },
    
    49
    +
    
    50
    +  /**
    
    51
    +   * Callback for browser-window-unload.
    
    52
    +   *
    
    53
    +   * @param {Window} win - The browser window that is being unloaded.
    
    54
    +   */
    
    55
    +  unload(win) {
    
    56
    +    if (this._notification?.window === win) {
    
    57
    +      this._notification = null;
    
    58
    +    }
    
    59
    +  },
    
    60
    +
    
    61
    +  observe(subject, topic, data) {
    
    62
    +    switch (topic) {
    
    63
    +      case lazy.TorProviderTopics.ProviderStateChanged:
    
    64
    +        this._setProviderState(data);
    
    65
    +        break;
    
    66
    +    }
    
    67
    +  },
    
    68
    +
    
    69
    +  /**
    
    70
    +   * The last seen `TorProviderState` state.
    
    71
    +   *
    
    72
    +   * @type {?string}
    
    73
    +   */
    
    74
    +  _providerState: null,
    
    75
    +
    
    76
    +  /**
    
    77
    +   * Set the provider state.
    
    78
    +   *
    
    79
    +   * @param {string} state - The `TorProviderState` state we are now in.
    
    80
    +   */
    
    81
    +  _setProviderState(state) {
    
    82
    +    if (this._providerState === state) {
    
    83
    +      // No change, ignore.
    
    84
    +      return;
    
    85
    +    }
    
    86
    +
    
    87
    +    this._providerState = state;
    
    88
    +    // A new instance of a provider, so ignore any previously dismissed
    
    89
    +    // notifications.
    
    90
    +    this._notificationUserDismissed = false;
    
    91
    +    this._updateNotification();
    
    92
    +  },
    
    93
    +
    
    94
    +  /**
    
    95
    +   * The notification that is currently shown.
    
    96
    +   *
    
    97
    +   * @type {?{ window: Window, elementPromise: Promise<NotificationMessage> }}
    
    98
    +   */
    
    99
    +  _notification: null,
    
    100
    +  /**
    
    101
    +   * Whether the user has dismissed the notification for the current TorProvider
    
    102
    +   * instance.
    
    103
    +   *
    
    104
    +   * @type {boolean}
    
    105
    +   */
    
    106
    +  _notificationUserDismissed: false,
    
    107
    +
    
    108
    +  /**
    
    109
    +   * Update the notification depending on the latest `TorProviderState`.
    
    110
    +   *
    
    111
    +   * @param {Window} [win] - A newly opened browser window to maybe show the
    
    112
    +   *   notification in. If not given, the notification might be shown in the
    
    113
    +   *   current top window.
    
    114
    +   */
    
    115
    +  _updateNotification(win) {
    
    116
    +    if (this._providerState === lazy.TorProviderState.Starting) {
    
    117
    +      this._updateNotificationButton(
    
    118
    +        "tor-external-process-error-retry-button-retrying"
    
    119
    +      );
    
    120
    +      return;
    
    121
    +    }
    
    122
    +
    
    123
    +    if (this._providerState === lazy.TorProviderState.Running) {
    
    124
    +      if (this._notification) {
    
    125
    +        // If there is a notification, close it.
    
    126
    +        const { elementPromise } = this._notification;
    
    127
    +        this._notification = null;
    
    128
    +        elementPromise.then(el => el.remove());
    
    129
    +      }
    
    130
    +      return;
    
    131
    +    }
    
    132
    +    // Else, _providerState is TorProviderState.Stopped.
    
    133
    +
    
    134
    +    if (this._notificationUserDismissed) {
    
    135
    +      // User has already dismissed this in a different window.
    
    136
    +      return;
    
    137
    +    }
    
    138
    +
    
    139
    +    if (this._notification) {
    
    140
    +      // Already showing.
    
    141
    +      this._updateNotificationButton("tor-external-process-error-retry-button");
    
    142
    +      return;
    
    143
    +    }
    
    144
    +
    
    145
    +    if (!win) {
    
    146
    +      win = lazy.BrowserWindowTracker.getTopWindow();
    
    147
    +      if (!win) {
    
    148
    +        // Wait for a window.
    
    149
    +        return;
    
    150
    +      }
    
    151
    +    }
    
    152
    +
    
    153
    +    const buttons = [
    
    154
    +      {
    
    155
    +        supportPage: "tor-manual:get-in-touch__bug-or-feedback",
    
    156
    +      },
    
    157
    +      {
    
    158
    +        "l10n-id": "tor-external-process-error-retry-button",
    
    159
    +        callback: () => {
    
    160
    +          if (this._providerState === lazy.TorProviderState.Stopped) {
    
    161
    +            lazy.TorProviderBuilder.replace();
    
    162
    +          }
    
    163
    +          // Keep open.
    
    164
    +          return true;
    
    165
    +        },
    
    166
    +      },
    
    167
    +    ];
    
    168
    +
    
    169
    +    const notification = {
    
    170
    +      window: win,
    
    171
    +      elementPromise: win.gNotificationBox.appendNotification(
    
    172
    +        "tor-provider-external-process-stopped",
    
    173
    +        {
    
    174
    +          label: { "l10n-id": "tor-external-process-error-message" },
    
    175
    +          priority: win.gNotificationBox.PRIORITY_WARNING_HIGH,
    
    176
    +          eventCallback: event => {
    
    177
    +            switch (event) {
    
    178
    +              case "dismissed":
    
    179
    +                this._notificationUserDismissed = true;
    
    180
    +                break;
    
    181
    +              case "disconnected":
    
    182
    +                if (this._notification === notification) {
    
    183
    +                  this._notification = null;
    
    184
    +                }
    
    185
    +                break;
    
    186
    +            }
    
    187
    +          },
    
    188
    +        },
    
    189
    +        buttons
    
    190
    +      ),
    
    191
    +    };
    
    192
    +    this._notification = notification;
    
    193
    +  },
    
    194
    +
    
    195
    +  /**
    
    196
    +   * Update the notification button if it exists.
    
    197
    +   *
    
    198
    +   * @param {string} l10nId - The Fluent ID for the string we want to show in
    
    199
    +   *   the button.
    
    200
    +   */
    
    201
    +  async _updateNotificationButton(l10nId) {
    
    202
    +    if (!this._notification) {
    
    203
    +      return;
    
    204
    +    }
    
    205
    +    const state = this._providerState;
    
    206
    +    const notification = this._notification;
    
    207
    +    const notificationEl = await notification.elementPromise;
    
    208
    +
    
    209
    +    if (this._providerState !== state || this._notification !== notification) {
    
    210
    +      // Replaced.
    
    211
    +      return;
    
    212
    +    }
    
    213
    +
    
    214
    +    notificationEl.buttonContainer.firstElementChild.setAttribute(
    
    215
    +      "data-l10n-id",
    
    216
    +      l10nId
    
    217
    +    );
    
    218
    +  },
    
    219
    +};

  • browser/modules/moz.build
    ... ... @@ -154,6 +154,7 @@ MOZ_SRC_FILES += [
    154 154
         "ObserverForwarder.sys.mjs",
    
    155 155
         "PrivateBrowsingUI.sys.mjs",
    
    156 156
         "SecurityLevelNotification.sys.mjs",
    
    157
    +    "TorProviderExternalNotification.sys.mjs",
    
    157 158
         "TorSettingsNotification.sys.mjs",
    
    158 159
         "TorUIUtils.sys.mjs",
    
    159 160
     ]
    

  • toolkit/locales/en-US/toolkit/global/tor-browser.ftl
    ... ... @@ -46,6 +46,15 @@ tor-connect-tor-not-working-restarting-button =
    46 46
         .label = Restarting Tor process…
    
    47 47
     tor-connect-tor-not-working-restarting-failed = Restarting failed
    
    48 48
     
    
    49
    +## External Tor process error.
    
    50
    +
    
    51
    +# "{ -brand-short-name }" will be replaced with the localized name of the browser, e.g. "Tor Browser".
    
    52
    +tor-external-process-error-message = { -brand-short-name } can’t communicate with your external Tor application, which may cause some browser features to malfunction. Check that the external application is running, or reconfigure its communication with { -brand-short-name }.
    
    53
    +tor-external-process-error-retry-button =
    
    54
    +    .label = Retry communication
    
    55
    +tor-external-process-error-retry-button-retrying =
    
    56
    +    .label = Retrying communication…
    
    57
    +
    
    49 58
     ## Tor Browser home page.
    
    50 59
     
    
    51 60
     tor-browser-home-heading-stable = Explore. Privately.
    

  • _______________________________________________
    tor-commits mailing list -- tor-commits@xxxxxxxxxxxxxxxxxxxx
    To unsubscribe send an email to tor-commits-leave@xxxxxxxxxxxxxxxxxxxx