Bug 1094324 - Set browser.newtabpage.enhanced default in prefs. r=adw
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 26 Jun 2015 06:36:02 -0700
changeset 250630 6101a4ede19e324b505f5dacc4a9630f1080461b
parent 250629 802e790c6687d1c5910f3fb2fe131570620547f7
child 250631 9c5e20dd8ae551e06a93234afea4509ad27f3069
push id28966
push usercbook@mozilla.com
push dateTue, 30 Jun 2015 11:23:37 +0000
treeherdermozilla-central@291614a686f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1094324
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
browser/app/profile/firefox.js
browser/base/content/newtab/intro.js
browser/base/content/newtab/page.js
browser/modules/DirectoryLinksProvider.jsm
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1672,16 +1672,19 @@ pref("browser.newtab.preload", true);
 pref("browser.newtabpage.introShown", false);
 
 // Remembers if the about:newtab update intro has been shown
 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);
 
 // number of columns of newtab grid
 pref("browser.newtabpage.columns", 5);
 
 // directory tiles download URL
 pref("browser.newtabpage.directory.source", "https://tiles.services.mozilla.com/v3/links/fetch/%LOCALE%/%CHANNEL%");
--- a/browser/base/content/newtab/intro.js
+++ b/browser/base/content/newtab/intro.js
@@ -1,16 +1,17 @@
 #ifdef 0
 /* 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/. */
 #endif
 
 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";
 const UPDATE = "update";
 
 // The maximum paragraph ID listed for 'newtab.intro.paragraph'
 // strings in newTab.properties
 const MAX_PARAGRAPH_ID = 9;
@@ -200,16 +201,19 @@ let gIntro = {
         this._paragraphs.push(newTabString(name, substringMappings[i]));
       } catch (ex) {
         // Paragraph with this ID doesn't exist so continue
       }
     }
   },
 
   showIfNecessary: function() {
+    if (!Services.prefs.getBoolPref(PREF_NEWTAB_ENHANCED)) {
+      return;
+    }
     if (!Services.prefs.getBoolPref(PREF_INTRO_SHOWN)) {
       this._onboardingType = WELCOME;
       this.showPanel();
     } else if (!Services.prefs.getBoolPref(PREF_UPDATE_INTRO_SHOWN)) {
       this._onboardingType = UPDATE;
       this.showPanel();
     }
     Services.prefs.setBoolPref(PREF_INTRO_SHOWN, true);
--- a/browser/base/content/newtab/page.js
+++ b/browser/base/content/newtab/page.js
@@ -49,16 +49,17 @@ let gPage = {
       gCustomize.updateSelected();
 
       let enabled = gAllPages.enabled;
       this._updateAttributes(enabled);
 
       // 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.
       if (enabled) {
         this._init();
       } else {
         gUndoDialog.hide();
       }
--- a/browser/modules/DirectoryLinksProvider.jsm
+++ b/browser/modules/DirectoryLinksProvider.jsm
@@ -383,17 +383,17 @@ let DirectoryLinksProvider = {
     return "en-US";
   },
 
   /**
    * Set appropriate default ping behavior controlled by enhanced pref
    */
   _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")) {
           enhanced = false;
         }
       }
       catch(ex) {}
       Services.prefs.setBoolPref(PREF_NEWTAB_ENHANCED, enhanced);