@@ -141,52 +141,34 @@ let privateWindowTask = {
141
141
142
142
// Implementation
143
143
144
- var WinTaskbarJumpList = {
145
- _builder : null ,
146
- _tasks : null ,
147
- _shuttingDown : false ,
148
-
149
- /**
150
- * Startup, shutdown, and update
151
- */
152
-
153
- startup : function WTBJL_startup ( ) {
154
- // exit if this isn't win7 or higher.
155
- if ( ! this . _initTaskbar ( ) ) {
156
- return ;
157
- }
158
-
159
- // Store our task list config data
160
- this . _tasks = tasksCfg ;
161
-
162
- if ( PrivateBrowsingUtils . enabled ) {
163
- tasksCfg . push ( privateWindowTask ) ;
164
- }
165
-
166
- // retrieve taskbar related prefs.
167
- this . _refreshPrefs ( ) ;
168
-
169
- // observer for private browsing and our prefs branch
170
- this . _initObs ( ) ;
171
-
172
- // jump list refresh timer
173
- this . _updateTimer ( ) ;
174
- } ,
175
-
176
- update : function WTBJL_update ( ) {
177
- // are we disabled via prefs? don't do anything!
178
- if ( ! this . _enabled ) {
179
- return ;
180
- }
181
-
182
- // do what we came here to do, update the taskbar jumplist
183
- this . _buildList ( ) ;
184
- } ,
185
-
186
- _shutdown : function WTBJL__shutdown ( ) {
187
- this . _shuttingDown = true ;
188
- this . _free ( ) ;
189
- } ,
144
+ var Builder = class {
145
+ constructor ( builder ) {
146
+ this . _builder = builder ;
147
+ this . _tasks = null ;
148
+ this . _pendingStatements = { } ;
149
+ this . _shuttingDown = false ;
150
+ // These are ultimately controlled by prefs, so we disable
151
+ // everything until is read from there
152
+ this . _showTasks = false ;
153
+ this . _showFrequent = false ;
154
+ this . _showRecent = false ;
155
+ this . _maxItemCount = 0 ;
156
+ }
157
+
158
+ refreshPrefs ( showTasks , showFrequent , showRecent , maxItemCount ) {
159
+ this . _showTasks = showTasks ;
160
+ this . _showFrequent = showFrequent ;
161
+ this . _showRecent = showRecent ;
162
+ this . _maxItemCount = maxItemCount ;
163
+ }
164
+
165
+ updateShutdownState ( shuttingDown ) {
166
+ this . _shuttingDown = shuttingDown ;
167
+ }
168
+
169
+ delete ( ) {
170
+ delete this . _builder ;
171
+ }
190
172
191
173
/**
192
174
* List building
@@ -198,13 +180,15 @@ var WinTaskbarJumpList = {
198
180
* commitBuild() will commit for real.
199
181
*/
200
182
201
- _pendingStatements : { } ,
202
- _hasPendingStatements : function WTBJL__hasPendingStatements ( ) {
183
+ _hasPendingStatements ( ) {
203
184
return ! ! Object . keys ( this . _pendingStatements ) . length ;
204
- } ,
185
+ }
205
186
206
- async _buildList ( ) {
207
- if ( this . _hasPendingStatements ( ) ) {
187
+ async buildList ( ) {
188
+ if (
189
+ ( this . _showFrequent || this . _showRecent ) &&
190
+ this . _hasPendingStatements ( )
191
+ ) {
208
192
// We were requested to update the list while another update was in
209
193
// progress, this could happen at shutdown, idle or privatebrowsing.
210
194
// Abort the current list building.
@@ -238,7 +222,7 @@ var WinTaskbarJumpList = {
238
222
}
239
223
240
224
this . _commitBuild ( ) ;
241
- } ,
225
+ }
242
226
243
227
/**
244
228
* Taskbar api wrappers
@@ -251,10 +235,13 @@ var WinTaskbarJumpList = {
251
235
// Prior to building, delete removed items from history.
252
236
this . _clearHistory ( URIsToRemove ) ;
253
237
}
254
- } ,
238
+ }
255
239
256
- _commitBuild : function WTBJL__commitBuild ( ) {
257
- if ( this . _hasPendingStatements ( ) ) {
240
+ _commitBuild ( ) {
241
+ if (
242
+ ( this . _showFrequent || this . _showRecent ) &&
243
+ this . _hasPendingStatements ( )
244
+ ) {
258
245
return ;
259
246
}
260
247
@@ -263,9 +250,9 @@ var WinTaskbarJumpList = {
263
250
this . _builder . abortListBuild ( ) ;
264
251
}
265
252
} ) ;
266
- } ,
253
+ }
267
254
268
- _buildTasks : function WTBJL__buildTasks ( ) {
255
+ _buildTasks ( ) {
269
256
var items = Cc [ "@mozilla.org/array;1" ] . createInstance ( Ci . nsIMutableArray ) ;
270
257
this . _tasks . forEach ( function ( task ) {
271
258
if (
@@ -290,19 +277,19 @@ var WinTaskbarJumpList = {
290
277
items
291
278
) ;
292
279
}
293
- } ,
280
+ }
294
281
295
- _buildCustom : function WTBJL__buildCustom ( title , items ) {
282
+ _buildCustom ( title , items ) {
296
283
if ( items . length ) {
297
284
this . _builder . addListToBuild (
298
285
this . _builder . JUMPLIST_CATEGORY_CUSTOMLIST ,
299
286
items ,
300
287
title
301
288
) ;
302
289
}
303
- } ,
290
+ }
304
291
305
- _buildFrequent : function WTBJL__buildFrequent ( ) {
292
+ _buildFrequent ( ) {
306
293
// Windows supports default frequent and recent lists,
307
294
// but those depend on internal windows visit tracking
308
295
// which we don't populate. So we build our own custom
@@ -339,9 +326,9 @@ var WinTaskbarJumpList = {
339
326
} ,
340
327
this
341
328
) ;
342
- } ,
329
+ }
343
330
344
- _buildRecent : function WTBJL__buildRecent ( ) {
331
+ _buildRecent ( ) {
345
332
var items = Cc [ "@mozilla.org/array;1" ] . createInstance ( Ci . nsIMutableArray ) ;
346
333
// Frequent items will be skipped, so we select a double amount of
347
334
// entries and stop fetching results at _maxItemCount.
@@ -385,23 +372,17 @@ var WinTaskbarJumpList = {
385
372
} ,
386
373
this
387
374
) ;
388
- } ,
375
+ }
389
376
390
- _deleteActiveJumpList : function WTBJL__deleteAJL ( ) {
377
+ _deleteActiveJumpList ( ) {
391
378
this . _builder . deleteActiveList ( ) ;
392
- } ,
379
+ }
393
380
394
381
/**
395
382
* Jump list item creation helpers
396
383
*/
397
384
398
- _getHandlerAppItem : function WTBJL__getHandlerAppItem (
399
- name ,
400
- description ,
401
- args ,
402
- iconIndex ,
403
- faviconPageUri
404
- ) {
385
+ _getHandlerAppItem ( name , description , args , iconIndex , faviconPageUri ) {
405
386
var file = Services . dirsvc . get ( "XREExeF" , Ci . nsIFile ) ;
406
387
407
388
var handlerApp = Cc [
@@ -422,25 +403,13 @@ var WinTaskbarJumpList = {
422
403
item . iconIndex = iconIndex ;
423
404
item . faviconPageUri = faviconPageUri ;
424
405
return item ;
425
- } ,
426
-
427
- _getSeparatorItem : function WTBJL__getSeparatorItem ( ) {
428
- var item = Cc [ "@mozilla.org/windows-jumplistseparator;1" ] . createInstance (
429
- Ci . nsIJumpListSeparator
430
- ) ;
431
- return item ;
432
- } ,
406
+ }
433
407
434
408
/**
435
409
* Nav history helpers
436
410
*/
437
411
438
- _getHistoryResults : function WTBLJL__getHistoryResults (
439
- aSortingMode ,
440
- aLimit ,
441
- aCallback ,
442
- aScope
443
- ) {
412
+ _getHistoryResults ( aSortingMode , aLimit , aCallback , aScope ) {
444
413
var options = PlacesUtils . history . getNewQueryOptions ( ) ;
445
414
options . maxResults = aLimit ;
446
415
options . sortingMode = aSortingMode ;
@@ -464,12 +433,12 @@ var WinTaskbarJumpList = {
464
433
) ;
465
434
} ,
466
435
handleCompletion ( aReason ) {
467
- aCallback . call ( WinTaskbarJumpList , null ) ;
436
+ aCallback . call ( aScope , null ) ;
468
437
} ,
469
438
} ) ;
470
- } ,
439
+ }
471
440
472
- _clearHistory : function WTBJL__clearHistory ( uriSpecsToRemove ) {
441
+ _clearHistory ( uriSpecsToRemove ) {
473
442
let URIsToRemove = uriSpecsToRemove
474
443
. map ( spec => {
475
444
try {
@@ -484,6 +453,61 @@ var WinTaskbarJumpList = {
484
453
if ( URIsToRemove . length ) {
485
454
PlacesUtils . history . remove ( URIsToRemove ) . catch ( Cu . reportError ) ;
486
455
}
456
+ }
457
+ } ;
458
+
459
+ var WinTaskbarJumpList = {
460
+ // We build two separate jump lists -- one for the regular Firefox icon
461
+ // and one for the Private Browsing icon
462
+ _builder : null ,
463
+ _pbBuilder : null ,
464
+ _shuttingDown : false ,
465
+
466
+ /**
467
+ * Startup, shutdown, and update
468
+ */
469
+
470
+ startup : function WTBJL_startup ( ) {
471
+ // exit if this isn't win7 or higher.
472
+ if ( ! this . _initTaskbar ( ) ) {
473
+ return ;
474
+ }
475
+
476
+ if ( PrivateBrowsingUtils . enabled ) {
477
+ tasksCfg . push ( privateWindowTask ) ;
478
+ }
479
+ // Store our task list config data
480
+ this . _builder . _tasks = tasksCfg ;
481
+ this . _pbBuilder . _tasks = tasksCfg ;
482
+
483
+ // retrieve taskbar related prefs.
484
+ this . _refreshPrefs ( ) ;
485
+
486
+ // observer for private browsing and our prefs branch
487
+ this . _initObs ( ) ;
488
+
489
+ // jump list refresh timer
490
+ this . _updateTimer ( ) ;
491
+
492
+ // We only build the Private Browsing Jump List once
493
+ this . _pbBuilder . buildList ( ) ;
494
+ } ,
495
+
496
+ update : function WTBJL_update ( ) {
497
+ // are we disabled via prefs? don't do anything!
498
+ if ( ! this . _enabled ) {
499
+ return ;
500
+ }
501
+
502
+ // do what we came here to do, update the taskbar jumplist
503
+ this . _builder . buildList ( ) ;
504
+ } ,
505
+
506
+ _shutdown : function WTBJL__shutdown ( ) {
507
+ this . _builder . updateShutdownState ( true ) ;
508
+ this . _pbBuilder . updateShutdownState ( true ) ;
509
+ this . _shuttingDown = true ;
510
+ this . _free ( ) ;
487
511
} ,
488
512
489
513
/**
@@ -492,22 +516,33 @@ var WinTaskbarJumpList = {
492
516
493
517
_refreshPrefs : function WTBJL__refreshPrefs ( ) {
494
518
this . _enabled = _prefs . getBoolPref ( PREF_TASKBAR_ENABLED ) ;
495
- this . _showFrequent = _prefs . getBoolPref ( PREF_TASKBAR_FREQUENT ) ;
496
- this . _showRecent = _prefs . getBoolPref ( PREF_TASKBAR_RECENT ) ;
497
- this . _showTasks = _prefs . getBoolPref ( PREF_TASKBAR_TASKS ) ;
498
- this . _maxItemCount = _prefs . getIntPref ( PREF_TASKBAR_ITEMCOUNT ) ;
519
+ var showTasks = _prefs . getBoolPref ( PREF_TASKBAR_TASKS ) ;
520
+ this . _builder . refreshPrefs (
521
+ showTasks ,
522
+ _prefs . getBoolPref ( PREF_TASKBAR_FREQUENT ) ,
523
+ _prefs . getBoolPref ( PREF_TASKBAR_RECENT ) ,
524
+ _prefs . getIntPref ( PREF_TASKBAR_ITEMCOUNT )
525
+ ) ;
526
+ // showTasks is the only relevant pref for the Private Browsing Jump List
527
+ // the others are are related to frequent/recent entries, which are
528
+ // explicitly disabled for it
529
+ this . _pbBuilder . refreshPrefs ( showTasks , false , false , 0 ) ;
499
530
} ,
500
531
501
532
/**
502
533
* Init and shutdown utilities
503
534
*/
504
535
505
536
_initTaskbar : function WTBJL__initTaskbar ( ) {
506
- this . _builder = _taskbarService . createJumpListBuilder ( ) ;
507
- if ( ! this . _builder || ! this . _builder . available ) {
537
+ var builder = _taskbarService . createJumpListBuilder ( false ) ;
538
+ var pbBuilder = _taskbarService . createJumpListBuilder ( true ) ;
539
+ if ( ! builder || ! builder . available || ! pbBuilder || ! pbBuilder . available ) {
508
540
return false ;
509
541
}
510
542
543
+ this . _builder = new Builder ( builder , true , true , true ) ;
544
+ this . _pbBuilder = new Builder ( pbBuilder , true , false , false ) ;
545
+
511
546
return true ;
512
547
} ,
513
548
@@ -571,7 +606,8 @@ var WinTaskbarJumpList = {
571
606
this . _freeObs ( ) ;
572
607
this . _updateTimer ( ) ;
573
608
this . _updateIdleObserver ( ) ;
574
- delete this . _builder ;
609
+ this . _builder . delete ( ) ;
610
+ this . _pbBuilder . delete ( ) ;
575
611
} ,
576
612
577
613
notify : function WTBJL_notify ( aTimer ) {
0 commit comments