Is there any way to use c++ in chrome extension?

前提是你 提交于 2019-12-18 12:07:59

问题


Is it possible to use c++ binary in chrome extension ?


回答1:


Yes, like with other browsers, you can write a NPAPI plugin that will comunicate with your extension.

See the related Google page at code.google.com

And a more generic description at wikipedia




回答2:


NPAPI was deprecated from Chrome/Opera for security concerns.

You can still use NPAPI if you are targeting firefox, but if Firefox follows the trend it might disable it at some point as well.

The better options you have today are

Use NaCl if you are targeting only Chrome

You can use instead NativeClient (A.K.A. NaCL, A.K.A. PPAPI - Pepper Plugin API)

All code ran inside NaCl is sandboxed so it's as secure as a javascript extensions.

Use asm.js if you targeting all Platforms

Using Emscripten you can compile C/C++ code into highly optimized javascript format called asm.js. It is designed to have near native performance and right now has decent support from grade-A browsers except Safari. Though performance is better in Firefox than Chrome at the moment.

Major browser vendors are also working on a new standard called WebAssembly that is partially inspired by asm.js, but not ready for prime usage as of this article

Update 2018-05-14

Native Client is being deprecated and asm.js is being replaced by WebAssembly which is becoming the new standard to compile C++ code for the web.




回答3:


As said upper, you can use NaCl for chrome and asm.js with Emscripten for all platforms, but it's reverse engineering is simpler, than binary. Now There is a middle solution: webassembly - LLVM bytecode embeded in browser is supported by most modern browsers https://caniuse.com/#feat=wasm . So Emscripten can compile C++ to wasm, mostly it's faster than asm.js.



来源:https://stackoverflow.com/questions/1666957/is-there-any-way-to-use-c-in-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!