Skip to content

Instantly share code, notes, and snippets.

@autonome
Last active December 23, 2015 13:49
Show Gist options
  • Save autonome/6644198 to your computer and use it in GitHub Desktop.
Save autonome/6644198 to your computer and use it in GitHub Desktop.
function installAppFromManifestObj(obj) {
//const {Cc, Ci, Cu, Cm} = require('chrome')
var Cu = Components.utils
Cu.import("resource://gre/modules/WebappsInstaller.jsm")
var installParam = {
app: {
manifest : obj,
origin: obj.url
}
}
console.log(installParam)
try {
var app = WebappsInstaller.init(installParam)
WebappsInstaller.install(installParam, obj).then(function success() {
console.log('success!')
}, function failure(error) {
console.log('error', error)
})
} catch(error) {
console.log('exception', error)
}
}
installAppFromManifestObj({
"app": {
"manifest": {
"name":"Zimbra Web Client Sign In",
"launch_path":"/zimbra/#1",
"url":"https://mail.mozilla.com/zimbra/#1",
"description":"Standalone: The Web in an App Form-factor.",
"icons":{"16":"https://mail.mozilla.com/zimbra/img/logo/favicon.ico"}
},
"origin":"https://mail.mozilla.com/zimbra/#1"
}
})
@felipc
Copy link

felipc commented Sep 20, 2013

try:

var app = WebappsInstaller.init(installParam);
WebappsInstaller.install(installParam, obj).then( () => { ... notify success } );

totally untested! if it doesn't work, look at webappsUI.jsm:195... I based it from there

@autonome
Copy link
Author

Gist updated to use new promises code. I'm not getting the typeerror exception anymore, but just silent failure now.

Felipe, in the new code, the manifest object appears to be passed to WebappsInstaller in three places, which is seems weird. Is that right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment