Verified Commit 6b31946b authored by Richard Pospesel's avatar Richard Pospesel Committed by ma1
Browse files

Bug 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 b7b938b2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ const { TelemetryController } = ChromeUtils.import(
  "resource://gre/modules/TelemetryController.jsm"
);

const { TorConnect } = ChromeUtils.import("resource:///modules/TorConnect.jsm");

const PREF_SSL_IMPACT_ROOTS = [
  "security.tls.version.",
  "security.ssl3.",
@@ -341,6 +343,10 @@ class NetErrorParent extends JSWindowActorParent {
            break;
          }
        }
        break;
      case "ShouldShowTorConnect":
        return TorConnect.shouldShowTorConnect;
    }
    return undefined;
  }
}
+58 −22
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ XPCOMUtils.defineLazyModuleGetters(this, {
  TabModalPrompt: "chrome://global/content/tabprompts.jsm",
  TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
  TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.jsm",
  TorConnect: "resource:///modules/TorConnect.jsm",
  TorConnectState: "resource:///modules/TorConnect.jsm",
  TorConnectTopics: "resource:///modules/TorConnect.jsm",
  Translation: "resource:///modules/translation/TranslationParent.jsm",
  UITour: "resource:///modules/UITour.jsm",
  UpdateUtils: "resource://gre/modules/UpdateUtils.jsm",
@@ -262,6 +265,16 @@ XPCOMUtils.defineLazyScriptGetter(
  "gSharedTabWarning",
  "chrome://browser/content/browser-webrtc.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"],
@@ -650,6 +663,7 @@ var gPageIcons = {

var gInitialPages = [
  "about:tor",
  "about:torconnect",
  "about:blank",
  "about:home",
  ...(AppConstants.NIGHTLY_BUILD ? ["about:firefoxview"] : []),
@@ -1793,6 +1807,9 @@ var gBrowserInit = {
    // Init the NewIdentityButton
    NewIdentityButton.init();

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

    gTorCircuitPanel.init();

    // Certain kinds of automigration rely on this notification to complete
@@ -2427,21 +2444,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
@@ -2453,6 +2472,20 @@ 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 => {
          if (aUri == null) {
            aUri = [];
          }

          aUri = TorConnect.getURIsToLoad(aUri);
          return aUri;
        });
      }
      return uri;
    })());
  },

@@ -2519,6 +2552,9 @@ var gBrowserInit = {

    NewIdentityButton.uninit();

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

    gTorCircuitPanel.uninit();

    gAccessibilityServiceIndicator.uninit();
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
<?xml-stylesheet href="chrome://browser/skin/places/editBookmark.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/onionservices/onionservices.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/torCircuitPanel.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/torconnect/torConnectTitlebarStatus.css" type="text/css"?>

<!DOCTYPE window [
#include browser-doctype.inc
+11 −1
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ function setErrorPageStrings(err) {
  document.l10n.setAttributes(titleElement, title);
}

function initPage() {
async function initPage() {
  // We show an offline support page in case of a system-wide error,
  // when a user cannot connect to the internet and access the SUMO website.
  // For example, clock error, which causes certerrors across the web or
@@ -300,6 +300,16 @@ function initPage() {
    document.body.classList.add("blocked");
  }

  // proxyConnectFailure because no-tor running daemon would return this error
  if (
    err === "proxyConnectFailure" &&
    (await RPMSendQuery("ShouldShowTorConnect"))
  ) {
    // pass orginal destination as redirect param
    const encodedRedirect = encodeURIComponent(document.location.href);
    document.location.replace(`about:torconnect?redirect=${encodedRedirect}`);
  }

  // Only worry about captive portals if this is a cert error.
  let showCaptivePortalUI = isCaptive() && gIsCertError;
  if (showCaptivePortalUI) {
+13 −0
Original line number Diff line number Diff line
@@ -93,6 +93,12 @@
              aria-live="polite"/>
      <hbox class="private-browsing-indicator"/>

      <html:div id="tor-connect-titlebar-status" role="status">
        <html:img alt=""
                  src="chrome://browser/content/torconnect/tor-not-connected-to-connected-animated.svg" />
        <html:span id="tor-connect-titlebar-status-label"></html:span>
      </html:div>

#include titlebar-items.inc.xhtml

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

            <hbox id="tor-connect-urlbar-button"
                  role="button"
                  class="tor-urlbar-button"
                  hidden="true">
              <label id="tor-connect-urlbar-button-label"/>
            </hbox>
          </hbox>
        </hbox>
        <toolbartabstop/>
Loading