如何在不使用 xpcomglue 的情况下从 NPAPI 插件获取浏览器代理?
我正在开发一个插件,我需要获取给定的浏览器代理 主持人。
现在它可以使用nsIProtocolProxyService。但是,NewURI 函数(需要构造一个 URI 对象,由 nsIProtocolProxyService::resolve()) 采用 const 引用 nsACString。看起来,对于它的任何具体实现 我需要链接到 xpcomglue,但我做不到(如果我理解的话) 是的,我不应该动态链接技术 原因;我无法与 xpcomglue_s 静态链接以获得合法的 原因)。
那么,如何在不与 xpcomglue 链接的情况下获得浏览器代理呢?
I am developing a plugin, and I need to get browser proxy for a given
host.
Right now it works using nsIProtocolProxyService. However, the NewURI
function (needed to construct an URI object, used by
nsIProtocolProxyService::resolve()) takes a const reference to
nsACString. And it looks like, for any concrete implementation of it
I need to link with xpcomglue, which I cannot do (If I understand it
right, I shouldn't link dynamically for techincal
reasons; and I cannot link statically with xpcomglue_s for legal
reasons).
So, how can I get browser proxy without linking with xpcomglue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这绝对是一个棘手的问题。实际上,最好的方法(如果可能)是尽可能使用 NPN_GetURL/NPN_PostURL 样式 NPAPI 函数。如果这是不可能的,除非您可以依赖最新的浏览器版本,否则您或多或少会陷入困境。
如果您可以假设 Firefox / gecko API 的最新版本(我很确定 Firefox 3.6 支持此功能,但不确定从哪个开始;文档说 gecko SDK 1.9,但我认为当时还不存在),那么您可以将 NPN_GetValueForURL 与 NPNURLVProxy 结合使用来获取给定 URL 的代理信息。
再次请记住,这仅适用于较新的浏览器,而且我还没有机会编译支持它的兼容性矩阵;我计划将其添加到 FireBreath 中,但它没有进入 1.4,所以可能还要再过一个月我明白了。
作为故障转移选项,如果此选项不可用,最常见的解决方案是简单地获取 WinInet(Internet Explorer)的代理配置并相信它将是相同的。
这是(IMO)一个重大问题,没有真正好的解决方案。这就是众所周知,Flash 在跨代理的网络访问方面变化无常的原因。
This is definitely a tricky question. Really, the best way (when possible) is to use the NPN_GetURL/NPN_PostURL style NPAPI functions when possible. If that's not possible, you're more or less up a creek unless you can rely on a recent browser version.
If you can assume a recent version of Firefox / gecko API (I'm pretty sure Firefox 3.6 supports this, but not certain which started; docs say gecko SDK 1.9, but I don't think it was there at that point) then you can use NPN_GetValueForURL with NPNURLVProxy to get the proxy information for a given URL.
Again, keep in mind that this will only work on newer browsers, and I haven't had a chance to compile a compatibility matrix on what supports it yet; I have plans to add this to FireBreath, but it didn't make it into 1.4 so it may be another month before I get to it.
As a failover option, the most common solution if this isn't available is to simply get the proxy configuration for WinInet (internet explorer) and trust that it will be the same.
This is (IMO) a significant issue without a really good fix. This is the reason that Flash is notoriously fickle with network access across proxies as well.
您不应该开发使用 XPCOM 的 NPAPI 插件;请参阅 Mozilla 文档。也许您可以使用 Firefox 扩展来完成至少部分您想要做的事情,并使用 JS 绑定在该扩展和您的插件之间进行通信。
You shouldn't be developing NPAPI plugins that use XPCOM; see Mozilla's docs. Perhaps you could use a Firefox extension for at least part of what you are trying to do, and communicate between that and your plugin using JS bindings.