@@ -19,29 +19,42 @@ const CommandLine = Module("commandline", {
1919
2020 this . _callbacks = { } ;
2121
22- storage . newArray ( "history-search" , { store : true , privateData : true } ) ;
23- storage . newArray ( "history-command" , { store : true , privateData : true } ) ;
22+ [ "search" , "command" ] . forEach ( function ( mode ) {
23+ let isPrivate = liberator . isPrivateWindow ( ) ;
24+ storage . newArray ( liberator . storeName ( mode , isPrivate ) , { store : ! isPrivate } ) ;
25+ } , this ) ;
2426
2527 // Really inideal.
2628 let services = modules . services ; // Storage objects are global to all windows, 'modules' isn't.
2729 storage . newObject ( "sanitize" , function ( ) {
2830 ( {
2931 CLEAR : "browser:purge-session-history" ,
3032 QUIT : "quit-application" ,
33+ PRIVATE_END : "last-pb-context-exited" ,
34+
3135 init : function ( ) {
3236 services . get ( "obs" ) . addObserver ( this , this . CLEAR , false ) ;
3337 services . get ( "obs" ) . addObserver ( this , this . QUIT , false ) ;
38+ services . get ( "obs" ) . addObserver ( this , this . PRIVATE_END , false ) ;
3439 } ,
3540 observe : function ( subject , topic , data ) {
3641 switch ( topic ) {
3742 case this . CLEAR :
3843 [ "search" , "command" ] . forEach ( function ( mode ) {
39- CommandLine . History ( null , mode ) . sanitize ( ) ;
40- } ) ;
44+ CommandLine . History ( null , mode , liberator . isPrivateWindow ( ) ) . sanitize ( ) ;
45+ } , this ) ;
46+ break ;
47+ case this . PRIVATE_END :
48+ for ( let [ key , obj ] in Iterator ( storage ) ) {
49+ if ( key . match ( / ^ p r i v a t e - [ 0 - 9 ] / ) ) {
50+ delete storage [ key ] ;
51+ }
52+ }
4153 break ;
4254 case this . QUIT :
4355 services . get ( "obs" ) . removeObserver ( this , this . CLEAR ) ;
4456 services . get ( "obs" ) . removeObserver ( this , this . QUIT ) ;
57+ services . get ( "obs" ) . removeObserver ( this , this . PRIVATE_END ) ;
4558 break ;
4659 }
4760 }
@@ -471,7 +484,9 @@ const CommandLine = Module("commandline", {
471484
472485 this . show ( ) ;
473486
474- this . _history = CommandLine . History ( this . _commandWidget . inputField , ( modes . extended == modes . EX ) ? "command" : "search" ) ;
487+ this . _history = CommandLine . History ( this . _commandWidget . inputField ,
488+ ( modes . extended == modes . EX ) ? "command" : "search" ,
489+ liberator . isPrivateWindow ( ) ) ;
475490 this . _completions = CommandLine . Completions ( this . _commandWidget . inputField ) ;
476491
477492 // open the completion list automatically if wanted
@@ -662,7 +677,9 @@ const CommandLine = Module("commandline", {
662677 this . show ( ) ;
663678 this . _commandWidget . focus ( ) ;
664679
665- this . _history = CommandLine . History ( this . _commandWidget . inputField , ( modes . extended == modes . EX ) ? "command" : "search" ) ;
680+ this . _history = CommandLine . History ( this . _commandWidget . inputField ,
681+ ( modes . extended == modes . EX ) ? "command" : "search" ,
682+ liberator . isPrivateWindow ( ) ) ;
666683 this . _completions = CommandLine . Completions ( this . _commandWidget . inputField ) ;
667684 } ,
668685
@@ -1032,10 +1049,11 @@ const CommandLine = Module("commandline", {
10321049 * @param {string } mode The mode for which we need history.
10331050 */
10341051 History : Class ( "History" , {
1035- init : function ( inputField , mode ) {
1052+ init : function ( inputField , mode , privateBrowsing ) {
10361053 this . mode = mode ;
10371054 this . input = inputField ;
1038- this . store = storage [ "history-" + mode ] ;
1055+ this . storeName = liberator . storeName ( mode , privateBrowsing ) ;
1056+ this . store = storage [ this . storeName ] ;
10391057 this . reset ( ) ;
10401058 } ,
10411059 /**
0 commit comments