Google Chrome扩展程序和NPAPI [英] Google Chrome Extensions and NPAPI

查看:230
本文介绍了Google Chrome扩展程序和NPAPI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一些Google Chrome扩展程序。问题在于Chrome浏览器的JavaScript API不能提供足够的功能 - 我需要使用本机代码。我考虑编写一个NPAPI插件,它将为扩展提供一些自定义的JS API。

是否可以将扩展,加上自定义NPAPI插件打包到.crx中,然后将其上传到 Chrome扩展程序商店



此方法的另一个问题是,NPAPI插件将有很多版本:Linux,Windows,OS X,x86,x86-64等。是否有可能将所有这些打包到crx中并使用最好的版本?

谢谢。

编辑:阅读这个,我意识到无法在一个crx中优雅地解决多平台问题。但是 - 是否可以将每个平台的不同crx-s上传到Chrome扩展存储? 如果您想要多平台在一个CRX中,你应该把它们按照这个顺序放在清单中:

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

请记住,将NPAPI扩展程序上传到商店只能在Google Chrome扩展程序中使用。对于Google Chrome OS(使用Google Chrome),您将无法使用NPAPI。



但是,您应该考虑PPAPI,这将成为插件开发的推荐方式: href =http://src.chromium.org/viewvc/chrome/trunk/src/ppapi/ =noreferrer> http://src.chromium.org/viewvc/chrome/trunk/src/ppapi/



与此同时,NPAPI的扩展程序中,您需要遵循本指南(效果很好):

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

请记住,你真的需要在你的扩展中使用NPAPI吗?如果您可以找到HTML5解决方法,那会更好。


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?

解决方案

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.

这篇关于Google Chrome扩展程序和NPAPI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆