15

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?

Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288

1 Answers1

16

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.

chitti
  • 281
  • 1
  • 4
  • 12
Mohamed Mansour
  • 39,445
  • 10
  • 116
  • 90
  • the dll/so files should be compiled for x86 or x86-64? In what versions of Google Chrome does PPAPI work? – Alon Gubkin Nov 12 '10 at 23:33
  • PPAPI is currently work in progress, you can find more information regarding that, here: http://www.chromium.org/developers/design-documents/pepper-plugin-implementation Well, compilation shouldn't matter (afaik), I have a 64bit system and I compile it normally there and it works on 32bit platforms. – Mohamed Mansour Nov 13 '10 at 01:53
  • 1
    @MohamedMansour For Linux it does matter. I have to compile *.so file separately for Linux 32-bit and 64-bit for project http://slimtext.org – Tyler Liu Mar 26 '13 at 13:58
  • @TylerLong yea for Linux you need different architectures :) – Mohamed Mansour Mar 27 '13 at 01:28