Bug 1247114 - do a one-off move of the synced-tabs button to the panel if Sync is initialized. r=Gijs
authorMark Hammond <mhammond@skippinet.com.au>
Tue, 16 Feb 2016 12:22:19 +1100
changeset 331219 1ba422314bc61c2cbf657f8c76ffff7e10a9082e
parent 331218 438b42019921171cdbcbad79dc216d185cad1b5f
child 331220 49adf1dee4ddf45d6090c5c7849b512ad8377f6c
push id10938
push userBogdan.Postelnicu@softvision.ro
push dateTue, 16 Feb 2016 15:52:05 +0000
reviewersGijs
bugs1247114
milestone47.0a1
Bug 1247114 - do a one-off move of the synced-tabs button to the panel if Sync is initialized. r=Gijs
browser/base/content/browser-syncui.js
--- a/browser/base/content/browser-syncui.js
+++ b/browser/base/content/browser-syncui.js
@@ -82,16 +82,18 @@ var gSyncUI = {
     broadcaster.setAttribute("label", this._stringBundle.GetStringFromName("syncnow.label"));
 
     // Initialize the Synced Tabs Sidebar
     if (Services.prefs.getBoolPref("services.sync.syncedTabsUIRefresh")) {
       let sidebarBroadcaster = document.getElementById("viewTabsSidebar");
       sidebarBroadcaster.removeAttribute("hidden");
     }
 
+    this.maybeMoveSyncedTabsButton();
+
     this.updateUI();
   },
 
 
   // Returns a promise that resolves with true if Sync needs to be configured,
   // false otherwise.
   _needsSetup() {
     // If Sync is configured for FxAccounts then we do that promise-dance.
@@ -327,16 +329,38 @@ var gSyncUI = {
         PanelUI.showSubView("PanelUI-remotetabs", anchor, area);
       }).catch(Cu.reportError);
     } else {
       // It is placed somewhere else - just try and show it.
       PanelUI.showSubView("PanelUI-remotetabs", anchor, area);
     }
   },
 
+  /* After Sync is initialized we perform a once-only check for the sync
+     button being in "customize purgatory" and if so, move it to the panel.
+     This is done primarily for profiles created before SyncedTabs landed,
+     where the button defaulted to being in that purgatory.
+     We use a preference to ensure we only do it once, so people can still
+     customize it away and have it stick.
+  */
+  maybeMoveSyncedTabsButton() {
+    const prefName = "browser.migrated-sync-button";
+    let migrated = false;
+    try {
+      migrated = Services.prefs.getBoolPref(prefName);
+    } catch (_) {}
+    if (migrated) {
+      return;
+    }
+    if (!CustomizableUI.getPlacementOfWidget("sync-button")) {
+      CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_PANEL);
+    }
+    Services.prefs.setBoolPref(prefName, true);
+  },
+
   /* Update the tooltip for the sync-status broadcaster (which will update the
      Sync Toolbar button and the Sync spinner in the FxA hamburger area.)
      If Sync is configured, the tooltip is when the last sync occurred,
      otherwise the tooltip reflects the fact that Sync needs to be
      (re-)configured.
   */
   _updateSyncButtonsTooltip: Task.async(function* () {
     if (!gBrowser)