How to access chrome flags in electron?


#1

My app uses the wacom plugin, which uses NPAPI, which is deprecated by google Chrome from version 42.
In the chrome browser it still works by changing the chrome/flags/NPAPI to enabled.
Does anyone know if there is a way to access these flags in electron?


#2

I believe you’re looking for the app.commandLine.appendSwitch method.

For instance, in one internal project I needed to use the now deprecated non-standard Proxy API of Chromium, so I ended up adding the following flag in my main file:

app.commandLine.appendSwitch "js-flags", "--harmony_proxies"

#3

Yes, that’s it. Found the switch:
app.commandLine.appendSwitch(’–enable-npapi’)
Now it works fine, thanks alot!


#4

@tungsten, what version of electron and chromium this is supported for? We are also trying this flag with electron version 0.31.2 and chromium version 44, but it does not work. We tried both ways

app.commandLine.appendSwitch(’–enable-npapi’)

and

app.commandLine.appendSwitch(‘enable-npapi’)

your help will be much appreciated.


#5

0.31.2 is the right version. I have

app.commandLine.appendSwitch('--enable-npapi');

in my main.js
Also, web-preferences plugins should be set to true:

mainWindow = new BrowserWindow({x: 100, y: 100, width: 800, height: 600, 'web-preferences': {'plugins': true}});

have you got that?


Embedding a Unity3d webplayer
#6

Thank you @tungsten, That did the trick.

We installed unity webplayer plugin through chrome. Firefox was also able to see that plugin for some reason. Even we did not have to specify any another information to electron’s chromium. it found it somehow. My guess is that it was somehow indicated by some windows registry.