diff options
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index c750162e..6d696b49 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -48,18 +48,12 @@ chrome.extension.onConnect.addListener((port, name) -> # domReady is the appropriate time to show the "vimium has been upgraded" message. # TODO: This might be broken on pages with frames. if (shouldShowUpgradeMessage()) - chrome.tabs.sendRequest(senderTabId, { name: "showUpgradeNotification", version: currentVersion }) + chrome.tabs.sendMessage(senderTabId, { name: "showUpgradeNotification", version: currentVersion }) if (portHandlers[port.name]) port.onMessage.addListener(portHandlers[port.name]) ) -chrome.extension.onRequest.addListener((request, sender, sendResponse) -> - if (sendRequestHandlers[request.handler]) - sendResponse(sendRequestHandlers[request.handler](request, sender)) - # Ensure the sendResponse callback is freed. - return false) - chrome.extension.onMessage.addListener((request, sender, sendResponse) -> if (sendRequestHandlers[request.handler]) sendResponse(sendRequestHandlers[request.handler](request, sender)) @@ -257,7 +251,7 @@ BackgroundCommands = # wait until that's over before we can call setScrollPosition. chrome.tabs.create({ url: tabQueueEntry.url, index: tabQueueEntry.positionIndex }, (tab) -> tabLoadedHandlers[tab.id] = -> - chrome.tabs.sendRequest(tab.id, + chrome.tabs.sendMessage(tab.id, name: "setScrollPosition", scrollX: tabQueueEntry.scrollX, scrollY: tabQueueEntry.scrollY) @@ -266,7 +260,7 @@ BackgroundCommands = openCopiedUrlInNewTab: (request) -> openUrlInNewTab({ url: Clipboard.paste() }) showHelp: (callback, frameId) -> chrome.tabs.getSelected(null, (tab) -> - chrome.tabs.sendRequest(tab.id, + chrome.tabs.sendMessage(tab.id, { name: "toggleHelpDialog", dialogHtml: helpDialogHtml(), frameId:frameId })) nextFrame: (count) -> chrome.tabs.getSelected(null, (tab) -> @@ -277,7 +271,7 @@ BackgroundCommands = # since it exists only to contain the other frames. newIndex = (currIndex + count) % frames.length - chrome.tabs.sendRequest(tab.id, { name: "focusFrame", frameId: frames[newIndex].id, highlight: true })) + chrome.tabs.sendMessage(tab.id, { name: "focusFrame", frameId: frames[newIndex].id, highlight: true })) # Selects a tab before or after the currently selected tab. # - direction: "next", "previous", "first" or "last". @@ -325,7 +319,7 @@ updateActiveState = (tabId) -> chrome.tabs.get(tabId, (tab) -> # Default to disabled state in case we can't connect to Vimium, primarily for the "New Tab" page. chrome.browserAction.setIcon({ path: disabledIcon }) - chrome.tabs.sendRequest(tabId, { name: "getActiveState" }, (response) -> + chrome.tabs.sendMessage(tabId, { name: "getActiveState" }, (response) -> isCurrentlyEnabled = (response? && response.enabled) shouldBeEnabled = isEnabledForUrl({url: tab.url}).isEnabledForUrl @@ -334,7 +328,7 @@ updateActiveState = (tabId) -> chrome.browserAction.setIcon({ path: enabledIcon }) else chrome.browserAction.setIcon({ path: disabledIcon }) - chrome.tabs.sendRequest(tabId, { name: "disableVimium" }) + chrome.tabs.sendMessage(tabId, { name: "disableVimium" }) else chrome.browserAction.setIcon({ path: disabledIcon }))) @@ -479,7 +473,7 @@ checkKeyQueue = (keysToCheck, tabId, frameId) -> registryEntry = Commands.keyToCommandRegistry[command] if !registryEntry.isBackgroundCommand - chrome.tabs.sendRequest(tabId, + chrome.tabs.sendMessage(tabId, name: "executePageCommand", command: registryEntry.command, frameId: frameId, @@ -510,7 +504,7 @@ checkKeyQueue = (keysToCheck, tabId, frameId) -> # If we haven't sent the completion keys piggybacked on executePageCommand, # send them by themselves. unless refreshedCompletionKeys - chrome.tabs.sendRequest(tabId, getCompletionKeysRequest(null, newKeyQueue), null) + chrome.tabs.sendMessage(tabId, getCompletionKeysRequest(null, newKeyQueue), null) newKeyQueue @@ -521,7 +515,7 @@ sendRequestToAllTabs = (args) -> chrome.windows.getAll({ populate: true }, (windows) -> for window in windows for tab in window.tabs - chrome.tabs.sendRequest(tab.id, args, null)) + chrome.tabs.sendMessage(tab.id, args, null)) # # Returns true if the current extension version is greater than the previously recorded version in @@ -602,4 +596,4 @@ chrome.windows.getAll { populate: true }, (windows) -> updateOpenTabs(tab) createScrollPositionHandler = -> (response) -> updateScrollPosition(tab, response.scrollX, response.scrollY) if response? - chrome.tabs.sendRequest(tab.id, { name: "getScrollPosition" }, createScrollPositionHandler()) + chrome.tabs.sendMessage(tab.id, { name: "getScrollPosition" }, createScrollPositionHandler()) |
