mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-05 09:26:34 +00:00
feat(pinned-tab-manager): Add restore pinned tabs to pinned url option
This commit introduces a new option to the pinned tab manager that allows users to restore pinned tabs to their pinned URL and title, even if the current tab has a different URL. - Adds a new preference `zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url` to control this behavior. - Updates the tab browser, tab state, and preferences code to support the new option. - Adds a new UI element in the settings to allow users to enable/disable this feature. This feature enhances the pinned tab manager by providing more control over how pinned tabs are restored when the browser is restarted.
This commit is contained in:
@@ -112,7 +112,8 @@ pref('zen.tab-unloader.enabled', true);
|
|||||||
pref('zen.tab-unloader.timeout-minutes', 20);
|
pref('zen.tab-unloader.timeout-minutes', 20);
|
||||||
pref('zen.tab-unloader.excluded-urls', "example.com,example.org");
|
pref('zen.tab-unloader.excluded-urls', "example.com,example.org");
|
||||||
|
|
||||||
pref('zen.pinned-tab-manager.reset-pinned-tab-on-close-shortcut', true);
|
pref('zen.pinned-tab-manager.reset-pinned-tab-on-close-shortcut', false);
|
||||||
|
pref('zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url', false);
|
||||||
|
|
||||||
// Pref to enable the new profiles (TODO: Check this out!)
|
// Pref to enable the new profiles (TODO: Check this out!)
|
||||||
//pref("browser.profiles.enabled", true);
|
//pref("browser.profiles.enabled", true);
|
||||||
|
@@ -1025,4 +1025,9 @@ Preferences.addAll([
|
|||||||
type: 'bool',
|
type: 'bool',
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url',
|
||||||
|
type: 'bool',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
@@ -74,6 +74,10 @@
|
|||||||
<checkbox id="zenPinnedTabResetOnCloseShortcutEnable"
|
<checkbox id="zenPinnedTabResetOnCloseShortcutEnable"
|
||||||
data-l10n-id="zen-pinned-tab-manager-reset-close-shortcut-enabled"
|
data-l10n-id="zen-pinned-tab-manager-reset-close-shortcut-enabled"
|
||||||
preference="zen.pinned-tab-manager.reset-pinned-tab-on-close-shortcut"/>
|
preference="zen.pinned-tab-manager.reset-pinned-tab-on-close-shortcut"/>
|
||||||
|
|
||||||
|
<checkbox id="zenPinnedTabRestorePinnedTabsToPinnedUrl"
|
||||||
|
data-l10n-id="zen-pinned-tab-manager-restore-pinned-tabs-to-pinned-url"
|
||||||
|
preference="zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url"/>
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
|
||||||
</html:template>
|
</html:template>
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
diff --git a/browser/components/sessionstore/TabState.sys.mjs b/browser/components/sessionstore/TabState.sys.mjs
|
diff --git a/browser/components/sessionstore/TabState.sys.mjs b/browser/components/sessionstore/TabState.sys.mjs
|
||||||
index 26f5671c849d9b0a126d79b07bc7d3d7870826ec..3726c8d89c9a8f797fda4ef3c18e4fa81f3ad130 100644
|
index 26f5671c849d9b0a126d79b07bc7d3d7870826ec..5e356a35639c802fcf6d95d42993d5bd5cda514a 100644
|
||||||
--- a/browser/components/sessionstore/TabState.sys.mjs
|
--- a/browser/components/sessionstore/TabState.sys.mjs
|
||||||
+++ b/browser/components/sessionstore/TabState.sys.mjs
|
+++ b/browser/components/sessionstore/TabState.sys.mjs
|
||||||
@@ -98,6 +98,11 @@ var TabStateInternal = {
|
@@ -98,6 +98,12 @@ var TabStateInternal = {
|
||||||
tabData.muteReason = tab.muteReason;
|
tabData.muteReason = tab.muteReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ index 26f5671c849d9b0a126d79b07bc7d3d7870826ec..3726c8d89c9a8f797fda4ef3c18e4fa8
|
|||||||
+ tabData.zenDefaultUserContextId = tab.getAttribute("zenDefaultUserContextId");
|
+ tabData.zenDefaultUserContextId = tab.getAttribute("zenDefaultUserContextId");
|
||||||
+ tabData.zenPinnedUrl = tab.getAttribute("zen-pinned-url");
|
+ tabData.zenPinnedUrl = tab.getAttribute("zen-pinned-url");
|
||||||
+ tabData.zenPinnedTitle = tab.getAttribute("zen-pinned-title");
|
+ tabData.zenPinnedTitle = tab.getAttribute("zen-pinned-title");
|
||||||
|
+ tabData.zenPinnedIcon = tab.getAttribute("zen-pinned-icon");
|
||||||
+
|
+
|
||||||
tabData.searchMode = tab.ownerGlobal.gURLBar.getSearchMode(browser, true);
|
tabData.searchMode = tab.ownerGlobal.gURLBar.getSearchMode(browser, true);
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b6835bdacdb 100644
|
index c89ae2cbb978d6218bd56a059c5ca1e371231607..6608e0d7df1092a7398979abb166895e0b4fb66b 100644
|
||||||
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
@@ -452,11 +452,26 @@
|
@@ -456,11 +456,26 @@
|
||||||
return duplicateTabs;
|
return duplicateTabs;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b68
|
|||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
},
|
},
|
||||||
@@ -2704,6 +2719,11 @@
|
@@ -2705,6 +2720,11 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b68
|
|||||||
if (!UserInteraction.running("browser.tabs.opening", window)) {
|
if (!UserInteraction.running("browser.tabs.opening", window)) {
|
||||||
UserInteraction.start("browser.tabs.opening", "initting", window);
|
UserInteraction.start("browser.tabs.opening", "initting", window);
|
||||||
}
|
}
|
||||||
@@ -2771,6 +2791,9 @@
|
@@ -2773,6 +2793,9 @@
|
||||||
noInitialLabel,
|
noInitialLabel,
|
||||||
skipBackgroundNotify,
|
skipBackgroundNotify,
|
||||||
});
|
});
|
||||||
@@ -53,7 +53,7 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b68
|
|||||||
if (insertTab) {
|
if (insertTab) {
|
||||||
// insert the tab into the tab container in the correct position
|
// insert the tab into the tab container in the correct position
|
||||||
this._insertTabAtIndex(t, {
|
this._insertTabAtIndex(t, {
|
||||||
@@ -3248,6 +3271,14 @@
|
@@ -3262,6 +3285,14 @@
|
||||||
) {
|
) {
|
||||||
tabWasReused = true;
|
tabWasReused = true;
|
||||||
tab = this.selectedTab;
|
tab = this.selectedTab;
|
||||||
@@ -68,7 +68,21 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b68
|
|||||||
if (!tabData.pinned) {
|
if (!tabData.pinned) {
|
||||||
this.unpinTab(tab);
|
this.unpinTab(tab);
|
||||||
} else {
|
} else {
|
||||||
@@ -3297,6 +3328,12 @@
|
@@ -3283,6 +3314,13 @@
|
||||||
|
url = tabData.entries[activeIndex].url;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if(Services.prefs.getBoolPref("zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url", false) && tabData.pinned && tabData.zenPinnedUrl) {
|
||||||
|
+ tabData.entries = [{url: tabData.zenPinnedUrl, title: tabData.zenPinnedTitle}];
|
||||||
|
+ tabData.image = tabData.zenPinnedIcon;
|
||||||
|
+ tabData.index = 0;
|
||||||
|
+ url = tabData.zenPinnedUrl;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
let preferredRemoteType = E10SUtils.getRemoteTypeForURI(
|
||||||
|
url,
|
||||||
|
gMultiProcessBrowser,
|
||||||
|
@@ -3311,6 +3349,12 @@
|
||||||
preferredRemoteType,
|
preferredRemoteType,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,7 +95,7 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b68
|
|||||||
if (select) {
|
if (select) {
|
||||||
tabToSelect = tab;
|
tabToSelect = tab;
|
||||||
}
|
}
|
||||||
@@ -3331,7 +3368,13 @@
|
@@ -3345,7 +3389,17 @@
|
||||||
this.tabContainer._invalidateCachedTabs();
|
this.tabContainer._invalidateCachedTabs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,11 +105,15 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b68
|
|||||||
|
|
||||||
+ if (tabData.zenPinnedTitle) {
|
+ if (tabData.zenPinnedTitle) {
|
||||||
+ tab.setAttribute("zen-pinned-title", tabData.zenPinnedTitle);
|
+ tab.setAttribute("zen-pinned-title", tabData.zenPinnedTitle);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if(tabData.zenPinnedIcon) {
|
||||||
|
+ tab.setAttribute("zen-pinned-icon", tabData.zenPinnedIcon);
|
||||||
+ }
|
+ }
|
||||||
tab.initialize();
|
tab.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4184,6 +4227,7 @@
|
@@ -4198,6 +4252,7 @@
|
||||||
isLastTab ||
|
isLastTab ||
|
||||||
aTab.pinned ||
|
aTab.pinned ||
|
||||||
aTab.hidden ||
|
aTab.hidden ||
|
||||||
@@ -103,7 +121,7 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b68
|
|||||||
this._removingTabs.size >
|
this._removingTabs.size >
|
||||||
3 /* don't want lots of concurrent animations */ ||
|
3 /* don't want lots of concurrent animations */ ||
|
||||||
!aTab.hasAttribute(
|
!aTab.hasAttribute(
|
||||||
@@ -5117,10 +5161,10 @@
|
@@ -5131,10 +5186,10 @@
|
||||||
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
|
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -116,7 +134,7 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b68
|
|||||||
aTab.selected ||
|
aTab.selected ||
|
||||||
aTab.closing ||
|
aTab.closing ||
|
||||||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
|
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
|
||||||
@@ -7822,7 +7866,10 @@ var TabContextMenu = {
|
@@ -7870,7 +7925,14 @@ var TabContextMenu = {
|
||||||
);
|
);
|
||||||
contextUnpinSelectedTabs.hidden =
|
contextUnpinSelectedTabs.hidden =
|
||||||
!this.contextTab.pinned || !multiselectionContext;
|
!this.contextTab.pinned || !multiselectionContext;
|
||||||
@@ -124,6 +142,10 @@ index ef857bd81f2cd7c163ecc74ac1cf81a0b63ce838..7ffa8f7d64f2ed13018e3f32f94e7b68
|
|||||||
+ let contextResetPinnedTab = document.getElementById("context_zen-reset-pinned-tab");
|
+ let contextResetPinnedTab = document.getElementById("context_zen-reset-pinned-tab");
|
||||||
+ if(contextResetPinnedTab) {
|
+ if(contextResetPinnedTab) {
|
||||||
+ contextResetPinnedTab.hidden = !this.contextTab.pinned || !this.contextTab.getAttribute("zen-pinned-url") || multiselectionContext;
|
+ contextResetPinnedTab.hidden = !this.contextTab.pinned || !this.contextTab.getAttribute("zen-pinned-url") || multiselectionContext;
|
||||||
|
+ }
|
||||||
|
+ let contextReplacePinnedUrlWithCurrent = document.getElementById("context_zen-replace-pinned-url-with-current");
|
||||||
|
+ if(contextReplacePinnedUrlWithCurrent) {
|
||||||
|
+ contextReplacePinnedUrlWithCurrent.hidden = !this.contextTab.pinned || !this.contextTab.getAttribute("zen-pinned-url") || multiselectionContext;
|
||||||
+ }
|
+ }
|
||||||
// Move Tab items
|
// Move Tab items
|
||||||
let contextMoveTabOptions = document.getElementById(
|
let contextMoveTabOptions = document.getElementById(
|
||||||
|
Reference in New Issue
Block a user