summaryrefslogtreecommitdiffstats
path: root/application/basilisk/components/preferences/in-content/containers.js
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-06-04 15:50:03 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-06-04 15:50:03 +0200
commite3b7744bee37c3d4a026d2193bed5e9439c40ff3 (patch)
treef3f7b07ca9bd78bf7ac2d76dd55b61b2a8bb549e /application/basilisk/components/preferences/in-content/containers.js
parentcbce4f0b6a337f8250b62cae028f1c6d4cce51df (diff)
parent031afcafe288bf0f46c0c5caae20dd3db8bd0297 (diff)
downloadUXP-e3b7744bee37c3d4a026d2193bed5e9439c40ff3.tar
UXP-e3b7744bee37c3d4a026d2193bed5e9439c40ff3.tar.gz
UXP-e3b7744bee37c3d4a026d2193bed5e9439c40ff3.tar.lz
UXP-e3b7744bee37c3d4a026d2193bed5e9439c40ff3.tar.xz
UXP-e3b7744bee37c3d4a026d2193bed5e9439c40ff3.zip
Merge branch 'move-basilisk'
Diffstat (limited to 'application/basilisk/components/preferences/in-content/containers.js')
-rw-r--r--application/basilisk/components/preferences/in-content/containers.js73
1 files changed, 73 insertions, 0 deletions
diff --git a/application/basilisk/components/preferences/in-content/containers.js b/application/basilisk/components/preferences/in-content/containers.js
new file mode 100644
index 000000000..758e45fff
--- /dev/null
+++ b/application/basilisk/components/preferences/in-content/containers.js
@@ -0,0 +1,73 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+Components.utils.import("resource://gre/modules/AppConstants.jsm");
+Components.utils.import("resource://gre/modules/ContextualIdentityService.jsm");
+
+const containersBundle = Services.strings.createBundle("chrome://browser/locale/preferences/containers.properties");
+
+const defaultContainerIcon = "fingerprint";
+const defaultContainerColor = "blue";
+
+let gContainersPane = {
+
+ init() {
+ this._list = document.getElementById("containersView");
+
+ document.getElementById("backContainersLink").addEventListener("click", function () {
+ gotoPref("privacy");
+ });
+
+ this._rebuildView();
+ },
+
+ _rebuildView() {
+ const containers = ContextualIdentityService.getIdentities();
+ while (this._list.firstChild) {
+ this._list.firstChild.remove();
+ }
+ for (let container of containers) {
+ let item = document.createElement("richlistitem");
+ item.setAttribute("containerName", ContextualIdentityService.getUserContextLabel(container.userContextId));
+ item.setAttribute("containerIcon", container.icon);
+ item.setAttribute("containerColor", container.color);
+ item.setAttribute("userContextId", container.userContextId);
+
+ this._list.appendChild(item);
+ }
+ },
+
+ onRemoveClick(button) {
+ let userContextId = button.getAttribute("value");
+ ContextualIdentityService.remove(userContextId);
+ this._rebuildView();
+ },
+ onPeferenceClick(button) {
+ this.openPreferenceDialog(button.getAttribute("value"));
+ },
+
+ onAddButtonClick(button) {
+ this.openPreferenceDialog(null);
+ },
+
+ openPreferenceDialog(userContextId) {
+ let identity = {
+ name: "",
+ icon: defaultContainerIcon,
+ color: defaultContainerColor
+ };
+ let title;
+ if (userContextId) {
+ identity = ContextualIdentityService.getIdentityFromId(userContextId);
+ // This is required to get the translation string from defaults
+ identity.name = ContextualIdentityService.getUserContextLabel(identity.userContextId);
+ title = containersBundle.formatStringFromName("containers.updateContainerTitle", [identity.name], 1);
+ }
+
+ const params = { userContextId, identity, windowTitle: title };
+ gSubDialog.open("chrome://browser/content/preferences/containers.xul",
+ null, params);
+ }
+
+};