|
57 | 57 |
|
58 | 58 | opt("cascadeRestrictions");
|
59 | 59 |
|
| 60 | + opt("containers", async o => { |
| 61 | + if (o) { |
| 62 | + contextStore.enabled = o.checked; |
| 63 | + await contextStore.updateContainers(policy); |
| 64 | + UI.updateSettings({contextStore}); |
| 65 | + } |
| 66 | + updateContainersEnabled(); |
| 67 | + return contextStore.enabled; |
| 68 | + }) |
| 69 | + |
60 | 70 | opt("xss");
|
61 | 71 |
|
62 | 72 | opt("overrideTorBrowserPolicy");
|
|
175 | 185 | var cookieStoreId = containerSelect.value;
|
176 | 186 | var currentPolicy = await UI.getPolicy(cookieStoreId);
|
177 | 187 |
|
178 |
| - containerSelect.hidden = !browser.contextualIdentities; |
179 |
| - document.querySelector("#select-container-label").hidden = containerSelect.hidden; |
180 |
| - if (!browser.contextualIdentities) document.querySelector("#per-site-buttons").style.display = "none"; |
| 188 | + function updateContainersEnabled() { |
| 189 | + let containersEnabled = Boolean(contextStore.enabled && browser.contextualIdentities); |
| 190 | + document.querySelector("#opt-containers").disabled = !browser.contextualIdentities; |
| 191 | + document.querySelector("#opt-containers").checked = contextStore.enabled; |
| 192 | + document.querySelector("#select-container").hidden = !containersEnabled; |
| 193 | + document.querySelector("#select-container-label").hidden = !containersEnabled; |
| 194 | + document.querySelector("#per-site-buttons").style.display = containersEnabled? "flex" : "none"; |
| 195 | + } |
| 196 | + updateContainersEnabled(); |
181 | 197 |
|
182 | 198 | async function changeContainer() {
|
183 | 199 | cookieStoreId = containerSelect.value;
|
|
205 | 221 | containerCopy.onchange = copyContainer;
|
206 | 222 |
|
207 | 223 | var containers = [];
|
208 |
| - async function updateContainers() { |
| 224 | + async function updateContainerOptions() { |
209 | 225 | let newContainers = [{cookieStoreId: "default", name: "Default"},];
|
210 | 226 | let identities = browser.contextualIdentities && await browser.contextualIdentities.query({});
|
211 | 227 | if (identities) {
|
|
223 | 239 | containerSelect.value = cookieStoreId;
|
224 | 240 | containerCopy.innerHTML = container_options;
|
225 | 241 | }
|
226 |
| - containerSelect.onfocus = updateContainers; |
227 |
| - containerCopy.onfocus = updateContainers; |
228 |
| - await updateContainers(); |
| 242 | + containerSelect.onfocus = updateContainerOptions; |
| 243 | + containerCopy.onfocus = updateContainerOptions; |
| 244 | + if (contextStore.enabled) await updateContainerOptions(); |
229 | 245 |
|
230 | 246 | UI.onSettings = async () => {
|
231 | 247 | currentPolicy = await UI.getPolicy(cookieStoreId);
|
|
0 commit comments