Commit f4d38f11 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 1e4e030d
Loading
Loading
Loading
Loading
+39 −22
Original line number Diff line number Diff line
@@ -232,6 +232,9 @@ var gBrowserInit = {
    // Init the SecurityLevelButton
    SecurityLevelButton.init();

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

    gTorCircuitPanel.init();

    // Certain kinds of automigration rely on this notification to complete
@@ -956,21 +959,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
@@ -982,6 +987,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;
    })());
  },

@@ -1045,6 +1059,9 @@ var gBrowserInit = {

    SecurityLevelButton.uninit();

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

    gTorCircuitPanel.uninit();

    if (gToolbarKeyNavEnabled) {
+15 −0
Original line number Diff line number Diff line
@@ -95,6 +95,10 @@ ChromeUtils.defineESModuleGetters(this, {
  ToolbarContextMenu: "resource:///modules/ToolbarContextMenu.sys.mjs",
  ToolbarDropHandler: "resource:///modules/ToolbarDropHandler.sys.mjs",
  ToolbarIconColor: "moz-src:///browser/themes/ToolbarIconColor.sys.mjs",
  TorConnect: "resource://gre/modules/TorConnect.sys.mjs",
  TorConnectStage: "resource://gre/modules/TorConnect.sys.mjs",
  TorConnectTopics: "resource://gre/modules/TorConnect.sys.mjs",
  TorConnectParent: "resource://gre/actors/TorConnectParent.sys.mjs",
  TorDomainIsolator: "resource://gre/modules/TorDomainIsolator.sys.mjs",
  TorUIUtils: "resource:///modules/TorUIUtils.sys.mjs",
  TranslationsParent: "resource://gre/actors/TranslationsParent.sys.mjs",
@@ -306,6 +310,16 @@ XPCOMUtils.defineLazyScriptGetter(
  "gProfiles",
  "chrome://browser/content/browser-profiles.js"
);
XPCOMUtils.defineLazyScriptGetter(
  this,
  ["gTorConnectUrlbarButton"],
  "chrome://global/content/torconnect/torConnectUrlbarButton.js"
);
XPCOMUtils.defineLazyScriptGetter(
  this,
  ["gTorConnectTitlebarStatus"],
  "chrome://global/content/torconnect/torConnectTitlebarStatus.js"
);
XPCOMUtils.defineLazyScriptGetter(
  this,
  ["gTorCircuitPanel"],
@@ -719,6 +733,7 @@ var gPageIcons = {
};

var gInitialPages = [
  "about:torconnect",
  "about:blank",
  "about:home",
  "about:firefoxview",
+7 −1
Original line number Diff line number Diff line
@@ -254,5 +254,11 @@
  "NewIdentityButton",
  "TorUIUtils",
  "TorDomainIsolator",
  "gTorCircuitPanel"
  "gTorCircuitPanel",
  "TorConnect",
  "TorConnectStage",
  "TorConnectTopics",
  "TorConnectParent",
  "gTorConnectUrlbarButton",
  "gTorConnectTitlebarStatus"
]
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,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://global/content/torconnect/torConnectTitlebarStatus.css" />

  <link rel="localization" href="branding/brand.ftl"/>
  <link rel="localization" href="browser/allTabsMenu.ftl"/>
+9 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@
#include private-browsing-indicator.inc.xhtml
    <toolbarbutton class="content-analysis-indicator toolbarbutton-1 content-analysis-indicator-icon"/>

#include ../../../toolkit/components/torconnect/content/torConnectTitlebarStatus.inc.xhtml
#include titlebar-items.inc.xhtml

  </toolbar>
@@ -428,6 +429,13 @@
                       class="urlbar-icon"/>
              </hbox>
            </hbox>

            <hbox id="tor-connect-urlbar-button"
                  role="button"
                  class="tor-button tor-urlbar-button"
                  hidden="true">
              <label id="tor-connect-urlbar-button-label"/>
            </hbox>
          </hbox>
        </html:div>
        <toolbartabstop/>
@@ -510,6 +518,7 @@
    <hbox class="titlebar-spacer" type="post-tabs"/>
#include private-browsing-indicator.inc.xhtml
    <toolbarbutton class="content-analysis-indicator toolbarbutton-1 content-analysis-indicator-icon"/>
#include ../../../toolkit/components/torconnect/content/torConnectTitlebarStatus.inc.xhtml
#include titlebar-items.inc.xhtml
  </toolbar>

Loading