@@ -41,11 +41,11 @@ Tab.onCreating.addListener((tab, info = {}) => {
41
41
TabsStore . addToBeGroupedTab ( tab ) ;
42
42
}
43
43
else {
44
+ let dontMove = false ;
44
45
if ( ! info . maybeOrphan &&
45
46
possibleOpenerTab &&
46
47
! info . restored ) {
47
48
let autoAttachBehavior = configs . autoAttachOnNewTabCommand ;
48
- let dontMove = false ;
49
49
if ( tab . $TST . nextTab &&
50
50
possibleOpenerTab == tab . $TST . previousTab ) {
51
51
// New tab opened with browser.tabs.insertAfterCurrent=true may have
@@ -85,7 +85,17 @@ Tab.onCreating.addListener((tab, info = {}) => {
85
85
else if ( possibleOpenerTab != tab ) {
86
86
tab . $TST . possibleOpenerTab = possibleOpenerTab . id ;
87
87
}
88
- tab . $TST . isNewTab = true ;
88
+ tab . $TST . isNewTab = ! info . fromExternal ;
89
+ }
90
+ if ( info . fromExternal ) {
91
+ log ( 'behave as a tab opened from external application' ) ;
92
+ return Tree . behaveAutoAttachedTab ( tab , {
93
+ baseTab : possibleOpenerTab ,
94
+ behavior : configs . autoAttachOnOpenedFromExternal ,
95
+ dontMove,
96
+ inheritContextualIdentity : configs . inheritContextualIdentityToTabsFromExternal ,
97
+ broadcast : true
98
+ } ) . then ( moved => ! moved ) ;
89
99
}
90
100
log ( 'behave as a tab opened with any URL' ) ;
91
101
tab . $TST . positionedBySelf = info . positionedBySelf ;
@@ -111,8 +121,9 @@ Tab.onCreating.addListener((tab, info = {}) => {
111
121
else if ( ! info . maybeOrphan && configs . autoAttach ) {
112
122
return Tree . behaveAutoAttachedTab ( tab , {
113
123
baseTab : opener ,
114
- behavior : configs . autoAttachOnOpenedWithOwner ,
124
+ behavior : info . fromExternal ? configs . autoAttachOnOpenedFromExternal : configs . autoAttachOnOpenedWithOwner ,
115
125
dontMove : info . positionedBySelf || info . mayBeReplacedWithContainer ,
126
+ inheritContextualIdentity : info . fromExternal ? configs . inheritContextualIdentityToTabsFromExternal : false ,
116
127
broadcast : true
117
128
} ) . then ( moved => ! moved ) ;
118
129
}
0 commit comments