/* 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/. */ import { MozLitElement } from "chrome://global/content/lit-utils.mjs"; import { html } from "chrome://global/content/vendor/lit.all.mjs"; // eslint-disable-next-line import/no-unassigned-import import "chrome://global/content/elements/moz-button.mjs"; // eslint-disable-next-line import/no-unassigned-import import "chrome://global/content/elements/moz-button-group.mjs"; // eslint-disable-next-line import/no-unassigned-import import "chrome://global/content/elements/moz-card.mjs"; /** * Element used for deleting the currently running profile. */ export class DeleteProfileCard extends MozLitElement { static properties = { data: { type: Object }, }; static queries = { headerAvatar: "#header-avatar", cancelButton: "#cancel-delete", }; connectedCallback() { super.connectedCallback(); this.init(); } async init() { if (this.initialized) { return; } this.data = await RPMSendQuery("Profiles:GetDeleteProfileContent"); if (this.data.profile.hasCustomAvatar) { const objURL = URL.createObjectURL(this.data.profile.avatarFiles.file16); this.data.profile.avatarURLs.url16 = objURL; this.data.profile.avatarURLs.url80 = objURL; } let titleEl = document.querySelector("title"); titleEl.setAttribute( "data-l10n-args", JSON.stringify({ profilename: this.data.profile.name }) ); this.initialized = true; this.setFavicon(); } setFavicon() { const favicon = document.getElementById("favicon"); if (this.data.profile.hasCustomAvatar) { favicon.href = this.data.profile.avatarURLs.url16; return; } const faviconBlob = new Blob([this.data.profile.faviconSVGText], { type: "image/svg+xml", }); const faviconObjURL = URL.createObjectURL(faviconBlob); favicon.href = faviconObjURL; } updated() { super.updated(); if (!this.data?.profile) { return; } let { themeFg, themeBg } = this.data.profile; this.headerAvatar.style.fill = themeBg; this.headerAvatar.style.stroke = themeFg; } cancelDelete() { RPMSendAsyncMessage("Profiles:CancelDelete"); } confirmDelete() { RPMSendAsyncMessage("Profiles:DeleteProfile"); } render() { if (!this.data) { return null; } return html`

${this.data.windowCount}
${this.data.tabCount}
${this.data.bookmarkCount}
${this.data.historyCount}
${this.data.autofillCount}
${this.data.loginCount}
`; } } customElements.define("delete-profile-card", DeleteProfileCard);