问题
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.
回答1:
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.
回答2:
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".
来源:https://stackoverflow.com/questions/19227472/how-to-open-a-chrome-packaged-app-with-a-parameter-on-windows