Bug 702297 - Disable Recently Closed Tabs/Windows in the Go Menu when empty. r=IanN a=Callek
authorEdmund Wong <ewong@pw-wspx.org>
Wed, 30 Nov 2011 12:59:20 +0800
changeset 9769 1430d8e9f084e75732865283f5cfd9da92a9af3f
parent 9762 308536744457d6466d06a26a0250a677139e216d
child 9770 7acacf881840bf178590764a7498dd75d558c3ae
push id300
push userjh@junetz.de
push dateSat, 07 Jan 2012 21:41:45 +0000
treeherdercomm-beta@7acacf881840 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, Callek
bugs702297
Bug 702297 - Disable Recently Closed Tabs/Windows in the Go Menu when empty. r=IanN a=Callek
suite/browser/navigator.js
suite/browser/sessionHistoryUI.js
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -1396,18 +1396,16 @@ function BrowserOpenFileWindow()
   try {
     openTopWin(selectFileToOpen("openFile", "browser.open.").spec);
   } catch (e) {}
 }
 
 function updateCloseItems()
 {
   var browser = getBrowser();
-  var ss = Components.classes["@mozilla.org/suite/sessionstore;1"]
-                     .getService(Components.interfaces.nsISessionStore);
 
   var hideCloseWindow = Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab") &&
                         (!browser || browser.tabContainer.childNodes.length <= 1);
   document.getElementById("menu_closeWindow").hidden = hideCloseWindow;
   var closeItem = document.getElementById("menu_close");
   if (hideCloseWindow) {
     closeItem.setAttribute("label", gNavigatorBundle.getString("tabs.close.label"));
     closeItem.setAttribute("accesskey", gNavigatorBundle.getString("tabs.close.accesskey"));
@@ -1416,16 +1414,25 @@ function updateCloseItems()
     closeItem.setAttribute("accesskey", gNavigatorBundle.getString("tabs.closeTab.accesskey"));
   }
 
   var hideCloseOtherTabs = !browser || !browser.getStripVisibility();
   document.getElementById("menu_closeOtherTabs").hidden = hideCloseOtherTabs;
   if (!hideCloseOtherTabs)
     document.getElementById("cmd_closeOtherTabs").setAttribute("disabled", hideCloseWindow);
 
+  updateRecentMenuItems();
+}
+
+function updateRecentMenuItems()
+{
+  var browser = getBrowser();
+  var ss = Components.classes["@mozilla.org/suite/sessionstore;1"]
+                     .getService(Components.interfaces.nsISessionStore);
+
   var recentTabsItem = document.getElementById("menu_recentTabs");
   recentTabsItem.setAttribute("disabled", !browser || browser.getUndoList().length == 0);
   var recentWindowsItem = document.getElementById("menu_recentWindows");
   recentWindowsItem.setAttribute("disabled", ss.getClosedWindowCount() == 0);
 }
 
 function updateRecentTabs(menupopup)
 {
--- a/suite/browser/sessionHistoryUI.js
+++ b/suite/browser/sessionHistoryUI.js
@@ -183,9 +183,10 @@ function deleteHistoryItems(aParent)
         if (index)
           aParent.removeChild( children[i] );
       }
   }
 
 function updateGoMenu(event)
   {
     FillHistoryMenu(event.target, "go");
+    updateRecentMenuItems();
   }