2

嗨,我正在将我的 NPAPI 插件转换为本机消息传递应用程序。我已经完成了http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/nativeMessaging/ 在此示例中,每个选项卡都会启动本机应用程序(.exe)。但在我的情况下,它只为 chrome 启动一次。这是我的 manifest.json。

{
   "background": {
      "page": "background.html"
   },
   "content_scripts": [ {
      "all_frames": true,
      "js": [ "contentscript.js" ],
      "matches": [ "http://*/*", "https://*/*" ],
      "run_at": "document_idle"
   } ],
   "description": "Native Messaging api",
   "key": "MIIBIjANBgkqhkiG9w0BAQEFAAO",
   "manifest_version": 2,
   "name": "Test Extension",
   "permissions": [ "tabs", "http://*/*", "https://*/*", "nativeMessaging" ],

}

这是背景.html:

<html>
   <head>
     <title></title>
   </head>
  <body>
     <script src="background_pg_helper.js"></script>
  </body>
</html>

我只能通过调用在“background_pg_helper.js”内启动我的本机应用程序

var hostName = "com.google.chrome.example.echo";
port = chrome.runtime.connectNative(hostName);

这是一个单一的实例。

我想按选项卡启动我的本机应用程序,以便一个 .exe 可以管理一个选项卡。我该怎么做?

4

0 回答 0