I am working on a chrome app and its basically done, however I am adding code to my customer's website to have it determine if the app is installed on chrome or not.
In order to do this I need to check for a file "manifest.json" is available for the app to determine if its installed or not.
I am using the below code that I got from another posted question on here:
function detectChromeExtension(extensionId, accesibleResource, callback){
if (typeof(chrome) !== 'undefined'){
var xmlHttp = new XMLHttpRequest(),
testUrl = 'chrome-extension://' +extensionId +'/' +accesibleResource;
xmlHttp.open('HEAD', testUrl, true);
xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlHttp.timeout = 1000;
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && typeof(callback) == 'function') {
if (xmlHttp.status == 200) {
callback.call(this, true);
} else {
callback.call(this, false);
}
}
}
xmlHttp.ontimeout = function() {
if (typeof(callback) == 'function')
callback.call(this, false);
}
xmlHttp.send();
} else {
if (typeof(callback) == 'function')
callback.call(this, false);
}
};
detectChromeExtension('gcjbmhbihobfgpjmfbooldocijijdpig', 'manifest.json', myCallbackFunction);
function myCallbackFunction(extensionExists) {
if (extensionExists){
console.log('Extension present');
} else {
console.log('Extension not present');
}
}
By checking the chrome console I am getting the following output:
Denying load of chrome-extension://gcjbmhbihobfgpjmfbooldocijijdpig/manifest.json. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
so to fix this I am trying to add "web_accessible_resources": ["manifest.json"] into my manifest.json but it tells me that this line doesn't follow syntax.
Here is the full manifest.json:
{
"name": "Watch TBR",
"version": "1.0",
"manifest_version": 2,
"default_locale": "en",
"description": "Easy access to WatchTBR.com",
"icons": { "128": "icon_128.png", "16": "icon_16.png" },
"app": {
"urls": [
"http://www.watchtbr.com/"
],
"launch": {
"web_url": "http://www.watchtbr.com/"
}
},
"web_accessible_resources": ["manifest.json"],
"permissions":["http://www.watchtbr.com"]
}
Any help on this is greatly appreciated.