Verified Commit a02c515f 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 tor connection status to url bar and tweaks UX when not online
- 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
- explicitly allows about:torconnect URIs to ignore Resist Fingerprinting (RFP)
- various tweaks to info-pages.inc.css for about:torconnect (also affects other firefox info pages)

Bug 40773: Update the about:torconnect frontend page to match additional UI flows
parent 9ba127a5
Loading
Loading
Loading
Loading
+44 −22
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
  ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.jsm",
  SiteDataManager: "resource:///modules/SiteDataManager.jsm",
  TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
  TorConnect: "resource:///modules/TorConnect.jsm",
  TorDomainIsolator: "resource://gre/modules/TorDomainIsolator.jsm",
  Translation: "resource:///modules/translation/TranslationParent.jsm",
  webrtcUI: "resource:///modules/webrtcUI.jsm",
@@ -703,6 +704,7 @@ var gPageIcons = {

var gInitialPages = [
  "about:tor",
  "about:torconnect",
  "about:blank",
  "about:home",
  "about:firefoxview",
@@ -1789,6 +1791,8 @@ var gBrowserInit = {
    }

    this._loadHandled = true;

    TorBootstrapUrlbar.init();
  },

  _cancelDelayedStartup() {
@@ -2385,21 +2389,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
@@ -2411,6 +2417,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;
    })());
  },

@@ -2480,6 +2500,8 @@ var gBrowserInit = {

    gTorCircuitPanel.uninit();

    TorBootstrapUrlbar.uninit();

    if (gToolbarKeyNavEnabled) {
      ToolbarKeyboardNavigator.uninit();
    }
+1 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@
  Services.scriptloader.loadSubScript("chrome://browser/content/search/searchbar.js", this);
  Services.scriptloader.loadSubScript("chrome://browser/content/languageNotification.js", this);
  Services.scriptloader.loadSubScript("chrome://torbutton/content/torbutton.js", this);
  Services.scriptloader.loadSubScript("chrome://browser/content/torconnect/torBootstrapUrlbar.js", this);

  window.onload = gBrowserInit.onLoad.bind(gBrowserInit);
  window.onunload = gBrowserInit.onUnload.bind(gBrowserInit);
+1 −0
Original line number Diff line number Diff line
@@ -352,6 +352,7 @@
                   data-l10n-id="urlbar-go-button"/>
            <hbox id="page-action-buttons" context="pageActionContextMenu" align="center">
              <toolbartabstop/>
#include ../../components/torconnect/content/torconnect-urlbar.inc.xhtml
              <hbox id="contextual-feature-recommendation" role="button" hidden="true">
                <hbox id="cfr-label-container">
                  <label id="cfr-label"/>
+14 −0
Original line number Diff line number Diff line
@@ -728,6 +728,20 @@ let JSWINDOWACTORS = {
    allFrames: true,
  },

  TorConnect: {
    parent: {
      moduleURI: "resource:///modules/TorConnectParent.jsm",
    },
    child: {
      moduleURI: "resource:///modules/TorConnectChild.jsm",
      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
@@ -148,6 +148,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