Commit 6113f8f4 authored by Alex Catarineu's avatar Alex Catarineu Committed by Matthew Finkel
Browse files

Bug 31575: Replace Firefox Home (newtab) with about:tor

Patching AboutNewTabService so that AboutNewTab is not loaded
to avoid several network requests that we do not need. Besides,
about:newtab will now point to about:blank or about:tor (depending
on browser.newtabpage.enabled) and about:home will point to
about:tor.
parent 6bf97379
Loading
Loading
Loading
Loading
+1 −28
Original line number Diff line number Diff line
@@ -10,9 +10,6 @@ const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm");

ChromeUtils.defineModuleGetter(this, "AboutNewTab",
                               "resource:///modules/AboutNewTab.jsm");

const TOPIC_APP_QUIT = "quit-application-granted";
const TOPIC_LOCALES_CHANGE = "intl:app-locales-changed";
const TOPIC_CONTENT_DOCUMENT_INTERACTIVE = "content-document-interactive";
@@ -47,12 +44,6 @@ function AboutNewTabService() {
  this.toggleActivityStream(true);
  this.initialized = true;
  this.alreadyRecordedTopsitesPainted = false;

  if (IS_MAIN_PROCESS) {
    AboutNewTab.init();
  } else if (IS_PRIVILEGED_PROCESS) {
    Services.obs.addObserver(this, TOPIC_CONTENT_DOCUMENT_INTERACTIVE);
  }
}

/*
@@ -179,11 +170,6 @@ AboutNewTabService.prototype = {
      }
      case TOPIC_APP_QUIT:
        this.uninit();
        if (IS_MAIN_PROCESS) {
          AboutNewTab.uninit();
        } else if (IS_PRIVILEGED_PROCESS) {
          Services.obs.removeObserver(this, TOPIC_CONTENT_DOCUMENT_INTERACTIVE);
        }
        break;
      case TOPIC_LOCALES_CHANGE:
        this.updatePrerenderedPath();
@@ -243,20 +229,7 @@ AboutNewTabService.prototype = {
   * the newtab page has no effect on the result of this function.
   */
  get defaultURL() {
    // Generate the desired activity stream resource depending on state, e.g.,
    // resource://activity-stream/prerendered/ar/activity-stream.html
    // resource://activity-stream/prerendered/en-US/activity-stream-prerendered.html
    // resource://activity-stream/prerendered/static/activity-stream-debug.html
    return [
      "resource://activity-stream/prerendered/",
      this._activityStreamPath,
      "activity-stream",
      this._activityStreamPrerender ? "-prerendered" : "",
      // Debug version loads dev scripts but noscripts separately loads scripts
      this._activityStreamDebug && !this._privilegedContentProcess ? "-debug" : "",
      this._privilegedContentProcess ? "-noscripts" : "",
      ".html",
    ].join("");
    return "about:tor";
  },

  /*
+2 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@
                class="check-home-page-controlled"
                data-preference-related="browser.startup.homepage">
        <menupopup>
            <menuitem value="0" data-l10n-id="home-mode-choice-default" />
            <menuitem value="0" label="&aboutTor.title;" />
            <menuitem value="2" data-l10n-id="home-mode-choice-custom" />
            <menuitem value="1" data-l10n-id="home-mode-choice-blank" />
        </menupopup>
@@ -79,7 +79,7 @@
                onsyncfrompreference="return gHomePane.syncFromNewTabPref();"
                onsynctopreference="return gHomePane.syncToNewTabPref(this.value);">
      <menupopup>
          <menuitem value="0" data-l10n-id="home-mode-choice-default" />
          <menuitem value="0" label="&aboutTor.title;" />
          <menuitem value="1" data-l10n-id="home-mode-choice-blank" />
      </menupopup>
    </menulist>
+4 −1
Original line number Diff line number Diff line
@@ -17,7 +17,10 @@
<?xml-stylesheet href="chrome://browser/skin/preferences/in-content/privacy.css"?>
<?xml-stylesheet href="chrome://browser/content/securitylevel/securityLevelPreferences.css"?>

<!DOCTYPE page>
<!DOCTYPE page [
<!ENTITY % aboutTorDTD SYSTEM "chrome://torbutton/locale/aboutTor.dtd">
  %aboutTorDTD;
]>

<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      xmlns:html="http://www.w3.org/1999/xhtml"
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ ChromeUtils.defineModuleGetter(
);

const kPrefName = "browser.startup.homepage";
const kDefaultHomePage = "about:home";
const kDefaultHomePage = "about:tor";

function getHomepagePref(useDefault) {
  let homePage;