Files
tubestation/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
Gijs Kruitbosch 97c3b183c4 Bug 1427186 - stop ever showing 'new tab' as a title for about:privatebrowsing in private windows, r=dao
There are 3 issues here:
- the runtime changing of the title causes issues where the content title is
  not set. This is fixed by setting it to the private title by default;
  there is very little (if any) UI that allows users to even open
  about:privatebrowsing in 'normal' windows so we care a lot less about
  flicker there. To be able to include this title in the markup, we switched
  to a dtd.
- the 'empty tab' title we set on the tab initially is set when the tab is
  created. This has been updated to check for private windows, and default to
  'Private Browsing' instead. This will obviously also affect other new tabs
  in private browsing, but that seems desirable/consistent.
- Likewise, we use this title when updating a tab's title that we don't yet
  have a content title for (which can still happen while about:privatebrowsing
  is loading because e10s), and so that is updated, too.

MozReview-Commit-ID: nVfXD2M6UZ
2018-03-07 20:13:54 +00:00

64 lines
2.8 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const FAVICON_QUESTION = "chrome://global/skin/icons/question-32.png";
const STRING_BUNDLE = "chrome://browser/locale/aboutPrivateBrowsing.properties";
const TP_ENABLED_PREF = "privacy.trackingprotection.enabled";
const TP_PB_ENABLED_PREF = "privacy.trackingprotection.pbmode.enabled";
function updateTPInfo() {
let aboutCapabilities = document.aboutCapabilities;
let tpButton = document.getElementById("tpButton");
let tpToggle = document.getElementById("tpToggle");
let title = document.getElementById("title");
let titleTracking = document.getElementById("titleTracking");
let tpSubHeader = document.getElementById("tpSubHeader");
let globalTrackingEnabled = aboutCapabilities.getBoolPref(TP_ENABLED_PREF, null);
let trackingEnabled = globalTrackingEnabled ||
aboutCapabilities.getBoolPref(TP_PB_ENABLED_PREF, null);
// if tracking protection is enabled globally we don't even give the user
// a choice here by hiding the toggle completely.
tpButton.classList.toggle("hide", globalTrackingEnabled);
tpToggle.checked = trackingEnabled;
title.classList.toggle("hide", trackingEnabled);
titleTracking.classList.toggle("hide", !trackingEnabled);
tpSubHeader.classList.toggle("tp-off", !trackingEnabled);
}
document.addEventListener("DOMContentLoaded", function() {
let aboutCapabilities = document.aboutCapabilities;
if (!aboutCapabilities.isWindowPrivate()) {
document.documentElement.classList.remove("private");
document.documentElement.classList.add("normal");
document.title = document.querySelector("title").getAttribute("notprivatetitle");
document.getElementById("favicon").setAttribute("href", FAVICON_QUESTION);
document.getElementById("startPrivateBrowsing").addEventListener("click", function() {
aboutCapabilities.sendAsyncMessage("OpenPrivateWindow", null);
});
return;
}
document.getElementById("startTour").addEventListener("click", function() {
aboutCapabilities.sendAsyncMessage("DontShowIntroPanelAgain", null);
});
document.getElementById("startTour").setAttribute("href",
aboutCapabilities.formatURLPref("privacy.trackingprotection.introURL"));
document.getElementById("learnMore").setAttribute("href",
aboutCapabilities.formatURLPref("app.support.baseURL") + "private-browsing");
let tpToggle = document.getElementById("tpToggle");
document.getElementById("tpButton").addEventListener("click", () => {
tpToggle.click();
});
tpToggle.addEventListener("change", function() {
aboutCapabilities.setBoolPref(TP_PB_ENABLED_PREF, tpToggle.checked).then(function() {
updateTPInfo();
});
});
updateTPInfo();
});