in src/js/popup.js [1540:1624]
async connectedCallback() {
const { mozillaVpnHiddenToutsList } = await browser.storage.local.get("mozillaVpnHiddenToutsList");
const mozillaVpnCollapseEditContainerTout = mozillaVpnHiddenToutsList && mozillaVpnHiddenToutsList.find(tout => tout.name === this.toutName);
const mozillaVpnInstalled = await browser.runtime.sendMessage({ method: "MozillaVPN_getInstallationStatus" });
this.hideShowButton.addEventListener("click", this);
if (mozillaVpnCollapseEditContainerTout && !mozillaVpnInstalled) {
this.collapseUi();
}
// Add listeners
if (!this.classList.contains("has-attached-listeners")) {
const bothMozillaVpnPermissionsEnabled = await MozillaVPN.bothPermissionsEnabled();
this.primaryCta.addEventListener("click", async() => {
if (!bothMozillaVpnPermissionsEnabled && mozillaVpnInstalled) {
await browser.permissions.request({ permissions: ["proxy", "nativeMessaging"] });
} else {
MozillaVPN.handleMozillaCtaClick("mac-edit-container-panel-btn");
}
});
this.switch.addEventListener("click", async() => {
const { mozillaVpnServers } = await browser.storage.local.get("mozillaVpnServers");
const id = Logic.currentIdentity();
this.enableDisableProxyButtons();
if (!this.switch.checked) {
const deactivatedMozProxy = MozillaVPN.getProxy(
this.countryCodeInput.value,
this.cityNameInput.value,
undefined,
mozillaVpnServers
);
if (!deactivatedMozProxy) {
return;
}
await proxifiedContainers.set(id.cookieStoreId, deactivatedMozProxy);
this.switch.checked = false;
return;
}
let proxy;
if (this.countryCodeInput.value.length === 2) {
// User is re-enabling a Mozilla proxy for this container.
// Use the stored location information to select a server
// in the same location.
proxy = MozillaVPN.getProxy(
this.countryCodeInput.value,
this.cityNameInput.value,
true,
mozillaVpnServers
);
} else {
// No saved Mozilla VPN proxy information. Get something new.
const { randomServerCountryCode, randomServerCityName } = await MozillaVPN.pickRandomLocation();
proxy = MozillaVPN.getProxy(
randomServerCountryCode,
randomServerCityName,
true,
mozillaVpnServers
);
}
if (proxy) {
await proxifiedContainers.set(id.cookieStoreId, proxy);
this.switch.checked = true;
this.updateProxyDependentUi(proxy);
} else {
this.switch.checked = false;
this.updateProxyDependentUi({});
return;
}
});
}
this.classList.add("has-attached-listeners");
this.currentServerButton.classList.add("hidden");
}