google-chrome - Chrome Native Messaging Api 不适用于 Linux

标签 google-chrome google-chrome-extension chrome-native-messaging

我一直在努力获取官方Native Messaging example在我的 Debian linux 上运行,但是当我单击连接按钮时,没有建立到主机的连接并且出现错误“未找到指定的 native 消息传递主机”。被退回。

从其他有同样问题的人那里,我了解到这可能是我的 native 应用程序 list 中的一个错误,但我现在好几个小时都找不到它。它位于 ~/.config/google-chrome/NativeMessagingHosts/com.google.chrome.example.echo.json并阅读:

{
  "name": "com.google.chrome.example.echo",
  "description": "Chrome Native Messaging API Example Host",
  "path": "/path/to/my/home/Desktop/native.py",
  "type": "stdio",
  "allowed_origins": [
    "chrome-extension://mcmmilohkmnlhdododggiegdjholjfan/"
  ]
}

我唯一改变的是 chrome 扩展 ID 和我检查过的路径(当从我的 shell 运行它时,应用程序启动并正确运行)。其代码取自上述示例。

知道可能有什么问题吗?我难住了。

最佳答案

好的,所以我挖掘了我的版本 (33.0.1750.117) 的 Chrome 源代码并发现 json 文件从未被读取(并使用 inotifywatch 确认了我的发现)。我认为(从 this file 第 143ff 行和 this file 判断)在搜索 list 文件时实际上从未查看过主目录。

但是我遇到了一个命令行开关,可以用来定位 list 文件:--native-messaging-hosts="com.google.chrome.example.echo=~/.config/google-chrome/NativeMessagingHosts/com.google.chrome.example.echo.json" .尽管这不是永久性的解决方案,但它对我有用,因为我在正在开发的机器上没有 root 并且无法写入/etc/opt/

关于google-chrome - Chrome Native Messaging Api 不适用于 Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21956679/

相关文章:

c++ - 使用 C++ 插件从 chrome 浏览器下载并运行 exe

html - iframe 上的滚动条在 Chrome 中没有动画

google-chrome - Chrome 开发工具 : tooltips are not displaying correctly

javascript - Chrome 扩展 : How to get specific information from a page

google-chrome - Chrome native 消息传递: can I stream a MediaStream to a native program?

javascript - 如何防止每次调用主机时都创建该类的新实例?

javascript - Google 云端硬盘中的搜索脚本

javascript - firebase 功能中的 Puppeteer 无法启动 chrome

python - 是否可以在我的 VPS 上运行服务器的情况下从 Google 获取刷新 token ?

javascript - Chrome 扩展更新流程