for #242: disable move when incompatible add-ons detected
This commit is contained in:
parent
c81851e3bd
commit
3fb6976401
3 changed files with 55 additions and 9 deletions
19
index.js
19
index.js
|
@ -8,6 +8,12 @@ const DEFAULT_TAB = "about:newtab";
|
||||||
const SHOW_MENU_TIMEOUT = 100;
|
const SHOW_MENU_TIMEOUT = 100;
|
||||||
const HIDE_MENU_TIMEOUT = 300;
|
const HIDE_MENU_TIMEOUT = 300;
|
||||||
|
|
||||||
|
const INCOMPATIBLE_ADDON_IDS = [
|
||||||
|
"pulse@mozilla.com",
|
||||||
|
"snoozetabs@mozilla.com",
|
||||||
|
"jid1-NeEaf3sAHdKHPA@jetpack" // PageShot
|
||||||
|
];
|
||||||
|
|
||||||
const IDENTITY_COLORS = [
|
const IDENTITY_COLORS = [
|
||||||
{ name: "blue", color: "#00a7e0" },
|
{ name: "blue", color: "#00a7e0" },
|
||||||
{ name: "turquoise", color: "#01bdad" },
|
{ name: "turquoise", color: "#01bdad" },
|
||||||
|
@ -40,6 +46,7 @@ const PREFS = [
|
||||||
[ "privacy.usercontext.about_newtab_segregation.enabled", true ],
|
[ "privacy.usercontext.about_newtab_segregation.enabled", true ],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
|
||||||
const { attachTo, detachFrom } = require("sdk/content/mod");
|
const { attachTo, detachFrom } = require("sdk/content/mod");
|
||||||
const { Cu } = require("chrome");
|
const { Cu } = require("chrome");
|
||||||
const { ContextualIdentityService } = require("resource://gre/modules/ContextualIdentityService.jsm");
|
const { ContextualIdentityService } = require("resource://gre/modules/ContextualIdentityService.jsm");
|
||||||
|
@ -181,7 +188,8 @@ const ContainerService = {
|
||||||
"removeIdentity",
|
"removeIdentity",
|
||||||
"updateIdentity",
|
"updateIdentity",
|
||||||
"getPreference",
|
"getPreference",
|
||||||
"sendTelemetryPayload"
|
"sendTelemetryPayload",
|
||||||
|
"checkIncompatibleAddons"
|
||||||
];
|
];
|
||||||
|
|
||||||
// Map of identities.
|
// Map of identities.
|
||||||
|
@ -488,6 +496,15 @@ const ContainerService = {
|
||||||
this._sendEvent(payload);
|
this._sendEvent(payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
checkIncompatibleAddons() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
AddonManager.getAddonsByIDs(INCOMPATIBLE_ADDON_IDS, (addons) => {
|
||||||
|
addons = addons.filter((a) => a && a.isActive);
|
||||||
|
resolve(addons.length !== 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// Tabs management
|
// Tabs management
|
||||||
|
|
||||||
hideTabs(args) {
|
hideTabs(args) {
|
||||||
|
|
|
@ -420,7 +420,13 @@ span ~ .panel-header-text {
|
||||||
margin-block-start: 4px;
|
margin-block-start: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container-info-tab-row:not(.clickable) {
|
#container-info-movetabs-incompat {
|
||||||
|
font-size: 10px;
|
||||||
|
opacity: 0.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-info-tab-row:not(.clickable),
|
||||||
|
.select-row:not(.clickable) {
|
||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,26 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector("#container-info-movetabs").addEventListener("click", () => {
|
// Check if the user has incompatible add-ons installed
|
||||||
|
browser.runtime.sendMessage({
|
||||||
|
method: "checkIncompatibleAddons"
|
||||||
|
}).then(incompatible => {
|
||||||
|
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.innerText = "Incompatible with other Experiments.";
|
||||||
|
incompatEl.classList.add("container-info-tab-row");
|
||||||
|
|
||||||
|
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
||||||
|
} else {
|
||||||
|
moveTabsEl.addEventListener("click", () => {
|
||||||
return browser.runtime.sendMessage({
|
return browser.runtime.sendMessage({
|
||||||
method: "moveTabsToWindow",
|
method: "moveTabsToWindow",
|
||||||
userContextId: Logic.currentIdentity().userContextId,
|
userContextId: Logic.currentIdentity().userContextId,
|
||||||
|
@ -310,6 +329,10 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
||||||
window.close();
|
window.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
throw new Error("Could not check for incompatible add-ons.");
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// This method is called when the panel is shown.
|
// This method is called when the panel is shown.
|
||||||
|
|
Loading…
Add table
Reference in a new issue