@@ -73,11 +73,11 @@ async function changeAction(tabId: number, mode?: CrxMode | 'detached') {
7373// https://bugs.chromium.org/p/chromium/issues/detail?id=1450904
7474chrome . tabs . onUpdated . addListener ( tabId => changeAction ( tabId ) ) ;
7575
76- async function getCrxApp ( ) {
76+ async function getCrxApp ( isIncognito : boolean ) {
7777 if ( ! crxAppPromise ) {
7878 await settingsInitializing ;
7979
80- crxAppPromise = crx . start ( ) . then ( crxApp => {
80+ crxAppPromise = crx . start ( { incognito : isIncognito } ) . then ( crxApp => {
8181 crxApp . recorder . addListener ( 'hide' , async ( ) => {
8282 await crxApp . detachAll ( ) ;
8383 } ) ;
@@ -104,6 +104,13 @@ async function getCrxApp() {
104104async function attach ( tab : chrome . tabs . Tab , mode ?: Mode ) {
105105 if ( ! tab ?. id || ( attachedTabIds . has ( tab . id ) && ! mode ) )
106106 return ;
107+ // if the tab is incognito, chek if can be started in incognito mode.
108+ if ( tab . incognito ) {
109+ if ( ! await chrome . extension . isAllowedIncognitoAccess ( ) || ! settings . playInIncognito ) {
110+ console . error ( 'Not authorized to launch in Incognito mode.' ) ;
111+ return ;
112+ }
113+ }
107114 const tabId = tab . id ;
108115
109116 const sidepanel = ! isUnderTest ( ) && settings . sidepanel ;
@@ -114,8 +121,7 @@ async function attach(tab: chrome.tabs.Tab, mode?: Mode) {
114121
115122 // ensure one attachment at a time
116123 chrome . action . disable ( ) ;
117-
118- const crxApp = await getCrxApp ( ) ;
124+ const crxApp = await getCrxApp ( tab . incognito ) ;
119125
120126 try {
121127 if ( crxApp . recorder . isHidden ( ) ) {
0 commit comments