Integrated the proxified-containers.js logic into relevant files without direct proxifying yet
This commit is contained in:
parent
a688fde769
commit
067843c4b9
3 changed files with 62 additions and 34 deletions
|
@ -42,6 +42,8 @@ const backgroundLogic = {
|
||||||
this.cookieStoreId(options.userContextId),
|
this.cookieStoreId(options.userContextId),
|
||||||
options.params
|
options.params
|
||||||
);
|
);
|
||||||
|
|
||||||
|
window.proxifiedContainers.set(this.cookieStoreId(options.userContextId), options.proxy);
|
||||||
} else {
|
} else {
|
||||||
donePromise = browser.contextualIdentities.create(options.params);
|
donePromise = browser.contextualIdentities.create(options.params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"js/background/messageHandler.js",
|
"js/background/messageHandler.js",
|
||||||
]
|
]
|
||||||
-->
|
-->
|
||||||
|
<script type="text/javascript" src="../proxified-containers.js"></script>
|
||||||
<script type="text/javascript" src="backgroundLogic.js"></script>
|
<script type="text/javascript" src="backgroundLogic.js"></script>
|
||||||
<script type="text/javascript" src="assignManager.js"></script>
|
<script type="text/javascript" src="assignManager.js"></script>
|
||||||
<script type="text/javascript" src="badge.js"></script>
|
<script type="text/javascript" src="badge.js"></script>
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* 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,
|
* 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/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
const CONTAINER_HIDE_SRC = "/img/container-hide.svg";
|
const CONTAINER_HIDE_SRC = "/img/container-hide.svg";
|
||||||
const CONTAINER_UNHIDE_SRC = "/img/container-unhide.svg";
|
const CONTAINER_UNHIDE_SRC = "/img/container-unhide.svg";
|
||||||
|
|
||||||
const DEFAULT_COLOR = "blue";
|
const DEFAULT_COLOR = "blue";
|
||||||
const DEFAULT_ICON = "circle";
|
const DEFAULT_ICON = "circle";
|
||||||
const NEW_CONTAINER_ID = "new";
|
const NEW_CONTAINER_ID = "new";
|
||||||
|
const DEFAULT_PROXY = {type: "direct"};
|
||||||
|
|
||||||
const ONBOARDING_STORAGE_KEY = "onboarding-stage";
|
const ONBOARDING_STORAGE_KEY = "onboarding-stage";
|
||||||
|
|
||||||
|
@ -214,27 +214,6 @@ const Logic = {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
async numTabs() {
|
|
||||||
const activeTabs = await browser.tabs.query({windowId: browser.windows.WINDOW_ID_CURRENT});
|
|
||||||
return activeTabs.length;
|
|
||||||
},
|
|
||||||
|
|
||||||
_disableMoveTabs(message) {
|
|
||||||
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
|
||||||
const fragment = document.createDocumentFragment();
|
|
||||||
const incompatEl = document.createElement("div");
|
|
||||||
|
|
||||||
moveTabsEl.classList.remove("clickable");
|
|
||||||
moveTabsEl.setAttribute("title", message);
|
|
||||||
|
|
||||||
fragment.appendChild(incompatEl);
|
|
||||||
incompatEl.setAttribute("id", "container-info-movetabs-incompat");
|
|
||||||
incompatEl.textContent = message;
|
|
||||||
incompatEl.classList.add("container-info-tab-row");
|
|
||||||
|
|
||||||
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
|
||||||
},
|
|
||||||
|
|
||||||
async refreshIdentities() {
|
async refreshIdentities() {
|
||||||
const [identities, state] = await Promise.all([
|
const [identities, state] = await Promise.all([
|
||||||
browser.contextualIdentities.query({}),
|
browser.contextualIdentities.query({}),
|
||||||
|
@ -321,6 +300,10 @@ const Logic = {
|
||||||
return Logic.userContextId(identity.cookieStoreId);
|
return Logic.userContextId(identity.cookieStoreId);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cookieStoreId(userContextId) {
|
||||||
|
return `firefox-container-${userContextId}`;
|
||||||
|
},
|
||||||
|
|
||||||
currentCookieStoreId() {
|
currentCookieStoreId() {
|
||||||
const identity = Logic.currentIdentity();
|
const identity = Logic.currentIdentity();
|
||||||
return identity.cookieStoreId;
|
return identity.cookieStoreId;
|
||||||
|
@ -732,14 +715,38 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if the user has incompatible add-ons installed
|
// Check if the user has incompatible add-ons installed
|
||||||
let incompatible = false;
|
|
||||||
try {
|
try {
|
||||||
incompatible = await browser.runtime.sendMessage({
|
const incompatible = await browser.runtime.sendMessage({
|
||||||
method: "checkIncompatibleAddons"
|
method: "checkIncompatibleAddons"
|
||||||
});
|
});
|
||||||
|
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
||||||
|
if (incompatible) {
|
||||||
|
const fragment = document.createDocumentFragment();
|
||||||
|
const incompatEl = document.createElement("div");
|
||||||
|
|
||||||
|
moveTabsEl.classList.remove("clickable");
|
||||||
|
moveTabsEl.setAttribute("title", "Moving container tabs is incompatible with Pulse, PageShot, and SnoozeTabs.");
|
||||||
|
|
||||||
|
fragment.appendChild(incompatEl);
|
||||||
|
incompatEl.setAttribute("id", "container-info-movetabs-incompat");
|
||||||
|
incompatEl.textContent = "Incompatible with other Experiments.";
|
||||||
|
incompatEl.classList.add("container-info-tab-row");
|
||||||
|
|
||||||
|
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
||||||
|
} else {
|
||||||
|
Logic.addEnterHandler(moveTabsEl, async function () {
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
method: "moveTabsToWindow",
|
||||||
|
windowId: browser.windows.WINDOW_ID_CURRENT,
|
||||||
|
cookieStoreId: Logic.currentIdentity().cookieStoreId,
|
||||||
|
});
|
||||||
|
window.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("Could not check for incompatible add-ons.");
|
throw new Error("Could not check for incompatible add-ons.");
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
||||||
const numTabs = await Logic.numTabs();
|
const numTabs = await Logic.numTabs();
|
||||||
if (incompatible) {
|
if (incompatible) {
|
||||||
|
@ -757,6 +764,8 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
||||||
});
|
});
|
||||||
window.close();
|
window.close();
|
||||||
});
|
});
|
||||||
|
=======
|
||||||
|
>>>>>>> Integrated the proxified-containers.js logic into relevant files without direct proxifying yet
|
||||||
},
|
},
|
||||||
|
|
||||||
// This method is called when the panel is shown.
|
// This method is called when the panel is shown.
|
||||||
|
@ -944,8 +953,6 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
||||||
this._editForm.addEventListener("submit", () => {
|
this._editForm.addEventListener("submit", () => {
|
||||||
this._submitForm();
|
this._submitForm();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async _submitForm() {
|
async _submitForm() {
|
||||||
|
@ -958,8 +965,9 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
||||||
params: {
|
params: {
|
||||||
name: document.getElementById("edit-container-panel-name-input").value || Logic.generateIdentityName(),
|
name: document.getElementById("edit-container-panel-name-input").value || Logic.generateIdentityName(),
|
||||||
icon: formValues.get("container-icon") || DEFAULT_ICON,
|
icon: formValues.get("container-icon") || DEFAULT_ICON,
|
||||||
color: formValues.get("container-color") || DEFAULT_COLOR,
|
color: formValues.get("container-color") || DEFAULT_COLOR
|
||||||
}
|
},
|
||||||
|
proxy: window.proxifiedContainers.parseProxy(document.getElementById("edit-container-panel-proxy").value) || DEFAULT_PROXY
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await Logic.refreshIdentities();
|
await Logic.refreshIdentities();
|
||||||
|
@ -1054,11 +1062,6 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
||||||
|
|
||||||
document.querySelector("#edit-container-panel-name-input").value = identity.name || "";
|
document.querySelector("#edit-container-panel-name-input").value = identity.name || "";
|
||||||
document.querySelector("#edit-container-panel-usercontext-input").value = userContextId || NEW_CONTAINER_ID;
|
document.querySelector("#edit-container-panel-usercontext-input").value = userContextId || NEW_CONTAINER_ID;
|
||||||
const containerName = document.querySelector("#edit-container-panel-name-input");
|
|
||||||
window.requestAnimationFrame(() => {
|
|
||||||
containerName.select();
|
|
||||||
containerName.focus();
|
|
||||||
});
|
|
||||||
[...document.querySelectorAll("[name='container-color']")].forEach(colorInput => {
|
[...document.querySelectorAll("[name='container-color']")].forEach(colorInput => {
|
||||||
colorInput.checked = colorInput.value === identity.color;
|
colorInput.checked = colorInput.value === identity.color;
|
||||||
});
|
});
|
||||||
|
@ -1066,6 +1069,28 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
||||||
iconInput.checked = iconInput.value === identity.icon;
|
iconInput.checked = iconInput.value === identity.icon;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var edit_proxy_dom = function(result) {
|
||||||
|
if(result.type == "http")
|
||||||
|
document.querySelector('#edit-container-panel-proxy').value = result.host.toString() + ":" + result.port.toString();
|
||||||
|
else if(result.type == "direct")
|
||||||
|
document.querySelector('#edit-container-panel-proxy').value = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
window.proxifiedContainers.retrieve(identity.cookieStoreId).then((result) => {
|
||||||
|
edit_proxy_dom(result.proxy);
|
||||||
|
}, (error) => {
|
||||||
|
if(error.error == "uninitialized" || error.error == "doesnotexist") {
|
||||||
|
window.proxifiedContainers.set(identity.cookieStoreId, DEFAULT_PROXY, error.error == "uninitialized").then((result) => {
|
||||||
|
edit_proxy_dom(result.proxy);
|
||||||
|
}, (error) => {
|
||||||
|
browser.extension.getBackgroundPage().console.log(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
browser.extension.getBackgroundPage().console.log(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue