topical media & game development
mobile-query-three-vendor-threex-threex.chromeWebStoreInstall.js / js
// This THREEx helper makes it easy to handle chrome.webstore.install API.
// * api description http://code.google.com/chrome/webstore/docs/inline_installation.html
// * paul kinlan post on g+ plus.google.com/116059998563577101552/posts/c9zYiA9RdC5
//
// # Code
//
@namespace
var THREEx = THREEx || {};
THREEx.ChromeWebStoreInstall = THREEx.ChromeWebStoreInstall || {};
test if the API is available
returns: {Boolean} true if the API is available, false otherwise
THREEx.ChromeWebStoreInstall.apiAvailable = function()
{
var available = typeof chrome !== 'undefined' && chrome.webstore && chrome.webstore.install;
return available ? true : false;
}
Test if the application is already installed
returns: {Boolean} true if the application is installed, false otherwise
THREEx.ChromeWebStoreInstall.isInstalled = function()
{
if( !this.apiAvailable() ) return false;
return chrome.app.isInstalled ? true : false;
}
Trigger an installation
parameter: {String} url of the application (optional)
parameter: {Function} callback called if installation succeed
parameter: {Function} callback called if installation failed
THREEx.ChromeWebStoreInstall.install = function(url, successCallback, failureCallback)
{
console.assert( this.apiAvailable() )
chrome.webstore.install(url, successCallback, failureCallback);
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.