Chrome PNaCl应用程序内联安装 [英] Chrome PNaCl app inline installation

查看:758
本文介绍了Chrome PNaCl应用程序内联安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想分发 PNaCl 应用,内嵌安装,并在不离开当前页面的情况下使用应用 。我已经在CWS上发布了这个应用程序。该应用需要一些用户权限。内联安装可以运行,应用程序将显示在Chrome浏览器应用程序部分。但是,我得到这个错误:

lockquote
NaCl模块加载失败:无法加载清单URL
/ blockquote>

当我尝试使用以下方式加载应用程序时:

 < embed id =testapp
width = 0 height = 0
src =testapp.nmf
type =application / x-pnacl/>

这是testapp.nmf文件,它位于我上传到开发人员仪表板的.zip pkg中。


$ b

{
program:{
portable:{
pnacl-translate:{
url:testapp.pexe
},
pnacl-debug:{
url:testapp_unstripped.bc
}
}
}
}

包文件中的Manifest.json如下所示:

 <$ c 
name:testapp,
version:0.0.0.2,
manifest_version:2,
description:TCP / UDP测试,
offline_enabled:true,
图标:{
128:icon128.png
},
app :{
background:{
scripts:[background.js]
}
},
权限:[
{
socket:[
tcp-listen: *:*,
tcp-connect,
resolve-host,
udp-bind:*:*,
udp-send-to: *:*

}
]
}

HTML网页位于Google的 blogspot.com 上,并已成功验证。

解决方案

观察: 不能在打包的应用程序之外使用套接字API(因为否则无法为其获取权限)。

  • 打包应用程序大多是自包含的:它不是与普通浏览器交互的东西,它是预先集合的资源,显示在单独的窗口中。

  • 某个网站仍然可以与应用程序通信。



  • 好像您正尝试遵循两个指南立即为一个打包的应用程序和一个网络应用程序。 PNaCl可以通过在网站上放置pexe和清单来在Web应用程序的环境中工作;但您需要原始的网络访问权限,并且只能在打包的应用中请求。



    绝对可以使用内联安装来添加应用到用户的机器,但是你不能在普通页面中嵌入一个模块。



    你的模块只能嵌入到应用程序自己的页面中。所以如果你想展示一些用户界面,你需要将这个页面与应用程序打包在一起,并用 chrome.app.window.create 来显示它。



    如果您绝对需要向某个网站公开功能,您可以将它列在 externally_connectable 中并使用消息API 与应用程序的后台页面进行通信。



    应用程序始终有一个活动页面,即页面,如果页面处于闲置状态则会卸载。因此,如果您只是通过动态创建< embed> 元素将模块嵌入到该页面中,则可能会失败。但是,如果您使用的是 externally_connectable 方法,则应该能够保持端口处于打开状态,这将导致页面继续运行。


    I want to distribute a PNaCl app, inline installation and use the app without leaving the current page. I have published the app on CWS. The app needs some user permissions. Inline installation works and the app appears in the Chrome browser apps section. But, I get this error :

    "NaCl module load failed: could not load manifest url"

    when I try to load the app using:

      <embed id="testapp"
             width=0 height=0
             src="testapp.nmf"
             type="application/x-pnacl" />
    

    This is the testapp.nmf file which is located in the .zip pkg that I uploaded to developers dashboard.

    {
      "program": {
        "portable": {
          "pnacl-translate": {
            "url": "testapp.pexe"
          },
          "pnacl-debug": {
            "url": "testapp_unstripped.bc"
          }
        }
      }
    }
    

    Manifest.json in the package file looks like :

    {
      "name": "testapp",
      "version": "0.0.0.2",
      "manifest_version": 2,
      "description": "TCP/UDP test",
      "offline_enabled": true,
      "icons": {
        "128": "icon128.png"
      },
      "app": {
        "background": {
          "scripts": ["background.js"]
        }
      },
      "permissions": [
        {
            "socket": [
                "tcp-listen:*:*", 
                "tcp-connect", 
                "resolve-host", 
                "udp-bind:*:*", 
                "udp-send-to:*:*"
            ]
        }
      ]
    }
    

    The HTML page is on Google's blogspot.com and verified successfully.

    解决方案

    Observations:

    • You can't use socket APIs outside a packaged app (since there is no way to get permissions for them otherwise).
    • A packaged app is mostly self-contained: it's not something interacting with the normal browser, it's a preset collection of resources that is displayed in a separate window.
    • A certain website can still communicate with the app.

    Seems like you're trying to follow two guides at once, for a packaged app and a web app. PNaCl can work in the context of a web app by just placing the pexe and the manifest on the site itself; but you require raw network access, and it can only be requested in a packaged app.

    You can absolutely use inline install to add the app to the user's machine, but you can't embed a module from it in a normal page.

    Your module can only be embedded in the app's own pages. So if you wanted to show some UI, you need to make that a page packaged together with the app and show it with chrome.app.window.create.

    If you absolutely need to expose functionality to a certain website, you can list it in externally_connectable and use messaging API to communicate with the app's background page.

    An app always has an event page, that is a page that unloads if it's idle. So if you just embed your module in that page by dynamically creating an <embed> element, it may fail. However, if you're using the externally_connectable method, you should be able to keep a port open, that would cause the page to keep running.

    这篇关于Chrome PNaCl应用程序内联安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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