Bug 1249574 - send the notification about synced tab state changing as the tabs engine is enabled or disabled. r=rnewman
authorMark Hammond <mhammond@skippinet.com.au>
Thu, 03 Mar 2016 12:20:41 +1100
changeset 322777 6a355b46c68b43c0df96978a25b36b661dd98737
parent 322776 c3b966f02d76216762764360516aa777ad505d07
child 322778 09d8e3caf51daf1554673799609b575de4383a02
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1249574
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1249574 - send the notification about synced tab state changing as the tabs engine is enabled or disabled. r=rnewman
services/sync/modules/SyncedTabs.jsm
--- a/services/sync/modules/SyncedTabs.jsm
+++ b/services/sync/modules/SyncedTabs.jsm
@@ -203,16 +203,19 @@ let SyncedTabsInternal = {
         Preferences.set("services.sync.lastTabFetch", Math.floor(Date.now() / 1000));
         Services.obs.notifyObservers(null, TOPIC_TABS_CHANGED, null);
         break;
       case "weave:service:start-over":
         // start-over needs to notify so consumers find no tabs.
         Preferences.reset("services.sync.lastTabFetch");
         Services.obs.notifyObservers(null, TOPIC_TABS_CHANGED, null);
         break;
+      case "nsPref:changed":
+        Services.obs.notifyObservers(null, TOPIC_TABS_CHANGED, null);
+        break;
       default:
         break;
     }
   },
 
   // Returns true if Sync is configured to Sync tabs, false otherwise
   get isConfiguredToSyncTabs() {
     if (!weaveXPCService.ready) {
@@ -227,16 +230,20 @@ let SyncedTabsInternal = {
   get hasSyncedThisSession() {
     let engine = Weave.Service.engineManager.get("tabs");
     return engine && engine.hasSyncedThisSession;
   },
 };
 
 Services.obs.addObserver(SyncedTabsInternal, "weave:engine:sync:finish", false);
 Services.obs.addObserver(SyncedTabsInternal, "weave:service:start-over", false);
+// Observe the pref the indicates the state of the tabs engine has changed.
+// This will force consumers to re-evaluate the state of sync and update
+// accordingly.
+Services.prefs.addObserver("services.sync.engine.tabs", SyncedTabsInternal, false);
 
 // The public interface.
 this.SyncedTabs = {
   // A mock-point for tests.
   _internal: SyncedTabsInternal,
 
   // We make the topic for the observer notification public.
   TOPIC_TABS_CHANGED,