From c831107cdb2e8eb8a3c140ccd05882845069c192 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Tue, 5 May 2015 17:21:33 -0700 Subject: [PATCH] Bug 1155521 - Migrate Pocket add-on and social provider users to the new Pocket button (part 1, CustomizableUI changes). r=jaws --- .../customizableui/CustomizableUI.jsm | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index e9cf54f42928..33c90788a641 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -294,13 +294,32 @@ let CustomizableUIInternal = { let currentVersion = gSavedState.currentVersion; for (let [id, widget] of gPalette) { - if (widget._introducedInVersion > currentVersion && - widget.defaultArea) { - let futurePlacements = gFuturePlacements.get(widget.defaultArea); - if (futurePlacements) { - futurePlacements.add(id); - } else { - gFuturePlacements.set(widget.defaultArea, new Set([id])); + if (widget.defaultArea) { + let shouldAdd = false; + let shouldSetPref = false; + let prefId = "browser.toolbarbuttons.introduced." + widget.id; + if (widget._introducedInVersion === "pref") { + try { + shouldAdd = !Services.prefs.getBoolPref(prefId); + } catch (ex) { + // Pref doesn't exist: + shouldAdd = true; + } + shouldSetPref = shouldAdd; + } else if (widget._introducedInVersion > currentVersion) { + shouldAdd = true; + } + + if (shouldAdd) { + let futurePlacements = gFuturePlacements.get(widget.defaultArea); + if (futurePlacements) { + futurePlacements.add(id); + } else { + gFuturePlacements.set(widget.defaultArea, new Set([id])); + } + if (shouldSetPref) { + Services.prefs.setBoolPref(prefId, true); + } } } }