From fb67cfdd2ca8c09453cc896fd02d08ed5a74a8a4 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 4 Mar 2016 08:51:39 +0000 Subject: Key bindings; disable on disconnect. This reinstates the feature whereby we disable the content script when we lose contact with the background page, e.g., on upgrade. From my investigations, this doesn't appear to be absolutely necessary. Nevertheless, it's cleaner like this. --- content_scripts/vimium_frontend.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 72be5510..0ae3d229 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -214,7 +214,11 @@ window.addEventListener "hashchange", onFocus # initializeOnDomReady = -> # Tell the background page we're in the dom ready state. - chrome.runtime.connect({ name: "domReady" }) + chrome.runtime.connect(name: "domReady").onDisconnect.addListener -> + # We disable content scripts when we lose contact with the background page. + isEnabledForUrl = false + chrome.runtime.sendMessage = -> + window.removeEventListener "focus", onFocus # We only initialize the vomnibar in the tab's main frame, because it's only ever opened there. Vomnibar.init() if DomUtils.isTopFrame() HUD.init() -- cgit v1.2.3