1

Using a NaCl packaged app, is it possible to handle a MIME type for a dummy resource within a webpage (the type and location of resource does not matter e.g from the app pkg)?

I need it to just launch the already installed packaged app without user's mouse click.

Thank you!

KaBa
  • 285
  • 3
  • 16
  • If launching the app is your goal, again, [as I said](http://stackoverflow.com/a/28297109/934239) in your previous question `externally_connectable` is all you need. – Xan Feb 05 '15 at 11:14
  • Also see: http://stackoverflow.com/questions/19519277/activate-chrome-app-from-web-page (not a duplicate) – Xan Feb 05 '15 at 11:23
  • @Xan I really appreciate your help. The workflow for `externally_connectable` is not clear to me. Could you please let me know how to use it and where and what methods should be called? – KaBa Feb 05 '15 at 12:34
  • See [this answer](http://stackoverflow.com/a/26095346/934239). It pertains to extensions, but as far as I know it should work as well in an app. You put the event listener into the background/event script of the app, it will wake up when receiving the message and you can create your app's window from there. – Xan Feb 05 '15 at 12:47
  • @Xan But, it seems the app needs to be launched before receiving any message. Am I right? If yes, how can I launch the app? – KaBa Feb 05 '15 at 13:17
  • No, that's not true. The background script of an app is launched on Chrome startup, registers events (like `onLaunched`) and goes to sleep. If you register a messaging event listener on the top level of the background script, it will wake the script. – Xan Feb 05 '15 at 13:21
  • This is becoming too long for a discussion that _is not even on the question topic_. – Xan Feb 05 '15 at 14:49

1 Answers1

4

Yes, you can handle a mimetype from an Native Client app. See https://developer.chrome.com/apps/manifest/nacl_modules.

Basically, you add this to your manifest.json:

"nacl_modules": [{
  "path": "NaClModule.nmf",
  "mime_type": "application/x-my-fancy-mimetype"
}],
...

When the user clicks a link to an object with this mimetype, Chrome will open a new window, create a fullscreen Native Client module, and pass the URL as src:

<embed type="application/x-my-fancy-mimetype" src="url-of-file">
binji
  • 1,860
  • 9
  • 9
  • Once the NaCl module launches it calls `pp::Instance::HandleDocumentLoad` with the the URL (assuming you're using the C++ interface). Docs here https://developer.chrome.com/native-client/pepper_dev/cpp/classpp_1_1_instance#a6cd99065ef0a55555647253442563225 – Benjineer Feb 17 '16 at 07:50