我可以通过Chrome中的本机消息嵌入程序吗(例如旧的npapi插件)? [英] Can i embed program through native messaging in Chrome (like old npapi plugins)?

查看:142
本文介绍了我可以通过Chrome中的本机消息嵌入程序吗(例如旧的npapi插件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建可以将程序嵌入Chrome的Chrome扩展程序?我的意思是类似旧的NPAPI插件,例如VLC播放器,java等. 我找到了一些本机消息传递示例,但是每个示例仅用于发送简单消息来控制外部程序.

Is it possible to create Chrome extension which can embed a program into Chrome? I mean something like old NPAPI plugins such as VLC player, java, etc... I found some native messaging examples, but every example is only for sending simple messages to control an external program.

但是例如IE Tab正在使用本机消息传递,而其IE Tab引擎正在Chrome中运行...还是IE Tab使用了其他功能?

But for example IE Tab is using native messaging and their IE tab engine is running inside in Chrome... or does IE Tab use something else?

推荐答案

更新后的答案:

因此,正如评论中指出的那样,它显然使用了本地消息传递;我不知道他们在做什么.该项目声称是开源的(和GPL),但是在链接的仓库中找不到该源.最新的提交是12月13日,远没有用.

So as pointed out in comments, it does obviously use native messaging; what I can't figure out is what they are doing. The project claims to be open source (and GPL) but the source is not to be found in the linked repo; the most recent commit is Dec 13, which is nowhere near useful.

通过查看扩展代码,我会猜测,他们以某种方式使用了可能无法使用Chrome长期支持的系统API的某种有趣的黑客工具,或某种未记录的API;他们将文档标题设置为包含"ietaba:"和IE选项卡ID,然后将带有该信息的消息发布到本机消息主机.

From looking at the extension code I would guess that they are somehow using either some sort of interesting hackery using system APIs which may not be supported by Chrome long term or some sort of undocumented APIs; they set the document title to contain 'ietaba:' + the IE tab ID and then post a message to the native message host with that info.

chrome.tabs.getCurrent(function(tab) {
    // We can't attach if we don't have a window id or aren't active
    if (!tab.active || !this.windowId) {
        this.restoreTitle();
        return;
    }

    // Remember the title change is asynchronous, so don't keep changing it or the helper
    // will never find it.  We may have to retry several times to find the window after
    // a single title change
    if (document.title.indexOf('ietaba:') == -1) {
        this.realTitle = document.title;
        document.title = 'ietaba:' + Background.getNextIETabId();
    }

    var msg = {
        type: 'ATTACH',
        tabTitle: document.title,
        innerWidth: this.getIEWidth(),
        innerHeight: this.getIEHeight()
    }
    NativeHost.postMessage(msg);
}.bind(this));

我不知道他们是如何使用它来附加它的;他们似乎以某种方式获得了该部分的HWND.这让我想知道Google是否为他们提供了特殊的API或他们是否发现了一些聪明的技巧. "GPL"项目没有发布其代码似乎有点可疑...

What I can't figure out is how they could use that to attach to it; they seem to be somehow getting an HWND for that section. It makes me wonder if Google gave them special APIs or if they found some clever hack. It seems a bit suspicious that the "GPL" project doesn't release its code...

更新

进行更多挖掘之后,我发现您可以枚举系统中打开的HWND,以获取它们正在启动的选项卡的HWND.他们在标题中设置了唯一的标签ID,因此他们只枚举HWND,直到找到所需的标签为止.之后,我想象他们只是将activex控件实例化到该位置.

After doing some more digging, I've found that you can enumerate open HWNDs in the system to get the HWND for the tab they are starting up; they set a unique tab ID in the title, so they just enumerate HWNDs until they find the one they want. After that I imagine they just instantiate the activex control into that spot.

也就是说,如果Chrome更改了错误的内容,这似乎很容易损坏.我也看不到如何轻松地将页面的特定部分作为目标.您必须将其绘制到特定区域,而要使其完全正确将非常棘手.我认为我不想这样做,但是我可以看到他们必须如何做.

That said, this seems like something that could break pretty easily if Chrome changes the wrong things. I also don't see how you could easily target a specific part of a page; you'd have to be drawing to a specific region and it'd be tricky to get it all just right. I don't think I'd want to do it this way, but I can see how they must be doing it.

由于他们不遵守GPL的规定,因此有人应该诱使他们释放其代码.

Someone should pester them to release their code, since they are in violation of the GPL by not doing so.

进一步更新

为了验证情况,我尝试将"ATTACH"事件更改为附加到"Developer Tools"上-结果,现在我打开了带有网页的开发人员工具chrome窗口.

Just to verify things, I tried changing the "ATTACH" event to attach to "Developer Tools" instead -- as a result I now have a developer tools chrome window open with a web page in it.

这篇关于我可以通过Chrome中的本机消息嵌入程序吗(例如旧的npapi插件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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