@@ -48,6 +48,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
48
48
` ;
49
49
50
50
async waitForPromises ( ) {
51
+ if ( this . privateWindowOrDisabled ) {
52
+ return ;
53
+ }
51
54
await Promise . all ( [
52
55
this . promiseDBInitialized ,
53
56
this . promisePinnedInitialized ,
@@ -115,6 +118,10 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
115
118
) ;
116
119
this . _activeWorkspace = Services . prefs . getStringPref ( 'zen.workspaces.active' , '' ) ;
117
120
121
+ if ( this . isPrivateWindow ) {
122
+ document . documentElement . setAttribute ( 'zen-private-window' , 'true' ) ;
123
+ }
124
+
118
125
window . addEventListener ( 'resize' , this . onWindowResize . bind ( this ) ) ;
119
126
this . addPopupListeners ( ) ;
120
127
}
@@ -136,21 +143,24 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
136
143
await this . initializeWorkspaces ( ) ;
137
144
if (
138
145
Services . prefs . getBoolPref ( 'zen.workspaces.swipe-actions' , false ) &&
139
- this . workspaceEnabled
146
+ this . workspaceEnabled &&
147
+ ! this . isPrivateWindow
140
148
) {
141
149
this . initializeGestureHandlers ( ) ;
142
150
this . initializeWorkspaceNavigation ( ) ;
143
151
}
144
152
145
- Services . obs . addObserver ( this , 'weave:engine:sync:finish' ) ;
146
- Services . obs . addObserver (
147
- async function observe ( subject ) {
148
- this . _workspaceBookmarksCache = null ;
149
- await this . workspaceBookmarks ( ) ;
150
- this . _invalidateBookmarkContainers ( ) ;
151
- } . bind ( this ) ,
152
- 'workspace-bookmarks-updated'
153
- ) ;
153
+ if ( ! this . privateWindowOrDisabled ) {
154
+ Services . obs . addObserver ( this , 'weave:engine:sync:finish' ) ;
155
+ Services . obs . addObserver (
156
+ async function observe ( subject ) {
157
+ this . _workspaceBookmarksCache = null ;
158
+ await this . workspaceBookmarks ( ) ;
159
+ this . _invalidateBookmarkContainers ( ) ;
160
+ } . bind ( this ) ,
161
+ 'workspace-bookmarks-updated'
162
+ ) ;
163
+ }
154
164
}
155
165
156
166
// Validate browser state before tab operations
@@ -548,7 +558,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
548
558
toolbox . addEventListener (
549
559
'wheel' ,
550
560
async ( event ) => {
551
- if ( ! this . workspaceEnabled ) return ;
561
+ if ( this . privateWindowOrDisabled ) return ;
552
562
553
563
// Only process non-gesture scrolls
554
564
if ( event . deltaMode !== 1 ) return ;
@@ -627,7 +637,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
627
637
}
628
638
629
639
_handleSwipeMayStart ( event ) {
630
- if ( ! this . workspaceEnabled || this . _inChangingWorkspace ) return ;
640
+ if ( this . privateWindowOrDisabled || this . _inChangingWorkspace ) return ;
631
641
if ( event . target . closest ( '#zen-sidebar-bottom-buttons' ) ) return ;
632
642
633
643
// Only handle horizontal swipes
@@ -706,6 +716,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
706
716
707
717
set activeWorkspace ( value ) {
708
718
this . _activeWorkspace = value ;
719
+ if ( this . privateWindowOrDisabled ) {
720
+ return ;
721
+ }
709
722
Services . prefs . setStringPref ( 'zen.workspaces.active' , value ) ;
710
723
}
711
724
@@ -734,7 +747,6 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
734
747
if ( typeof this . _shouldHaveWorkspaces === 'undefined' ) {
735
748
let docElement = document . documentElement ;
736
749
this . _shouldHaveWorkspaces = ! (
737
- PrivateBrowsingUtils . isWindowPrivate ( window ) ||
738
750
docElement . getAttribute ( 'chromehidden' ) . includes ( 'toolbar' ) ||
739
751
docElement . getAttribute ( 'chromehidden' ) . includes ( 'menubar' )
740
752
) ;
@@ -743,6 +755,14 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
743
755
return this . _shouldHaveWorkspaces ;
744
756
}
745
757
758
+ get isPrivateWindow ( ) {
759
+ return PrivateBrowsingUtils . isWindowPrivate ( window ) ;
760
+ }
761
+
762
+ get privateWindowOrDisabled ( ) {
763
+ return this . isPrivateWindow || ! this . shouldHaveWorkspaces ;
764
+ }
765
+
746
766
get workspaceEnabled ( ) {
747
767
if ( typeof this . _workspaceEnabled === 'undefined' ) {
748
768
this . _workspaceEnabled =
@@ -769,6 +789,15 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
769
789
return this . _workspaceCache ;
770
790
}
771
791
792
+ if ( this . isPrivateWindow ) {
793
+ this . _workspaceCache = {
794
+ workspaces : this . _privateWorkspace ? [ this . _privateWorkspace ] : [ ] ,
795
+ lastChangeTimestamp : 0 ,
796
+ } ;
797
+ this . _activeWorkspace = this . _privateWorkspace ?. uuid ;
798
+ return this . _workspaceCache ;
799
+ }
800
+
772
801
const [ workspaces , lastChangeTimestamp ] = await Promise . all ( [
773
802
ZenWorkspacesStorage . getWorkspaces ( ) ,
774
803
ZenWorkspacesStorage . getLastChangeTimestamp ( ) ,
@@ -1242,6 +1271,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
1242
1271
}
1243
1272
1244
1273
async saveWorkspace ( workspaceData , preventPropagation = false ) {
1274
+ if ( this . privateWindowOrDisabled ) {
1275
+ return ;
1276
+ }
1245
1277
await ZenWorkspacesStorage . saveWorkspace ( workspaceData ) ;
1246
1278
if ( ! preventPropagation ) {
1247
1279
await this . _propagateWorkspaceData ( ) ;
@@ -1383,10 +1415,14 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
1383
1415
}
1384
1416
1385
1417
async _propagateWorkspaceData ( { ignoreStrip = false , clearCache = true } = { } ) {
1418
+ const currentWindowIsPrivate = this . isPrivateWindow ;
1386
1419
await this . foreachWindowAsActive ( async ( browser ) => {
1387
1420
// Do not update the window if workspaces are not enabled in it.
1388
1421
// For example, when the window is in private browsing mode.
1389
- if ( ! browser . gZenWorkspaces . workspaceEnabled ) {
1422
+ if (
1423
+ ! browser . gZenWorkspaces . workspaceEnabled ||
1424
+ browser . gZenWorkspaces . isPrivateWindow !== currentWindowIsPrivate
1425
+ ) {
1390
1426
return ;
1391
1427
}
1392
1428
@@ -1710,7 +1746,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
1710
1746
}
1711
1747
1712
1748
async openWorkspacesDialog ( event ) {
1713
- if ( ! this . workspaceEnabled ) {
1749
+ if ( ! this . workspaceEnabled || this . isPrivateWindow ) {
1714
1750
return ;
1715
1751
}
1716
1752
let target = event . target . closest ( '.zen-current-workspace-indicator' ) ;
@@ -2526,6 +2562,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
2526
2562
}
2527
2563
2528
2564
async _updateWorkspacesChangeContextMenu ( ) {
2565
+ if ( gZenWorkspaces . privateWindowOrDisabled ) return ;
2529
2566
const workspaces = await this . _workspaces ( ) ;
2530
2567
2531
2568
const menuPopup = document . getElementById ( 'context-zen-change-workspace-tab-menu-popup' ) ;
@@ -2575,6 +2612,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
2575
2612
if ( ! this . workspaceEnabled ) {
2576
2613
return ;
2577
2614
}
2615
+ if ( this . isPrivateWindow ) {
2616
+ name = 'Private ' + name ;
2617
+ }
2578
2618
// get extra tabs remaning (e.g. on new profiles) and just move them to the new workspace
2579
2619
const extraTabs = Array . from ( gBrowser . tabContainer . arrowScrollbox . children ) . filter (
2580
2620
( child ) =>
@@ -2590,7 +2630,11 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
2590
2630
! dontChange ,
2591
2631
containerTabId
2592
2632
) ;
2593
- await this . saveWorkspace ( workspaceData , dontChange ) ;
2633
+ if ( this . isPrivateWindow ) {
2634
+ this . _privateWorkspace = workspaceData ;
2635
+ } else {
2636
+ await this . saveWorkspace ( workspaceData , dontChange ) ;
2637
+ }
2594
2638
if ( ! dontChange ) {
2595
2639
this . registerPinnedResizeObserver ( ) ;
2596
2640
let changed = extraTabs . length > 0 ;
0 commit comments