【发布时间】:2015-03-22 17:04:07
【问题描述】:
我已经研究了一段时间了,我想不通。我已阅读Chrome Native Messaging docs,但我不断收到“未找到指定的本机消息传递主机”。扩展错误。
注册表指向的清单:
{
"name": "com.fordcars.chromekeys",
"description": "ChromeKeys description",
"path": "C:\Users\fordcars\Desktop\Development\ChromeKeys\Debug\ChromeKeys.exe",
"type": "stdio",
"allowed_origins": [
"chrome-extension://pdkakljppghagmaoijbpicogfdbodpbc"
]
}
扩展脚本:
// Event page
var nativeName = "com.fordcars.chromekeys";
var nativePort = chrome.runtime.connectNative(nativeName);
function nativeDataReceived(data)
{
// Not used
}
function nativeDisconnected()
{
console.log("Native program disconnected. Error: " + chrome.runtime.lastError.message);
}
nativePort.onMessage.addListener(nativeDataReceived);
nativePort.onDisconnect.addListener(nativeDisconnected);
请记住,我一使用 connectNative() 就会收到错误消息。我的扩展清单中有“nativeMessaging”权限。
注册表:
Subkey: HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\com.fordcars.chromekeys
Value name: (Default)
Value: C:\Users\fordcars\Desktop\Development\ChromeKeys\Debug\nativeManifest.json
调试: 我进行了一些调试,发现如果我将 connectNative nativeName 从 com.fordcars.chromekeys 更改为其他任何内容,我 仍然 得到相同的错误,所以要么找不到注册表项或/和我没有好的 manifest.json。
谢谢!
【问题讨论】:
-
嗯,你真的应该再读一遍文档。
标签: javascript json windows google-chrome chrome-native-messaging