From b1506439e172f81f8233b17489fc6f0190eef95b Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 30 Dec 2009 14:25:00 -0800 Subject: Add infrastructure to handle sendRequest calls in the background page. --- background_page.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/background_page.html b/background_page.html index 9a30f55d..0213eebc 100644 --- a/background_page.html +++ b/background_page.html @@ -18,6 +18,8 @@ getSetting: getSetting }; + var sendRequestHandlers = {}; + // Event handlers var selectionChangedHandlers = []; var getScrollPositionHandlers = {}; // tabId -> function(tab, scrollX, scrollY); @@ -40,6 +42,13 @@ }); + chrome.extension.onRequest.addListener(function (request, sender, sendResponse) { + var senderTabId = sender.tab ? sender.tab.id : null; + + if (sendRequestHandlers[request.handler]) + sendResponse(sendRequestHandlers[request.handler](request)); + }); + function handleReturnScrollPosition(args) { if (getScrollPositionHandlers[args.currentTab.id]) { // Delete first to be sure there's no circular events. -- cgit v1.2.3