Bug 600815 - Warnings into browser.js and about:home [r=vingtetun]
authorMark Finkle <mfinkle@mozilla.com>
Wed, 06 Oct 2010 11:04:46 -0400
changeset 66784 77124e7087748768e31bbf7f5ebc9aaac7ebb06f
parent 66783 ed9d6ab1ebadf1557ef8303a9133e14cf252cfd3
child 66785 2e8f176661102b3d8873cbe02dff692ff8d5fcdd
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvingtetun
bugs600815
Bug 600815 - Warnings into browser.js and about:home [r=vingtetun]
mobile/chrome/content/aboutHome.xhtml
mobile/chrome/content/bindings.xml
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/aboutHome.xhtml
+++ b/mobile/chrome/content/aboutHome.xhtml
@@ -227,44 +227,31 @@
       } else {
         let placeHolder = document.getElementById("loadingTabs");
         placeHolder.innerHTML = "<div class='no-items'>" + document.getElementById("text-notabs").textContent + "</div>";
       }
     }
 
     function initWeave() {
       let chromeWin = getChromeWin();
-      if ("WeaveGlue" in chromeWin) {
-        chromeWin.Services.obs.addObserver(updateWeaveButton, "weave:service:login:finish", false);
-        chromeWin.Services.obs.addObserver(updateWeaveButton, "weave:service:logout:finish", false);
+      chromeWin.Services.obs.addObserver(updateWeaveButton, "weave:service:login:finish", false);
+      chromeWin.Services.obs.addObserver(updateWeaveButton, "weave:service:logout:finish", false);
 
-        updateWeaveButton();
-      }
-      else {
-        let loading = document.getElementById("remoteTabs");
-        loading.parentNode.removeChild(loading);
-      }
+      updateWeaveButton();
     }
 
     function uninitWeave() {
       let chromeWin = getChromeWin();
-      if ("WeaveGlue" in chromeWin) {
-        chromeWin.Services.obs.removeObserver(updateWeaveButton, "weave:service:login:finish");
-        chromeWin.Services.obs.removeObserver(updateWeaveButton, "weave:service:logout:finish");
-      }
+      chromeWin.Services.obs.removeObserver(updateWeaveButton, "weave:service:login:finish");
+      chromeWin.Services.obs.removeObserver(updateWeaveButton, "weave:service:logout:finish");
     }
 
     function updateWeaveButton() {
-      let weave = getChromeWin().Weave;
-      if (!weave)
-        return;
-
-      let isDisabled =
-        (weave.Status.checkSetup() == weave.CLIENT_NOT_CONFIGURED)
-        || !weave.Service.isLoggedIn;
+      let chromeWin = getChromeWin();
+      let isDisabled = chromeWin.document.getElementById("cmd_remoteTabs").getAttribute("disabled");
       document.getElementById("remoteTabs").setAttribute("disabled", isDisabled);
     }
 
     function openRemoteTabs() {
       getChromeWin().CommandUpdater.doCommand("cmd_remoteTabs");
     }
 
     function goToAddons(aSearchString) {
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -386,24 +386,37 @@
       <method name="_invalidateBadges">
         <body><![CDATA[
           window.clearTimeout(this._badgesTimeout);
 
           this._badgesTimeout = window.setTimeout(function(self) {
 #ifdef MOZ_SERVICES_SYNC
             let remoteItems = RemoteTabsList.panel._getRemoteTabs();
 #endif
-
             for (let i = 0; i < self._items.childNodes.length; i++) {
               let item = self._items.childNodes[i];
               if (!item.hasAttribute("url"))
                 continue;
 
               let currentURL = item.getAttribute("url");
               let itemHost = self._getEffectiveHost(Services.io.newURI(currentURL, null, null));
+
+#ifdef MOZ_SERVICES_SYNC
+              // check if the tab is in the remote list
+              for (let i = 0; i < remoteItems.length; i++) {
+                let remoteURI = remoteItems[i].uri;
+                if (remoteURI) {
+                  let itemHost = Services.io.newURI(currentURL, null, null);
+                  let remoteHost = Services.io.newURI(remoteURI, null, null);
+                  if (itemHost.equals(remoteHost))
+                    item.setAttribute("remote", "true");
+                }
+              }
+#endif
+
               for (let badgeHost in self._badges) {
                 if (itemHost == badgeHost) {
                   // wrap the item to prevent setting a badge on a wrong item
                   let wrapper = {
                     set: function(aBadge) {
                       if (item.getAttribute("url") != currentURL)
                         return;
 
@@ -414,32 +427,16 @@
                     }
                   };
 
                   let handler = self._badges[badgeHost];
                   handler.updateBadge ? handler.updateBadge(wrapper) : handler(wrapper);
                   break;
                 }
               }
-
-#ifdef MOZ_SERVICES_SYNC
-              // once we have check badges, check if the tab is in the remote list
-              if (!Weave.Service.isLoggedIn)
-                return;
-
-              for (let i = 0; i < remoteItems.length; i++) {
-                let remoteURI = remoteItems[i].uri;
-                if (remoteURI) {
-                  let itemHost = Services.io.newURI(currentURL, null, null);
-                  let remoteHost = Services.io.newURI(remoteURI, null, null);
-                  if (itemHost.equals(remoteHost))
-                    item.setAttribute("remote", "true");
-                }
-              }
-#endif
             }
           }, 300, this);
         ]]></body>
       </method>
 
       <!-- Helpers -->
       <field name="_items">
         document.getAnonymousElementByAttribute(this,
@@ -1237,16 +1234,20 @@
       <field name="_children">
         document.getAnonymousElementByAttribute(this, "anonid", "child-items");
       </field>
 
       <field name="scrollBoxObject">this._children.scrollBoxObject</field>
 
       <method name="_getRemoteTabs">
         <body><![CDATA[
+          // Don't do anything if the Weave isn't ready
+          if (document.getElementById("cmd_remoteTabs").getAttribute("disabled") == "true")
+            return [];
+
           // Don't do anything if the tabs engine isn't ready
           let engine = Weave.Engines.get("tabs");
           if (!engine)
             return [];
 
           // Don't bother refetching tabs if we already did so recently
           let lastFetch = Weave.Svc.Prefs.get("lastTabFetch", 0);
           let now = Math.floor(Date.now() / 1000);
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -236,16 +236,19 @@ var Browser = {
     pageScrollbox.customDragger = controlsScrollbox.customDragger;
 
     let stylesheet = document.styleSheets[0];
     for each (let style in ["window-width", "window-height", "toolbar-height"]) {
       let index = stylesheet.insertRule("." + style + " {}", stylesheet.cssRules.length);
       this.styles[style] = stylesheet.cssRules[index].style;
     }
 
+    // Init the cache used in the resize handler
+    window.cachedWidth = window.innerWidth;
+
     function resizeHandler(e) {
       if (e.target != window)
         return;
 
       let w = window.innerWidth;
       let h = window.innerHeight;
 
       // XXX is this code right here actually needed?