@@ -88,6 +88,26 @@ const attach = (event, webContents) => {
8888 }
8989 } )
9090
91+ webContents . session . setPermissionCheckHandler ( ( webContents , permission ) => {
92+ console . log ( `[PERMISSION DEBUG] Permission check for: "${ permission } "` )
93+ return permission === 'media' || permission === 'display-capture' || permission === 'desktopCapture'
94+ } )
95+
96+ webContents . session . setDisplayMediaRequestHandler ( ( request , callback ) => {
97+ console . log ( '[DISPLAY MEDIA DEBUG] Display media request received' )
98+ desktopCapturer . getSources ( { types : [ 'screen' , 'window' ] } ) . then ( ( sources ) => {
99+ console . log ( '[DISPLAY MEDIA DEBUG] Available sources:' , sources . length )
100+ if ( sources . length > 0 ) {
101+ callback ( { video : sources [ 0 ] , audio : 'loopback' } )
102+ } else {
103+ callback ( { } )
104+ }
105+ } ) . catch ( err => {
106+ console . error ( '[DISPLAY MEDIA DEBUG] Error getting sources:' , err )
107+ callback ( { } )
108+ } )
109+ } )
110+
91111 webContents . on ( 'will-navigate' , ( event , url ) => {
92112 if ( ! webContents . opened ) {
93113 // The first time this view is being used, set the "opened" to true, and don't do anything
@@ -555,6 +575,7 @@ if (!gotTheLock) {
555575 app . commandLine . appendSwitch ( 'enable-features' , 'GetDisplayMediaSet,GetDisplayMediaSetAutoSelectAllScreens' ) ;
556576
557577 app . whenReady ( ) . then ( async ( ) => {
578+ app . userAgentFallback = "Pinokio"
558579
559580 // PROMPT
560581 let promptResponse
@@ -636,9 +657,20 @@ document.querySelector("form").addEventListener("submit", (e) => {
636657 } ,
637658 browser : {
638659 clearCache : async ( ) => {
639- console . log ( 'clear cache' , session . defaultSession )
660+ console . log ( 'clear cache from all sessions' )
661+
662+ // Clear default session
640663 await session . defaultSession . clearStorageData ( )
641- console . log ( "cleared" )
664+
665+ // Clear all custom sessions from active windows
666+ const windows = BrowserWindow . getAllWindows ( )
667+ for ( const window of windows ) {
668+ if ( window . webContents && window . webContents . session ) {
669+ await window . webContents . session . clearStorageData ( )
670+ }
671+ }
672+
673+ console . log ( "cleared all sessions" )
642674 }
643675 }
644676 } )
@@ -647,39 +679,8 @@ document.querySelector("form").addEventListener("submit", (e) => {
647679 theme = pinokiod . theme
648680 colors = pinokiod . colors
649681
650- // Set global permission handler for screen capture
651- session . defaultSession . setPermissionRequestHandler ( ( webContents , permission , callback ) => {
652- console . log ( `[PERMISSION DEBUG] Global session permission requested: "${ permission } "` )
653- if ( permission === 'media' || permission === 'display-capture' || permission === 'desktopCapture' ) {
654- console . log ( `[PERMISSION DEBUG] Global session granting permission: "${ permission } "` )
655- callback ( true )
656- } else {
657- console . log ( `[PERMISSION DEBUG] Global session denying permission: "${ permission } "` )
658- callback ( false )
659- }
660- } )
661682
662- // Enable desktop capture
663- session . defaultSession . setPermissionCheckHandler ( ( webContents , permission ) => {
664- console . log ( `[PERMISSION DEBUG] Permission check for: "${ permission } "` )
665- return permission === 'media' || permission === 'display-capture' || permission === 'desktopCapture'
666- } )
667683
668- // Handle getDisplayMedia requests to make web API work
669- session . defaultSession . setDisplayMediaRequestHandler ( ( request , callback ) => {
670- console . log ( '[DISPLAY MEDIA DEBUG] Display media request received' )
671- desktopCapturer . getSources ( { types : [ 'screen' , 'window' ] } ) . then ( ( sources ) => {
672- console . log ( '[DISPLAY MEDIA DEBUG] Available sources:' , sources . length )
673- if ( sources . length > 0 ) {
674- callback ( { video : sources [ 0 ] , audio : 'loopback' } )
675- } else {
676- callback ( { } )
677- }
678- } ) . catch ( err => {
679- console . error ( '[DISPLAY MEDIA DEBUG] Error getting sources:' , err )
680- callback ( { } )
681- } )
682- } )
683684
684685 app . on ( 'web-contents-created' , attach )
685686 app . on ( 'activate' , function ( ) {
0 commit comments