background.js revision 5821806d5e7f356e8fa4b058a389a808ea183019
1/**
2 * Handles requests sent by the content script.  Shows an infobar.
3 */
4function onRequest(request, sender, sendResponse) {
5  // The number of matches is sent in the request - pass it to the
6  // infobar.
7  var url = "infobar.html#" + request.count;
8
9  // Show the infobar on the tab where the request was sent.
10  chrome.experimental.infobars.show({
11    tabId: sender.tab.id,
12    path: url
13  });
14
15  // Return nothing to let the connection be cleaned up.
16  sendResponse({});
17};
18
19// Listen for the content script to send a message to the background page.
20chrome.extension.onRequest.addListener(onRequest);
21