From 0ae71e68c0020c7d000eb204dfa2cdd99fe758e6 Mon Sep 17 00:00:00 2001 From: groovecoder Date: Wed, 15 Feb 2017 15:17:16 -0600 Subject: [PATCH] fix #174: remove add-on containers on uninstall --- index.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 357fc1c..57abfb5 100644 --- a/index.js +++ b/index.js @@ -66,10 +66,16 @@ const ContainerService = { // uninstallation. This object contains also a version number, in case we // need to implement a migration in the future. if (installation) { + let preInstalledIdentities = []; // eslint-disable-line prefer-const + ContextualIdentityService.getIdentities().forEach(identity => { + preInstalledIdentities.push(identity.userContextId); + }); + const object = { version: 1, prefs: {}, metricsUUID: uuid.uuid().toString(), + preInstalledIdentities: preInstalledIdentities }; PREFS.forEach(pref => { @@ -850,9 +856,6 @@ const ContainerService = { CustomizableUI.createWidget(widget); } - // Let's delete the configuration. - delete ss.storage.savedConfiguration; - for (let window of windows.browserWindows) { // eslint-disable-line prefer-const this._getOrCreateContainerWindow(viewFor(window)).shutdown(); } @@ -869,6 +872,16 @@ const ContainerService = { } } this._closeTabs(tabsToClose); + + const preInstalledIdentities = data.preInstalledIdentities; + ContextualIdentityService.getIdentities().forEach(identity => { + if (!preInstalledIdentities.includes(identity.userContextId)) { + ContextualIdentityService.remove(identity.userContextId); + } + }); + + // Let's delete the configuration. + delete ss.storage.savedConfiguration; }, };