I have web app that needs to know if my extension is installed on the PC. The Extension popup is not opened. Is the background task running at all times? What I want to do is 1) determine if my extension is installed 2) change the default icon and the popup of my Extension. I have been trying to send an External Message by calling this javascript from my html page without much luck:
$(document).ready(function(){
var editorExtensionId = "lamacgnkfoieghfknfigbmhdaei";
alert("here");
// Make a simple request:
chrome.runtime.sendMessage(editorExtensionId, "snapshot_mode",
function(response) {
if (!response.success)
handleError(url);
})
}
I am wondering if the problem is that the Extension (in its closed state) cannot get a message? On the Extension side in the background task I have tried both of these without any luck:
1)
//added to handle message from controller
chrome.runtime.onConnectExternal.addListener(function(port) {
port.onMessage.addListener(function(msg) {
// See other examples for sample onMessage handlers.
});
});
2)
chrome.runtime.onMessageExternal.addListener(
function(request, sender, sendResponse) {
if (sender.url == blocklistedWebsite)
return; // don't allow this web page access
if (request.openUrlInEditor)
openUrl(request.openUrlInEditor);
});
I have been watching the Network tab in the Chrome Debugger and don't see any messages coming over. I have also added this to my manifest.json