Chrome PNaCl app inline installation

2019-07-21 12:17发布

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.

1条回答
来,给爷笑一个
2楼-- · 2019-07-21 12:51

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.

查看更多
登录 后发表回答