From b509de8f99d7e20c996630f87db0ef8a436070c4 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Tue, 24 Aug 2010 10:49:32 +0200 Subject: [PATCH] Bug 559372 - Fennec start page still shows weave tabs option after logging out of Weave [r=mfinkle] --- mobile/chrome/content/aboutHome.xhtml | 33 +++++++++++++++++++++++---- mobile/chrome/content/browser-ui.js | 4 ++++ mobile/chrome/content/browser.xul | 8 +++++++ mobile/chrome/jar.mn | 2 ++ mobile/themes/core/aboutHome.css | 9 ++++++++ 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/mobile/chrome/content/aboutHome.xhtml b/mobile/chrome/content/aboutHome.xhtml index 9689dfd3a4ee..2a02e67d08bf 100644 --- a/mobile/chrome/content/aboutHome.xhtml +++ b/mobile/chrome/content/aboutHome.xhtml @@ -58,7 +58,7 @@ - +
@@ -69,7 +69,7 @@
-
+
&aboutHome.remoteTabs;
@@ -119,6 +119,10 @@ initAddons(); } + function uninit() { + uninitWeave(); + } + function _readFile(aFile) { try { let stream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream); @@ -212,11 +216,11 @@ outer.className = "openall"; outer.textContent = document.getElementById("text-openalltabs").textContent; outer.setAttribute("role", "button"); - + outer.addEventListener("click", function() { openTabs(allPageURLs); }, false); - + list.appendChild(outer); } } else { @@ -226,8 +230,27 @@ } function initWeave() { - if (!("WeaveGlue" in getChromeWin())) + 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); + } + else { document.getElementById("remoteTabs").style.display = "none"; + } + } + + 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"); + } + } + + function updateWeaveButton() { + let isDisabled = !getChromeWin().Weave.Service.isLoggedIn; + document.getElementById("remoteTabs").setAttribute("disabled", isDisabled); } function openRemoteTabs() { diff --git a/mobile/chrome/content/browser-ui.js b/mobile/chrome/content/browser-ui.js index ede16ad315ba..3af1efceda41 100644 --- a/mobile/chrome/content/browser-ui.js +++ b/mobile/chrome/content/browser-ui.js @@ -425,8 +425,10 @@ var BrowserUI = { .ensureContentProcess(); #endif +#ifdef MOZ_SERVICES_SYNC // Init the sync system WeaveGlue.init(); +#endif }); FormHelperUI.init(); @@ -2255,9 +2257,11 @@ XPCOMUtils.defineLazyGetter(this, "HistoryList", function() { return new AwesomePanel("history-items", "cmd_history"); }); +#ifdef MOZ_SERVICES_SYNC XPCOMUtils.defineLazyGetter(this, "RemoteTabsList", function() { return new AwesomePanel("remotetabs-items", "cmd_remoteTabs"); }); +#endif XPCOMUtils.defineLazyGetter(this, "AllPagesList", function() { return new AwesomePanel("popup_autocomplete", "cmd_openLocation"); diff --git a/mobile/chrome/content/browser.xul b/mobile/chrome/content/browser.xul index ffc2c24e777c..a29ad23eb86b 100644 --- a/mobile/chrome/content/browser.xul +++ b/mobile/chrome/content/browser.xul @@ -87,7 +87,9 @@