mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 16:19:58 +02:00
Merge pull request #51 from kristijanribaric/fix/pinned-tabs-storing-the-whole-entry
Fix/pinned tabs storing the whole entry
This commit is contained in:
commit
382466fcd7
1 changed files with 27 additions and 22 deletions
|
@ -94,17 +94,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_setPinnedAttributes(tab) {
|
_setPinnedAttributes(tab) {
|
||||||
tab.setAttribute("zen-pinned-url", tab.linkedBrowser.currentURI.spec);
|
const browser = tab.linkedBrowser;
|
||||||
tab.setAttribute("zen-pinned-title", tab.getAttribute("label"));
|
const entry = {
|
||||||
tab.setAttribute("zen-pinned-icon", tab.linkedBrowser.mIconURL);
|
url: browser.currentURI.spec,
|
||||||
tab.setAttribute("zen-pinned-triggering-principal", lazy.E10SUtils.serializePrincipal(tab.linkedBrowser.contentPrincipal));
|
title: tab.label || browser.contentTitle,
|
||||||
|
triggeringPrincipal_base64: lazy.E10SUtils.SERIALIZED_SYSTEMPRINCIPAL
|
||||||
|
};
|
||||||
|
|
||||||
|
tab.setAttribute("zen-pinned-entry", JSON.stringify(entry));
|
||||||
|
tab.setAttribute("zen-pinned-icon", browser.mIconURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
_removePinnedAttributes(tab) {
|
_removePinnedAttributes(tab) {
|
||||||
tab.removeAttribute("zen-pinned-url");
|
tab.removeAttribute("zen-pinned-entry");
|
||||||
tab.removeAttribute("zen-pinned-title");
|
|
||||||
tab.removeAttribute("zen-pinned-icon");
|
tab.removeAttribute("zen-pinned-icon");
|
||||||
tab.removeAttribute("zen-pinned-triggering-principal");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_initClosePinnedTabShortcut() {
|
_initClosePinnedTabShortcut() {
|
||||||
|
@ -116,17 +119,21 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
setPinnedTabState(tabData, tab) {
|
setPinnedTabState(tabData, tab) {
|
||||||
tabData.zenPinnedUrl = tab.getAttribute("zen-pinned-url");
|
tabData.zenPinnedEntry = tab.getAttribute("zen-pinned-entry");
|
||||||
tabData.zenPinnedTitle = tab.getAttribute("zen-pinned-title");
|
|
||||||
tabData.zenPinnedIcon = tab.getAttribute("zen-pinned-icon");
|
tabData.zenPinnedIcon = tab.getAttribute("zen-pinned-icon");
|
||||||
tabData.zenPinnedTriggeringPrincipal = tab.getAttribute("zen-pinned-triggering-principal");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePinnedTabForSessionRestore(tabData, tab) {
|
updatePinnedTabForSessionRestore(tabData, tab) {
|
||||||
!!tabData.zenPinnedUrl ? tab.setAttribute("zen-pinned-url", tabData.zenPinnedUrl) : tab.removeAttribute("zen-pinned-url");
|
if (tabData.zenPinnedEntry) {
|
||||||
!!tabData.zenPinnedTitle ? tab.setAttribute("zen-pinned-title", tabData.zenPinnedTitle) : tab.removeAttribute("zen-pinned-title");
|
tab.setAttribute("zen-pinned-entry", tabData.zenPinnedEntry);
|
||||||
!!tabData.zenPinnedIcon ? tab.setAttribute("zen-pinned-icon", tabData.zenPinnedIcon) : tab.removeAttribute("zen-pinned-icon");
|
} else {
|
||||||
!!tabData.zenPinnedTriggeringPrincipal ? tab.setAttribute("zen-pinned-triggering-principal", tabData.zenPinnedTriggeringPrincipal) : tab.removeAttribute("zen-pinned-triggering-principal");
|
tab.removeAttribute("zen-pinned-entry");
|
||||||
|
}
|
||||||
|
if (tabData.zenPinnedIcon) {
|
||||||
|
tab.setAttribute("zen-pinned-icon", tabData.zenPinnedIcon);
|
||||||
|
} else {
|
||||||
|
tab.removeAttribute("zen-pinned-icon");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onCloseTabShortcut(event, selectedTab = gBrowser.selectedTab) {
|
_onCloseTabShortcut(event, selectedTab = gBrowser.selectedTab) {
|
||||||
|
@ -184,16 +191,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_resetTabToStoredState(tab) {
|
_resetTabToStoredState(tab) {
|
||||||
const url = tab.getAttribute("zen-pinned-url");
|
const entry = tab.getAttribute("zen-pinned-entry");
|
||||||
const title = tab.getAttribute("zen-pinned-title");
|
|
||||||
const icon = tab.getAttribute("zen-pinned-icon");
|
const icon = tab.getAttribute("zen-pinned-icon");
|
||||||
const triggeringPrincipal_base64 = tab.getAttribute("zen-pinned-triggering-principal");
|
|
||||||
|
|
||||||
if (url) {
|
if (entry) {
|
||||||
const tabState = SessionStore.getTabState(tab);
|
const tabState = SessionStore.getTabState(tab);
|
||||||
const state = JSON.parse(tabState);
|
const state = JSON.parse(tabState);
|
||||||
|
|
||||||
state.entries = [{url, title, triggeringPrincipal_base64}];
|
state.entries = [JSON.parse(entry)];
|
||||||
state.image = icon;
|
state.image = icon;
|
||||||
state.index = 0;
|
state.index = 0;
|
||||||
|
|
||||||
|
@ -216,8 +221,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPinnedTabData(tabData) {
|
resetPinnedTabData(tabData) {
|
||||||
if (lazy.zenPinnedTabRestorePinnedTabsToPinnedUrl && tabData.pinned && tabData.zenPinnedUrl) {
|
if (lazy.zenPinnedTabRestorePinnedTabsToPinnedUrl && tabData.pinned && tabData.zenPinnedEntry) {
|
||||||
tabData.entries = [{url: tabData.zenPinnedUrl, title: tabData.zenPinnedTitle, triggeringPrincipal_base64: tabData.zenPinnedTriggeringPrincipal}];
|
tabData.entries = [JSON.parse(tabData.zenPinnedEntry)];
|
||||||
tabData.image = tabData.zenPinnedIcon;
|
tabData.image = tabData.zenPinnedIcon;
|
||||||
tabData.index = 0;
|
tabData.index = 0;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +230,7 @@
|
||||||
|
|
||||||
updatePinnedTabContextMenu(contextTab) {
|
updatePinnedTabContextMenu(contextTab) {
|
||||||
const isVisible = contextTab.pinned && !contextTab.multiselected;
|
const isVisible = contextTab.pinned && !contextTab.multiselected;
|
||||||
document.getElementById("context_zen-reset-pinned-tab").hidden = !isVisible || !contextTab.getAttribute("zen-pinned-url");
|
document.getElementById("context_zen-reset-pinned-tab").hidden = !isVisible || !contextTab.getAttribute("zen-pinned-entry");
|
||||||
document.getElementById("context_zen-replace-pinned-url-with-current").hidden = !isVisible;
|
document.getElementById("context_zen-replace-pinned-url-with-current").hidden = !isVisible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue