Bug 1094324 - Set browser.newtabpage.enhanced default in prefs. r=adw

The current behavior is that if there is no user pref, it is set to true or
false depending on the value of privacy.donottrackheader.enabled, but
completely ignoring the global default.

This patch changes the behavior such that:
- browser.newtabpage.enhanced's default value is set as a global default
- it is also set as sticky, so that even when the same value as the default is
  set, prefHasUserValue is true.
- The introduction is not shown when the default for browser.newtabpage.enhanced
  is false. It is however shown when the pref is flipped for the first time.
This commit is contained in:
Mike Hommey 2015-06-26 06:36:02 -07:00
parent 80c3a87828
commit 8444d8b32a
4 changed files with 9 additions and 1 deletions

View File

@ -1677,6 +1677,9 @@ pref("browser.newtabpage.updateIntroShown", false);
// Toggles the content of 'about:newtab'. Shows the grid when enabled.
pref("browser.newtabpage.enabled", true);
// Toggles the enhanced content of 'about:newtab'. Shows sponsored tiles.
sticky_pref("browser.newtabpage.enhanced", true);
// number of rows of newtab grid
pref("browser.newtabpage.rows", 3);

View File

@ -6,6 +6,7 @@
const PREF_INTRO_SHOWN = "browser.newtabpage.introShown";
const PREF_UPDATE_INTRO_SHOWN = "browser.newtabpage.updateIntroShown";
const PREF_NEWTAB_ENHANCED = "browser.newtabpage.enhanced";
// These consts indicate the type of intro/onboarding we show.
const WELCOME = "welcome";
@ -205,6 +206,9 @@ let gIntro = {
},
showIfNecessary: function() {
if (!Services.prefs.getBoolPref(PREF_NEWTAB_ENHANCED)) {
return;
}
if (!Services.prefs.getBoolPref(PREF_INTRO_SHOWN)) {
this._onboardingType = WELCOME;
this.showPanel();

View File

@ -54,6 +54,7 @@ let gPage = {
// Update thumbnails to the new enhanced setting
if (aData == "browser.newtabpage.enhanced") {
this.update();
gIntro.showIfNecessary();
}
// Initialize the whole page if we haven't done that, yet.

View File

@ -388,7 +388,7 @@ let DirectoryLinksProvider = {
*/
_setDefaultEnhanced: function DirectoryLinksProvider_setDefaultEnhanced() {
if (!Services.prefs.prefHasUserValue(PREF_NEWTAB_ENHANCED)) {
let enhanced = true;
let enhanced = Services.prefs.getBoolPref(PREF_NEWTAB_ENHANCED);
try {
// Default to not enhanced if DNT is set to tell websites to not track
if (Services.prefs.getBoolPref("privacy.donottrackheader.enabled")) {