1

I'm trying to create a file handler on my app, I've not Chrome OS so the only way to try my code is to launch the app from command line with a file in parameter. My question is: how?

I've tried chrome --appid=[TheIdOfMyApp] --[Path of the file to open] but it just opens the app and the entry from my function is the same as when I open Mado with no parameters.

To check if I have an entry I do that :

chrome.app.runtime.onLaunched.addListener(function(items) { 
  console.log(items);
  // The code to open the app's window...
});

It always returns me Object {isKioskSession: false}.

[UPDATE]

My manifest looks like (these are just the file handlers and the permissions parts):

"file_handlers": {
    "text": {
        "types": ["text/md"],
        "title": "MyApp"
    }
},
"permissions": [
    {"fileSystem": ["write", "retainEntries"]},
    {"mediaGalleries": ["read", "allAutoDetected"]},
    "storage",
    "webview"
]

[END OF THE UPDATE]

Does anyone know how to check if an app's file handler is working on Windows? Is my code correct?

Thanks for your help.

Armand Grillet
  • 3,229
  • 5
  • 30
  • 60
  • This should work. Can you provide the manifest of your app? – Ben Wells Oct 08 '13 at 21:40
  • I've added the manifest parts who are used for the file handler on the post. – Armand Grillet Oct 09 '13 at 06:54
  • My guess is the text/md MIME type isn't being interpreted corerctly. Two things to try: (1) what happens if you change your handler to handle all types? (2) is anything appearing on the console after you start the app. – Ben Wells Oct 16 '13 at 04:39

2 Answers2

3

Thanks Ben Wells, it's working now. The code (if someone has the same problem one day):

In manifest.json:

"file_handlers": {
    "text": {
        "extensions": [
            "md"
        ],
        "title": "YourApp"
    }
},

And what to do on the command line (remove (x86) if you're on a 32-bit Windows):

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --app-id=YourAppId "C:\Path\To\document.md"

If you want to see if your app has detect a parameter, add the code above (the block who begins with chrome.app.runtime.onLaunched) to your background javascript.

Armand Grillet
  • 3,229
  • 5
  • 30
  • 60
  • Thanks, this helps me a lot. A word of caution, a fully qualified path is needed (in OSX at least, which is where I'm developing in). Something like this didn't work for me `~/Desktop/file.json`. I had to do `/Users/me/Desktop/file.json` – pixelfreak May 29 '16 at 00:08
0

Command line parameters to packaged apps do not seem to be implemented yet.

The open issue 165573 "Allow launch arguments to be passed to platform apps" states "We need to figure out ... if / how to pass these via the command line".

Vincent Scheib
  • 17,142
  • 9
  • 61
  • 77
  • 1
    This is true for random parameters (e.g. --show-foo) but files should be passed through correctly, if your app is setup properly as a file_handler. E.g. the Text app should be able to be started from the command line with a file it can handle. – Ben Wells Oct 16 '13 at 06:00