diff options
| author | Daniel MacDougall | 2012-03-31 20:19:08 -0700 |
|---|---|---|
| committer | Daniel MacDougall | 2012-03-31 20:19:08 -0700 |
| commit | c5dfef538d267861a6cfe4f1144823449fbe73b8 (patch) | |
| tree | e87de00c4a9ddc868d1a704a6af1ea5d3988d513 | |
| parent | 71413f5124d8f807555f1e852959652ab85b16bf (diff) | |
| download | vimium-c5dfef538d267861a6cfe4f1144823449fbe73b8.tar.bz2 | |
Immediately disable Vimium if current page is excluded via the popup
| -rw-r--r-- | background_page.html | 14 | ||||
| -rw-r--r-- | vimiumFrontend.js | 12 |
2 files changed, 23 insertions, 3 deletions
diff --git a/background_page.html b/background_page.html index b80f49b4..94389436 100644 --- a/background_page.html +++ b/background_page.html @@ -117,6 +117,10 @@ var excludedUrls = settings.get("excludedUrls"); excludedUrls += "\n" + url; settings.set("excludedUrls", excludedUrls); + + chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT, active: true }, function(tabs) { + updateActiveState(tabs[0].id); + }); } function saveHelpDialogSettings(request) { @@ -338,11 +342,15 @@ delete framesForTab[tab.id]; } - function updateIconState(tabId) { + function updateActiveState(tabId) { if (openTabs[tabId]) { var isEnabled = isEnabledForUrl({url: openTabs[tabId].url}).isEnabledForUrl; var iconPath = isEnabled ? "icons/icon48.png" : "icons/icon48disabled.png"; chrome.browserAction.setIcon({path: iconPath}); + + if (!isEnabled) { + chrome.tabs.connect(tabId, { name: "disableVimium" }).postMessage(); + } } } @@ -359,7 +367,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if (changeInfo.status != "loading") { return; } // only do this once per URL change updateOpenTabs(tab); - updateIconState(tabId); + updateActiveState(tabId); }); chrome.tabs.onAttached.addListener(function(tabId, attachedInfo) { @@ -399,7 +407,7 @@ }); chrome.tabs.onActiveChanged.addListener(function(tabId, selectInfo) { - updateIconState(tabId); + updateActiveState(tabId); }); chrome.windows.onRemoved.addListener(function(windowId) { diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 58863c6f..80a9dd3b 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -177,6 +177,10 @@ function initializePreDomReady() { port.onMessage.addListener(function (args) { refreshCompletionKeys(args.completionKeys); }); + } else if (port.name == "disableVimium") { + port.onMessage.addListener(function(args) { + disableVimium(); + }); } }); } @@ -194,6 +198,14 @@ function initializeWhenEnabled() { enterInsertModeIfElementIsFocused(); } +function disableVimium() { + document.removeEventListener("keydown", onKeydown, true); + document.removeEventListener("keypress", onKeypress, true); + document.removeEventListener("keyup", onKeyup, true); + document.removeEventListener("focus", onFocusCapturePhase, true); + document.removeEventListener("blur", onBlurCapturePhase, true); + document.removeEventListener("DOMActivate", onDOMActivate, true); +} /* * The backend needs to know which frame has focus. |
