File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
2- const { app, BrowserWindow} = require ( 'electron' ) ;
2+ const { app, BrowserWindow, session } = require ( 'electron' ) ;
33const localShortcut = require ( 'electron-localshortcut' ) ;
44const isDev = require ( 'electron-is-dev' ) ;
55
@@ -54,13 +54,25 @@ function inspectElements() {
5454
5555const addExtensionIfInstalled = ( name , getPath ) => {
5656 const isExtensionInstalled = name => {
57+ // For Electron >=9.
58+ if ( session . defaultSession . getAllExtensions ) {
59+ return { } . hasOwnProperty . call ( session . defaultSession . getAllExtensions ( ) , name ) ;
60+ }
61+
62+ // TODO: Remove this when targeting Electron >=9.
5763 return BrowserWindow . getDevToolsExtensions &&
5864 { } . hasOwnProperty . call ( BrowserWindow . getDevToolsExtensions ( ) , name ) ;
5965 } ;
6066
6167 try {
6268 if ( ! isExtensionInstalled ( name ) ) {
63- BrowserWindow . addDevToolsExtension ( getPath ( name ) ) ;
69+ // For Electron >=9.
70+ if ( session . defaultSession . loadExtension ) {
71+ session . defaultSession . loadExtension ( getPath ( name ) ) ;
72+ } else {
73+ // TODO: Remove this when targeting Electron >=9.
74+ BrowserWindow . addDevToolsExtension ( getPath ( name ) ) ;
75+ }
6476 }
6577 } catch ( _ ) { }
6678} ;
You can’t perform that action at this time.
0 commit comments