Verified Commit badef3d6 authored by Richard Pospesel's avatar Richard Pospesel Committed by Pier Angelo Vendrame
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 a30c568b
Loading
Loading
Loading
Loading
+58 −22
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ XPCOMUtils.defineLazyModuleGetters(this, {
  ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.jsm",
  SiteDataManager: "resource:///modules/SiteDataManager.jsm",
  TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
  TorConnect: "resource:///modules/TorConnect.jsm",
  TorConnectState: "resource:///modules/TorConnect.jsm",
  TorConnectTopics: "resource:///modules/TorConnect.jsm",
  Translation: "resource:///modules/translation/TranslationParent.jsm",
  webrtcUI: "resource:///modules/webrtcUI.jsm",
  ZoomUI: "resource:///modules/ZoomUI.jsm",
@@ -282,6 +285,16 @@ XPCOMUtils.defineLazyScriptGetter(
  "gPageStyleMenu",
  "chrome://browser/content/browser-pagestyle.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"],
@@ -702,6 +715,7 @@ var gPageIcons = {
};

var gInitialPages = [
  "about:torconnect",
  "about:blank",
  "about:home",
  "about:firefoxview",
@@ -1702,6 +1716,9 @@ var gBrowserInit = {
    // Init the NewIdentityButton
    NewIdentityButton.init();

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

    gTorCircuitPanel.init();

    // Certain kinds of automigration rely on this notification to complete
@@ -2384,21 +2401,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
@@ -2410,6 +2429,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;
    })());
  },

@@ -2477,6 +2510,9 @@ var gBrowserInit = {

    NewIdentityButton.uninit();

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

    gTorCircuitPanel.uninit();

    if (gToolbarKeyNavEnabled) {
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
<?xml-stylesheet href="chrome://browser/skin/places/tree-icons.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/places/editBookmark.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
+13 −0
Original line number Diff line number Diff line
@@ -108,6 +108,12 @@
        <label data-l10n-id="private-browsing-indicator-label"></label>
      </hbox>

      <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>
@@ -415,6 +421,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/>
+14 −0
Original line number Diff line number Diff line
@@ -729,6 +729,20 @@ let JSWINDOWACTORS = {
    allFrames: true,
  },

  TorConnect: {
    parent: {
      esModuleURI: "resource:///actors/TorConnectParent.sys.mjs",
    },
    child: {
      esModuleURI: "resource:///actors/TorConnectChild.sys.mjs",
      events: {
        DOMWindowCreated: {},
      },
    },

    matches: ["about:torconnect", "about:torconnect?*"],
  },

  // The older translations feature backed by external services.
  // This is being replaced by a newer ML-backed translation service. See Bug 971044.
  Translation: {
+5 −0
Original line number Diff line number Diff line
@@ -141,6 +141,11 @@ static const RedirEntry kRedirMap[] = {
         nsIAboutModule::HIDE_FROM_ABOUTABOUT},
    {"restartrequired", "chrome://browser/content/aboutRestartRequired.xhtml",
     nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::HIDE_FROM_ABOUTABOUT},
    {"torconnect", "chrome://browser/content/torconnect/aboutTorConnect.xhtml",
     nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
         nsIAboutModule::URI_CAN_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT |
         nsIAboutModule::HIDE_FROM_ABOUTABOUT |
         nsIAboutModule::IS_SECURE_CHROME_UI},
};

static nsAutoCString GetAboutModuleName(nsIURI* aURI) {
Loading