Bug 1196017 - Deal with TP turned on globally in about:privatebrowsing. r=paolo, a=lizzard
authorFrancois Marier <francois@mozilla.com>
Mon, 24 Aug 2015 16:10:14 -0700
changeset 288931 119f61ff79afdd6735ca4d05f48383f03c72ac20
parent 288930 c47645f91f51afbfc50416a08ba625c5d4b4cf54
child 288932 1ec7d19880f925e0c5f290e2971759ea5cfaf9cf
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo, lizzard
bugs1196017
milestone42.0a2
Bug 1196017 - Deal with TP turned on globally in about:privatebrowsing. r=paolo, a=lizzard
browser/components/privatebrowsing/content/aboutPrivateBrowsing.css
browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml
--- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.css
+++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.css
@@ -17,16 +17,19 @@ body {
 }
 
 body.private .showNormal,
 body.normal .showPrivate,
 body[tpEnabled] .showTpDisabled,
 body:not([tpEnabled]) .showTpEnabled {
   display: none !important;
 }
+body[globalTpEnabled] .showGlobalTpDisabled {
+  display: none !important;
+}
 
 @media screen and (min-width: 1200px) and (min-height: 700px) {
   body.private {
     font-size: 1.25em;
   }
 }
 
 #bar {
--- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
+++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
@@ -9,28 +9,35 @@ Cu.import("resource://gre/modules/Privat
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const FAVICON_QUESTION = "chrome://global/skin/icons/question-16.png";
 const FAVICON_PRIVACY = "chrome://browser/skin/Privacy-16.png";
 
 let stringBundle = Services.strings.createBundle(
                      "chrome://browser/locale/aboutPrivateBrowsing.properties");
 
-let prefBranch = Services.prefs.getBranch("privacy.trackingprotection.pbmode.");
+let prefBranch = Services.prefs.getBranch("privacy.trackingprotection.");
 let prefObserver = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                          Ci.nsISupportsWeakReference]),
   observe: function () {
     if (prefBranch.getBoolPref("enabled")) {
+      document.body.setAttribute("globalTpEnabled", "true");
+    } else {
+      document.body.removeAttribute("globalTpEnabled");
+    }
+    if (prefBranch.getBoolPref("pbmode.enabled") ||
+        prefBranch.getBoolPref("enabled")) {
       document.body.setAttribute("tpEnabled", "true");
     } else {
       document.body.removeAttribute("tpEnabled");
     }
   },
 };
+prefBranch.addObserver("pbmode.enabled", prefObserver, true);
 prefBranch.addObserver("enabled", prefObserver, true);
 
 function setFavIcon(url) {
   document.getElementById("favicon").setAttribute("href", url);
 }
 
 document.addEventListener("DOMContentLoaded", function () {
   if (!PrivateBrowsingUtils.isContentWindowPrivate(window)) {
--- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml
+++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml
@@ -68,20 +68,20 @@
                 style="width: &trackingProtection.state.width;"
                 class="showTpDisabled">&trackingProtection.state.disabled;</span>
         </div>
         <p id="tpDiagram"/>
         <p>&trackingProtection.description1;</p>
         <!-- Use text links to implement plain styled buttons without an href. -->
         <label xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
                id="disableTrackingProtection"
-               class="text-link showTpEnabled"
+               class="text-link showTpEnabled showGlobalTpDisabled"
                value="&trackingProtection.disable;"/>
         <label xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
                id="enableTrackingProtection"
-               class="text-link showTpDisabled"
+               class="text-link showTpDisabled showGlobalTpDisabled"
                value="&trackingProtection.enable;"/>
         <p id="tpStartTour"
            class="showTpEnabled"><a id="startTour">&trackingProtection.startTour1;</a></p>
       </div>
     </div>
   </body>
 </html>