Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
605 views
in Technique[技术] by (71.8m points)

cross platform - Google Chrome Extensions and NPAPI

I need to write some Google Chrome extension. The problem is that Chrome JavaScript APIs don't give me enough power - I need to use native code. I thought about writing a NPAPI plug-in that will provide the extension some custom JS APIs.

Is it possible to package the extension, plus the custom NPAPI plugin inside a .crx, and then upload it to the Chrome Extensions Store?

Another issue with this method is that the NPAPI plugin will have many versions: Linux, Windows, OS X, x86, x86-64, etc. Is it possible to package all these in the crx and use the best version?

Thanks.

EDIT: After reading this, I realized that it's not possible to elegantly solve the multi-platform issue in one crx. But - is it possible to upload different crx-s for each platform to the Chrome extension store?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you want multi platform in one CRX, you should put them in this order within the manifest:

"plugins": [
   { "path": "plugin-windows.dll" },
   { "path": "plugin-linux.so" },
   { "path": "plugin-mac.plugin" }
]

Remember uploading your NPAPI extension to the store will only work in Google Chrome Extensions. In the case of Google Chrome OS (which uses Google Chrome), you will not be able to use NPAPI.

But you should look into PPAPI which will be the recommended way doing plugin development for extension:

http://src.chromium.org/viewvc/chrome/trunk/src/ppapi/

In the meantime NPAPI in extensions, you need to follow this guide (which works great):

http://code.google.com/chrome/extensions/npapi.html

Just remember, do you really need to use NPAPI in your extension? If you could find a HTML5 workaround, it would be better.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...