[tbb-commits] [tor-launcher/master] Bug 28044: Integrate Tor Launcher into tor-browser

gk at torproject.org gk at torproject.org
Mon May 13 09:47:44 UTC 2019


commit ab7e47f4ab54626e8b7e6348aac25fc3436d166f
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Fri Feb 8 14:42:05 2019 -0500

    Bug 28044: Integrate Tor Launcher into tor-browser
    
    To avoid potential conflicts with other preference files, rename
    our default preferences file from pref.js to torlauncher-prefs.js.
    
    Do not load default preferences if the browser has already done so.
---
 .../preferences/{prefs.js => torlauncher-prefs.js} |  0
 src/modules/tl-util.jsm                            | 26 +++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/torlauncher-prefs.js
similarity index 100%
rename from src/defaults/preferences/prefs.js
rename to src/defaults/preferences/torlauncher-prefs.js
diff --git a/src/modules/tl-util.jsm b/src/modules/tl-util.jsm
index 8b59afb..bac5eae 100644
--- a/src/modules/tl-util.jsm
+++ b/src/modules/tl-util.jsm
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, The Tor Project, Inc.
+// Copyright (c) 2019, The Tor Project, Inc.
 // See LICENSE for licensing information.
 //
 // vim: set sw=2 sts=2 ts=8 et syntax=javascript:
@@ -876,10 +876,30 @@ let TLUtilInternal =  // Private
       return this.mDefaultPreferencesLoaded;
     }
 
+    // Check whether default preferences have already been loaded, e.g.,
+    // because Tor Launcher is integrated into the browser rather than
+    // running as an extension. This code assumes that a default value is
+    // defined for extensions.torlauncher.loglevel.
+    let prefName = "extensions.torlauncher.loglevel";
+    let val;
+    try
+    {
+      let defaultBranch = this._getPrefDefaultBranch(prefName);
+      val = defaultBranch.getIntPref("");
+    } catch (e) {}
+    if (val !== undefined)
+    {
+      this.mDefaultPreferencesLoaded = true;
+      return true;
+    }
+
+    // Use the JS subscript loaded in conjunction with our pref() function
+    // to load the default preferences.
+    const kPrefsURL =
+          "resource://torlauncher/defaults/preferences/torlauncher-prefs.js";
     var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
                        .getService(Ci.mozIJSSubScriptLoader);
-    loader.loadSubScript(
-            "resource://torlauncher/defaults/preferences/prefs.js", this);
+    loader.loadSubScript(kPrefsURL, this);
 
     this.mDefaultPreferencesLoaded =
           (this.mNumDefaultPrefsDefined == this.mNumDefaultPrefsLoaded);





More information about the tbb-commits mailing list