Skip to content

Commit

Permalink
Add ability to deactivate sync of parent tab and opener tab
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Nov 17, 2017
1 parent 634dd84 commit 49c9539
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion webextensions/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ async function attachTabFromRestoredInfo(aTab, aOptions = {}) {
}
var opener = getOpenerTab(aTab);
if (!attached &&
opener) {
opener &&
configs.syncParentTabAndOpenerTab) {
await attachTabTo(aTab, opener, {
dontExpand: !active,
forceExpand: active,
Expand Down
10 changes: 7 additions & 3 deletions webextensions/background/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,9 @@ function handleNewActiveTab(aTab, aInfo = {}) {

function onTabUpdated(aTab) {
var parent = getOpenerTab(aTab);
if (parent && parent != getParentTab(aTab)) {
if (parent &&
parent != getParentTab(aTab) &&
configs.syncParentTabAndOpenerTab) {
attachTabTo(aTab, parent, {
insertAt: kINSERT_NEAREST,
forceExpand: isActive(aTab),
Expand All @@ -580,7 +582,8 @@ function onTabCollapsedStateChanged(aTab, aInfo = {}) {

async function onTabAttached(aTab, aInfo = {}) {
var parent = aInfo.parent;
if (aTab.apiTab.openerTabId != parent.apiTab.id) {
if (aTab.apiTab.openerTabId != parent.apiTab.id &&
configs.syncParentTabAndOpenerTab) {
aTab.apiTab.openerTabId = parent.apiTab.id;
aTab.apiTab.TSTUpdatedOpenerTabId = aTab.apiTab.openerTabId; // workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1409262
browser.tabs.update(aTab.apiTab.id, { openerTabId: parent.apiTab.id })
Expand Down Expand Up @@ -701,7 +704,8 @@ async function onTabAttached(aTab, aInfo = {}) {
}

function onTabDetached(aTab, aDetachInfo) {
if (aTab.apiTab.openerTabId) {
if (aTab.apiTab.openerTabId &&
configs.syncParentTabAndOpenerTab) {
aTab.apiTab.openerTabId = aTab.apiTab.id;
aTab.apiTab.TSTUpdatedOpenerTabId = aTab.apiTab.openerTabId; // workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1409262
browser.tabs.update(aTab.apiTab.id, { openerTabId: aTab.apiTab.id }) // set self id instead of null, because it requires any valid tab id...
Expand Down
2 changes: 2 additions & 0 deletions webextensions/common/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ configs = new Configs({

parentTabBehaviorForChanges: kPARENT_TAB_BEHAVIOR_ALWAYS,

syncParentTabAndOpenerTab: true,


// grouping
autoGroupNewTabs: true,
Expand Down

0 comments on commit 49c9539

Please sign in to comment.