Bug 640873 - Homepage fails to load 'No recent tabs' in new profiles [r=mbrubeck a=dougt]
authorMark Finkle <mfinkle@mozilla.com>
Wed, 16 Mar 2011 16:36:49 -0400
changeset 2917 6b93fd7423c4f9b053da56c21a99202cc1954fdf
parent 2916 90d505ee8f9b801afff34386683b0f1727f7fce4
child 2918 f8f616b259ff161731ca21a9910d8a2554598068
push id2461
push usermfinkle@mozilla.com
push dateWed, 16 Mar 2011 20:37:41 +0000
reviewersmbrubeck, dougt
bugs640873
Bug 640873 - Homepage fails to load 'No recent tabs' in new profiles [r=mbrubeck a=dougt]
chrome/content/aboutHome.xhtml
--- a/chrome/content/aboutHome.xhtml
+++ b/chrome/content/aboutHome.xhtml
@@ -156,23 +156,34 @@
       let BrowserUI = getChromeWin().BrowserUI;
       let owner = getChromeWin().Browser.selectedTab;
       for (let i=0; i < aURLs.length; i++) {
         BrowserUI.newTab(aURLs[i], owner);
       }
     }
 
     function initTabs() {
+      function noRecentTabs() {
+        let placeHolder = document.getElementById("loadingTabs");
+        placeHolder.innerHTML = "<div class='no-items'>" + document.getElementById("text-notabs").textContent + "</div>";
+      }
+
       let dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
       let session = dirService.get("ProfD", Ci.nsILocalFile);
       session.append("sessionstore.bak");
+      if (!session.exists()) {
+        noRecentTabs();
+        return;
+      }
 
       let data = JSON.parse(_readFile(session));
-      if (!data || data.windows.length == 0)
+      if (!data || data.windows.length == 0) {
+        noRecentTabs();
         return;
+      }
 
       let chromeWin = getChromeWin();
       let allPageURLs = [];
 
       let list = document.getElementById("recentTabs");
 
       let tabs = data.windows[0].tabs;
       for (let i=0; i<tabs.length; i++) {
@@ -230,18 +241,17 @@
 
           outer.addEventListener("click", function() {
             openTabs(allPageURLs);
           }, false);
 
           list.appendChild(outer);
         }
       } else {
-        let placeHolder = document.getElementById("loadingTabs");
-        placeHolder.innerHTML = "<div class='no-items'>" + document.getElementById("text-notabs").textContent + "</div>";
+        noRecentTabs();
       }
     }
 
     function openRemoteTabs() {
       getChromeWin().CommandUpdater.doCommand("cmd_remoteTabs");
     }
 
     function goToAddons(aSearchString) {
@@ -343,18 +353,18 @@
             let aus = Cc["@mozilla.org/browser/addon-update-service;1"].getService(Ci.nsITimerCallback);
             aus.notify(null);
           }, aDelay);
         }
       }
     }
 
     function updateAddons() {
-      // If a cache does not exist, start an update after 10 seconds
-      RecommendedAddons.loadFromCacheOrScheduleUpdate(10000);
+      // If a cache does not exist, start an update after 6 seconds
+      RecommendedAddons.loadFromCacheOrScheduleUpdate(6000);
     }
 
     function initAddons() {
       getChromeWin().Services.obs.addObserver(updateAddons, "recommended-addons-cache-updated", false);
       updateAddons();
     }
 
     function uninitAddons() {