Here’s my code:
...
if($("input:checked").length > 0) {
chrome.tabs.create(
{url:"http://www.multiculturalyp.com/multiculturalypnewtab.crx"},
function(tab) {
chrome.management.onInstalled.addListener(function(info){alert("Installed A");});
chrome.management.onEnabled.addListener(function(info){alert("Enabled A");});
}
);
chrome.tabs.create(
{url:"instructions.html"},
function(tab) {
chrome.management.onInstalled.addListener(function(info){alert("Installed B");});
chrome.management.onEnabled.addListener(function(info){alert("Enabled B");});
}
);
}
...
So what is happening: I wrote an extension, and if a user so chooses from with that extension’s options, a second extension is installed, so I launch instructions in the form of html to tell the user what to click if they really want it installed. I want to hide the instructions (close the instructions tab) automatically ones the second extension installs. The problem is that it appears that neither the onInstalled nor the onEnabled events are triggered. My example above is a simplified version of the logic that just alerts when the events are triggered but so far I can’t get the onInstalled event for extension B to be triggered in extension A. I registered the events twice each when they didn’t work the first time. The alerts end in A or B just to tell me whether the first registered listener, the second or both get triggered, but the should all get triggered in extension A.
So can this be done? If so, what am I doing wrong.
Thanks in advance.
My suggestion – try to bind events before executing a url with extension. Bind event once and check its type to make action (in the background page!):