[tbb-commits] [tor-browser/tor-browser-68.1.0esr-9.0-2] Bug 31575: Replace Firefox Home (newtab) with about:tor

gk at torproject.org gk at torproject.org
Wed Sep 25 10:43:13 UTC 2019


commit e11a1889ae871a9ced871346f5f9eb3e0a9ab6d3
Author: Alex Catarineu <acat at torproject.org>
Date:   Mon Sep 9 13:04:34 2019 +0200

    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.
---
 browser/components/newtab/AboutNewTabService.jsm   | 29 +---------------------
 browser/components/preferences/in-content/home.xul |  4 +--
 .../preferences/in-content/preferences.xul         |  5 +++-
 browser/modules/HomePage.jsm                       |  2 +-
 4 files changed, 8 insertions(+), 32 deletions(-)

diff --git a/browser/components/newtab/AboutNewTabService.jsm b/browser/components/newtab/AboutNewTabService.jsm
index 8995d82d543b..117b9d6347cd 100644
--- a/browser/components/newtab/AboutNewTabService.jsm
+++ b/browser/components/newtab/AboutNewTabService.jsm
@@ -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";
   },
 
   /*
diff --git a/browser/components/preferences/in-content/home.xul b/browser/components/preferences/in-content/home.xul
index 8c38ba68c2af..fc555a2f56af 100644
--- a/browser/components/preferences/in-content/home.xul
+++ b/browser/components/preferences/in-content/home.xul
@@ -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>
diff --git a/browser/components/preferences/in-content/preferences.xul b/browser/components/preferences/in-content/preferences.xul
index 13c7bcc74ad8..3b07e4596907 100644
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -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"
diff --git a/browser/modules/HomePage.jsm b/browser/modules/HomePage.jsm
index f888f185c6a8..2519f3eaa754 100644
--- a/browser/modules/HomePage.jsm
+++ b/browser/modules/HomePage.jsm
@@ -17,7 +17,7 @@ ChromeUtils.defineModuleGetter(
 );
 
 const kPrefName = "browser.startup.homepage";
-const kDefaultHomePage = "about:home";
+const kDefaultHomePage = "about:tor";
 
 function getHomepagePref(useDefault) {
   let homePage;



More information about the tbb-commits mailing list