Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
600 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...