是否可以从 chrome.manifest 引用远程内容? (XUL跑步者)

发布于 2024-10-11 15:27:09 字数 860 浏览 1 评论 0原文

我有一个 xulrunner 应用程序,我一直在尝试引用 chrome.manifest 文件中的远程内容。这是我工作的公司的申请;它作为一种互联网监控服务在多台计算机上运行(其中大多数也被其他员工使用)。我想解决的问题是:更新此类应用程序的代码通常需要我手动将修改后的文件复制到运行该应用程序的每台计算机(我没有成功尝试通过 xulrunner 平台进行自动更新) )。这个过程变得非常乏味。我想要的是一个 Web 服务器,其中所有 xul 和 js 文件都可以访问,以便每个应用程序都可以从那里引用它们。这只需要我更新该服务器上的代码,并且应用程序(重新启动时)将自动获取最新的代码。

我设法做到的:

我可以使用基于 http 的 url 从 xul 文件引用 js 脚本,并且一切正常(我可以使用本地、二进制组件等),尽管 xul 文件必须是本地的 - 我想改变。但是当我在 chrome.manifest 中写入如下行:

content my_app http://path/to/app/files/

然后使用 default/preferences/pref.js

pref("toolkit.defaultChromeURI", "chrome://my_app/content/my_app.xul");

中的行它只是打开一个控制台窗口(为了测试我使用 -console 选项手动运行应用程序)并且没有执行任何代码。该文件可以使用 wget 远程下载,所以我想这不是网络服务器的问题。

这些应用程序可在 Windows 计算机上运行。

是否存在某种安全问题导致这种行为,或者我做错了什么?是否可以将基于 http 的远程内容注册为 chrome?

I have a xulrunner application and I've been trying to reference remote content from chrome.manifest file. Tt's an application for the company I work in; it's run on a number of computers (most of them are used by other employees as well) as a kind of an internet monitoring service. The problem I'd like to solve is this: updating the code of such application usually requires me to manually copy the modified files to every computer that the application is running on (I've had no luck trying to make automatic updates via xulrunner platform). This process has become very tedious. What I'd like to have is a web server, where all of the xul and js files would be accessible, so that every application could reference them from there. This would require me only to update the code on that server, and the applications (when restarted) would automatically get the latest code.

What I managed to do:

I can reference js scripts from a xul file using http based urls and everything works fine (I can use local, binary components etc.), although the xul file has to be local - that I'd like to change. But when I write in chrome.manifest a line like:

content my_app http://path/to/app/files/

and then use the line in default/preferences/pref.js

pref("toolkit.defaultChromeURI", "chrome://my_app/content/my_app.xul");

it just opens a console window (to test I manually run the application with the -console option) and no code gets executed. The file can be downloaded remotely using wget so I guess this isn't the web server issue.

The applications work on Windows machines.

Is there some kind of security issue causing such behavior or am I doing something wrong? Is it even possible to register remote, http based content as chrome?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

指尖凝香 2024-10-18 15:27:09

简短的回答:

可以运行远程 XUL 应用程序,但需要在应用程序中进行大量结构更改。

详细说明:

我们在我们的产品中使用了类似的概念,就像您想在您的公司中引入的概念一样,三周以来。

您可以管理 XUL-Runner 从远程位置获取 XUL 文件并执行它们。您可以拥有所有相关的内容,例如 XUL 文件、在服务器上绑定 js 文件:)

但是:由于安全限制,它不适用于“chrome://...”路径
意思是:您必须更改应用程序中包含 chrome 路径的所有引用:(

将 xul 文件、绑定和 js 文件中的所有 src 规范从“chrome://dir/somefile”更改为“../”等相对路径dir/somefile”或“dir/somefile”

以从远程启动应用程序,将如下行添加到您的首选项文件

pref("toolkit.defaultChromeURI", "http://"LOCATION"/bla.xul");
(XUL-Runner在启动应用程序后会提示安全警告)

20分钟前我测试了一些东西并发现(在删除客户端上的几乎所有东西之后,特别是现在在服务器上的chrome文件夹)你甚至不需要chrome .manifest 了,想通过在谷歌上查找“remote XUL chrome.manifest”来了解原因(这就是为什么我在这里找到你的问题)。

我在客户端上需要的只是: XUL-Runner 和应用程序路径中的 appication.ini 和 defaults/prefs.js

祝你好运

Short answer:

It is possible to run a remote XUL app, but requires lots of structure changes across your application.

In detail:

We use a similar concept like you want to introduce in your company since 3 weeks in our product.

You can manage XUL-Runner to get XUL-files from a remote location AND execute them. You can have all relevant stuff like XUL-files, bindings an js- files on a server :)

BUT: it doesn't work with "chrome://..." paths because of security restrictions
meaning: you will HAVE TO change all referece containing chrome-paths across your application :(

change all src specifications in xul-files, bindings and js-files from "chrome://dir/somefile" to relative paths like "../dir/somefile" or "dir/somefile"

to start app from remote add a line like following to your prefs file

pref("toolkit.defaultChromeURI", "http://"LOCATION"/bla.xul");
(XUL-Runner will promt a securuty warning after starting app)

20 mins ago I tested some stuff and found out (after deleting nearly all stuff on client, especially the chrome folder which is on server now) that you even do not need the chrome.manifest anymore and wanted to know WHY by looking for "remote XUL chrome.manifest" on google (thats why I found your question here).

All I needed on client is: the XUL-Runner and in app-path the appication.ini and the defaults/prefs.js

good luck

萌酱 2024-10-18 15:27:09

首先,是的,XPCOM 可以工作,来自服务器的二进制文件:未经测试,访问本地二进制文件可以工作
但是在几乎每个函数中需要一个或多个以下访问方法之前,您必须在第一行或一行中添加代码怪物(每当 XUL-Runner 抱怨安全问题时):/

netscape.security.PrivilegeManager.enablePrivilege( “此处为以下一项或多项”);

通用浏览器阅读
通用浏览器写入
通用XP连接
通用偏好阅读
通用首选项写入
UniversalFileRead

如果您担心安全性,我建议您在 Mozilla 开发网络/中心上阅读它,以了解该东西到底是做什么的。我的一位同事向我发布了该代码,但我还没有时间进行调查:P

但这还不是全部,您将遇到更多访问问题(至少在架构更改之后我仍然遇到问题)。您将无法像以前那样轻松访问 js 内容(函数...)。

通常,您必须修改您的调用,例如

parent.YOURFUNCTION或window.parent.YOURFUNCTION或类似的调用,

以便您了解我所说的“不太容易”的意思,这是架构更改后的代码示例(曾经是不到一半...):

document.getElementById("mainIframe").contentDocument.getElementById("UrlBar").value = getSelectedBrowser().contentWindow.location.href;

first, yes, XPCOM works, binaries from server: not tested, access to local binaries works
but you have to add that monster of code in first line or one line before you need one or more of the following access methods IN NEARLY EACH function (whenever XUL-Runner complains about security stuff) :/

netscape.security.PrivilegeManager.enablePrivilege(" here one or more of the following ");

UniversalBrowserRead
UniversalBrowserWrite
UniversalXPConnect
UniversalPreferencesRead
UniversalPreferencesWrite
UniversalFileRead

If you are worried about security, I recommend you to read it on Mozilla Development Network/Center to learn what exactly that stuff does. One of my workmates posted me that code and I did not yet have time to investigate :P

But thats's not all, you will have more access problems (at least I still have after that architecture change). You won't have that easily have access to js- stuff (functions...) like before.

Often you will have to modify your invokations like

parent.YOURFUNCTION or window.parent.YOURFUNCTION or similar

in order you have an idea what I mean with "not that easily", here is an example of code after architecture change (which used to be less of half of that...):

document.getElementById("mainIframe").contentDocument.getElementById("UrlBar").value = getSelectedBrowser().contentWindow.location.href;

情栀口红 2024-10-18 15:27:09

以下是您可能会发现有用的链接: http://fixunix.com/mozilla /575473-re-remote-xul.html。另请阅读原始消息,了解如何实现您想要的目标的提示。

Here's a link to what you may find usefull: http://fixunix.com/mozilla/575473-re-remote-xul.html. Read the original message as well for hints how to achieve what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文