Bug 1126186: Allow users to turn off all tiles that aren't history tiles and update newtab cogmenu wording. r=adw, a=sylvestre
authorMarina Samuel <msamuel@mozilla.com>
Fri, 20 Mar 2015 17:28:15 -0400
changeset 258192 db2b58500934
parent 258191 e9021ea8d7ca
child 258193 56763fc69140
push id4619
push useredilee@gmail.com
push date2015-04-02 05:50 +0000
treeherdermozilla-beta@daf8a9291a9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw, sylvestre
bugs1126186
milestone38.0
Bug 1126186: Allow users to turn off all tiles that aren't history tiles and update newtab cogmenu wording. r=adw, a=sylvestre
browser/base/content/newtab/newTab.css
browser/base/content/newtab/page.js
browser/base/content/test/newtab/browser_newtab_enhanced.js
toolkit/modules/NewTabUtils.jsm
toolkit/modules/tests/xpcshell/test_NewTabUtils.js
--- a/browser/base/content/newtab/newTab.css
+++ b/browser/base/content/newtab/newTab.css
@@ -486,17 +486,17 @@ input[type=button] {
 #newtab-customize-panel > .panel-arrowcontainer > .panel-arrowcontent,
 #newtab-search-panel > .panel-arrowcontainer > .panel-arrowcontent {
   padding: 0;
 }
 
 .newtab-customize-panel-item,
 .newtab-search-panel-engine,
 #newtab-search-manage {
-  padding: 4px 24px;
+  padding: 10px 10px 10px 25px;
 }
 
 .newtab-customize-panel-item:not(:last-child),
 .newtab-search-panel-engine {
   border-bottom: 1px solid threedshadow;
 }
 
 .newtab-search-panel-engine > image {
@@ -508,16 +508,20 @@ input[type=button] {
 
 .newtab-customize-panel-item > label,
 .newtab-search-panel-engine > label,
 #newtab-search-manage > label {
   padding: 0;
   margin: 0;
 }
 
+.newtab-customize-panel-item:not([selected]) {
+  color: #919191;
+}
+
 .newtab-customize-panel-item[selected],
 .newtab-search-panel-engine[selected] {
   background: url("chrome://global/skin/menu/shared-menu-check.png") center left 4px no-repeat transparent;
   background-size: 16px 16px;
 }
 
 @media (min-resolution: 2dppx) {
   .newtab-customize-panel-item[selected],
--- a/browser/base/content/newtab/page.js
+++ b/browser/base/content/newtab/page.js
@@ -36,16 +36,24 @@ let gPage = {
 
     // Initialize customize controls.
     gCustomize.init();
 
     // Initialize intro panel.
     gIntro.init();
   },
 
+  _updateCogMenuStringsForEnUS: function() {
+    if (DirectoryLinksProvider.locale == "en-US") {
+      document.querySelector("#newtab-customize-enhanced label").innerHTML = "Show suggested and your top sites";
+      document.querySelector("#newtab-customize-classic label").innerHTML = "Show your top sites";
+      document.querySelector("#newtab-customize-blank label").innerHTML = "Show blank page";
+    }
+  },
+
   /**
    * Listens for notifications specific to this page.
    */
   observe: function Page_observe(aSubject, aTopic, aData) {
     if (aTopic == "nsPref:changed") {
       gCustomize.updateSelected();
 
       let enabled = gAllPages.enabled;
@@ -139,29 +147,31 @@ let gPage = {
 #endif
   },
 
   /**
    * Updates the 'page-disabled' attributes of the respective DOM nodes.
    * @param aValue Whether the New Tab Page is enabled or not.
    */
   _updateAttributes: function Page_updateAttributes(aValue) {
+    this._updateCogMenuStringsForEnUS();
+
     // Set the nodes' states.
     let nodeSelector = "#newtab-scrollbox, #newtab-grid, #newtab-search-container";
     for (let node of document.querySelectorAll(nodeSelector)) {
       if (aValue)
         node.removeAttribute("page-disabled");
       else
         node.setAttribute("page-disabled", "true");
     }
 
     // Enables/disables the control and link elements.
     let inputSelector = ".newtab-control, .newtab-link";
     for (let input of document.querySelectorAll(inputSelector)) {
-      if (aValue) 
+      if (aValue)
         input.removeAttribute("tabindex");
       else
         input.setAttribute("tabindex", "-1");
     }
   },
 
   /**
    * Handles all page events.
--- a/browser/base/content/test/newtab/browser_newtab_enhanced.js
+++ b/browser/base/content/test/newtab/browser_newtab_enhanced.js
@@ -35,32 +35,32 @@ function runTests() {
 
   // Make the page have a directory link followed by a history link
   yield setLinks("-1");
 
   // Test with enhanced = false
   yield addNewTabPageTab();
   yield customizeNewTabPage("classic");
   let {type, enhanced, title} = getData(0);
+  isnot(type, "enhanced", "history link is not enhanced");
+  is(enhanced, "", "history link has no enhanced image");
+  is(title, "site#-1");
+
+  is(getData(1), null, "there is only one link and it's a history link");
+
+  // Test with enhanced = true
+  yield addNewTabPageTab();
+  yield customizeNewTabPage("enhanced");
+  ({type, enhanced, title} = getData(0));
   is(type, "organic", "directory link is organic");
   isnot(enhanced, "", "directory link has enhanced image");
   is(title, "title");
 
   is(getData(1), null, "history link pushed out by directory link");
 
-  // Test with enhanced = true
-  yield addNewTabPageTab();
-  yield customizeNewTabPage("enhanced");
-  ({type, enhanced, title} = getData(0));
-  is(type, "organic", "directory link is still organic");
-  isnot(enhanced, "", "directory link still has enhanced image");
-  is(title, "title");
-
-  is(getData(1), null, "history link still pushed out by directory link");
-
   // Test with a pinned link
   setPinnedLinks("-1");
   yield addNewTabPageTab();
   ({type, enhanced, title} = getData(0));
   is(type, "enhanced", "pinned history link is enhanced");
   isnot(enhanced, "", "pinned history link has enhanced image");
   is(title, "title");
 
--- a/toolkit/modules/NewTabUtils.jsm
+++ b/toolkit/modules/NewTabUtils.jsm
@@ -930,17 +930,22 @@ let Links = {
 
   /**
    * Merges the cached lists of links from all providers whose lists are cached.
    * @return The merged list.
    */
   _getMergedProviderLinks: function Links__getMergedProviderLinks() {
     // Build a list containing a copy of each provider's sortedLinks list.
     let linkLists = [];
-    for (let links of this._providers.values()) {
+    for (let provider of this._providers.keys()) {
+      if (!AllPages.enhanced && provider != PlacesProvider) {
+        // Only show history tiles if we're not in 'enhanced' mode.
+        continue;
+      }
+      let links = this._providers.get(provider);
       if (links && links.sortedLinks) {
         linkLists.push(links.sortedLinks.slice());
       }
     }
 
     function getNextLink() {
       let minLinks = null;
       for (let links of linkLists) {
--- a/toolkit/modules/tests/xpcshell/test_NewTabUtils.js
+++ b/toolkit/modules/tests/xpcshell/test_NewTabUtils.js
@@ -2,18 +2,22 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // See also browser/base/content/test/newtab/.
 
 const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
 Cu.import("resource://gre/modules/NewTabUtils.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+const PREF_NEWTAB_ENHANCED = "browser.newtabpage.enhanced";
 
 function run_test() {
+  Services.prefs.setBoolPref(PREF_NEWTAB_ENHANCED, true);
   run_next_test();
 }
 
 add_task(function notifyLinkDelete() {
   let expectedLinks = makeLinks(0, 3, 1);
 
   let provider = new TestProvider(done => done(expectedLinks));
   provider.maxNumLinks = expectedLinks.length;