Commit 47bb646f authored by Richard Pospesel's avatar Richard Pospesel Committed by Pier Angelo Vendrame
Browse files

TB 27476: Implement about:torconnect captive portal within Tor Browser

- implements new about:torconnect page as tor-launcher replacement
- adds new torconnect component to browser
- tor process management functionality remains implemented in tor-launcher through the TorProtocolService module
- adds warning/error box to about:preferences#tor when not connected to tor

Bug 40773: Update the about:torconnect frontend page to match additional UI flows.

Bug 41608: Add a toolbar status button and a urlbar "Connect" button.
parent 85a1cd33
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ export default [
    rules: {
      // XXX Bug 1326071 - This should be reduced down - probably to 20 or to
      // be removed & synced with the mozilla/recommended value.
      complexity: ["error", { max: 44 }],
      complexity: ["error", { max: 48 }],

      // Disallow empty statements. This will report an error for:
      // try { something(); } catch (e) {}
+39 −22
Original line number Diff line number Diff line
@@ -355,6 +355,9 @@ var gBrowserInit = {
    // Init the SecurityLevelButton
    SecurityLevelButton.init();

    gTorConnectUrlbarButton.init();
    gTorConnectTitlebarStatus.init();

    gTorCircuitPanel.init();

    // Certain kinds of automigration rely on this notification to complete
@@ -1111,21 +1114,23 @@ var gBrowserInit = {

      let defaultArgs = BrowserHandler.defaultArgs;

      // figure out which URI to actually load (or a Promise to get the uri)
      uri = (aUri => {
        // If the given URI is different from the homepage, we want to load it.
      if (uri != defaultArgs) {
        if (aUri != defaultArgs) {
          AboutNewTab.noteNonDefaultStartup();

        if (uri instanceof Ci.nsIArray) {
          if (aUri instanceof Ci.nsIArray) {
            // Transform the nsIArray of nsISupportsString's into a JS Array of
            // JS strings.
            return Array.from(
            uri.enumerate(Ci.nsISupportsString),
              aUri.enumerate(Ci.nsISupportsString),
              supportStr => supportStr.data
            );
        } else if (uri instanceof Ci.nsISupportsString) {
          return uri.data;
          } else if (aUri instanceof Ci.nsISupportsString) {
            return aUri.data;
          }
        return uri;
          return aUri;
        }

        // The URI appears to be the the homepage. We want to load it only if
@@ -1137,6 +1142,15 @@ var gBrowserInit = {
        return willOverride.then(willOverrideHomepage =>
          willOverrideHomepage ? null : uri
        );
      })(uri);

      // if using TorConnect, convert these uris to redirects
      if (TorConnect.shouldShowTorConnect) {
        return Promise.resolve(uri).then(aUri =>
          TorConnectParent.getURIsToLoad(aUri ?? [])
        );
      }
      return uri;
    })());
  },

@@ -1177,6 +1191,9 @@ var gBrowserInit = {

    SecurityLevelButton.uninit();

    gTorConnectUrlbarButton.uninit();
    gTorConnectTitlebarStatus.uninit();

    gTorCircuitPanel.uninit();

    // LinkPreview.sys.mjs is missing. tor-browser#44045.
+16 −0
Original line number Diff line number Diff line
@@ -106,6 +106,11 @@ ChromeUtils.defineESModuleGetters(this, {
  ToolbarDropHandler:
    "moz-src:///browser/components/customizableui/ToolbarDropHandler.sys.mjs",
  ToolbarIconColor: "moz-src:///browser/themes/ToolbarIconColor.sys.mjs",
  TorConnect: "moz-src:///toolkit/modules/TorConnect.sys.mjs",
  TorConnectStage: "moz-src:///toolkit/modules/TorConnect.sys.mjs",
  TorConnectTopics: "moz-src:///toolkit/modules/TorConnect.sys.mjs",
  TorConnectParent:
    "moz-src:///browser/components/torconnect/TorConnectParent.sys.mjs",
  TorDomainIsolator:
    "moz-src:///toolkit/components/tor-launcher/TorDomainIsolator.sys.mjs",
  TorUIUtils: "moz-src:///browser/modules/TorUIUtils.sys.mjs",
@@ -317,6 +322,16 @@ XPCOMUtils.defineLazyScriptGetter(
  "gProfiles",
  "chrome://browser/content/browser-profiles.js"
);
XPCOMUtils.defineLazyScriptGetter(
  this,
  ["gTorConnectUrlbarButton"],
  "chrome://browser/content/torconnect/torConnectUrlbarButton.js"
);
XPCOMUtils.defineLazyScriptGetter(
  this,
  ["gTorConnectTitlebarStatus"],
  "chrome://browser/content/torconnect/torConnectTitlebarStatus.js"
);
XPCOMUtils.defineLazyScriptGetter(
  this,
  ["gTorCircuitPanel"],
@@ -738,6 +753,7 @@ var gPageIcons = {
};

var gInitialPages = [
  "about:torconnect",
  "about:blank",
  "about:home",
  "about:firefoxview",
+7 −1
Original line number Diff line number Diff line
@@ -241,5 +241,11 @@
  "TorUIUtils",
  "NewIdentityButton",
  "TorDomainIsolator",
  "gTorCircuitPanel"
  "gTorCircuitPanel",
  "TorConnect",
  "TorConnectStage",
  "TorConnectTopics",
  "TorConnectParent",
  "gTorConnectUrlbarButton",
  "gTorConnectTitlebarStatus"
]
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@
  <link rel="stylesheet" href="chrome://browser/content/securitylevel/securityLevelPanel.css" />
  <link rel="stylesheet" href="chrome://browser/content/securitylevel/securityLevelButton.css" />
  <link rel="stylesheet" href="chrome://browser/content/torCircuitPanel.css" />
  <link rel="stylesheet" href="chrome://browser/content/torconnect/torConnectTitlebarStatus.css" />

  <link rel="localization" href="branding/brand.ftl"/>
  <link rel="localization" href="browser/allTabsMenu.ftl"/>
Loading