/* 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/. */ /* eslint-env mozilla/remote-page */ 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"); let titleEl = document.querySelector("title"); titleEl.setAttribute( "data-l10n-args", JSON.stringify({ profilename: this.data.profile.name }) ); this.initialized = true; } updated() { super.updated(); if (!this.data?.profile) { return; } let { themeFg, themeBg } = this.data.profile; this.headerAvatar.style.fill = themeBg; this.headerAvatar.style.stroke = themeFg; this.setFavicon(); } setFavicon() { let favicon = document.getElementById("favicon"); favicon.href = `chrome://browser/content/profiles/assets/16_${this.data.profile.avatar}.svg`; } 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);