aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Sukhar2010-10-24 19:43:57 -0700
committerIlya Sukhar2010-10-24 19:43:57 -0700
commit658981295b5c90b821b5eae1b3e2b6783db5e46d (patch)
treecd1625e6a6ee193af11aa95b44588c0738589e12
parentc00dae33b8734d151437cdf4681423a01f89d674 (diff)
downloadvimium-658981295b5c90b821b5eae1b3e2b6783db5e46d.tar.bz2
Fix an excluded URLs regression due to frame support.
-rw-r--r--background_page.html11
-rw-r--r--vimiumFrontend.js25
2 files changed, 19 insertions, 17 deletions
diff --git a/background_page.html b/background_page.html
index 4d03c99b..f4a40ffa 100644
--- a/background_page.html
+++ b/background_page.html
@@ -59,7 +59,6 @@
var portHandlers = {
keyDown: handleKeyDown,
returnScrollPosition: handleReturnScrollPosition,
- isEnabledForUrl: isEnabledForUrl,
getCurrentTabUrl: getCurrentTabUrl,
getZoomLevel: getZoomLevel,
saveZoomLevel: saveZoomLevel,
@@ -75,7 +74,8 @@
frameFocused: handleFrameFocused,
upgradeNotificationClosed: upgradeNotificationClosed,
updateScrollPosition: handleUpdateScrollPosition,
- copyToClipboard: copyToClipboard
+ copyToClipboard: copyToClipboard,
+ isEnabledForUrl: isEnabledForUrl
};
// Event handlers
@@ -134,18 +134,17 @@
/*
* Checks the user's preferences in local storage to determine if Vimium is enabled for the given URL.
*/
- function isEnabledForUrl(args, port) {
- var returnPort = chrome.tabs.connect(port.tab.id, { name: "returnIsEnabledForUrl" });
+ function isEnabledForUrl(request) {
// excludedUrls are stored as a series of URL expressions separated by newlines.
var excludedUrls = (localStorage["excludedUrls"] || "").split("\n");
var isEnabled = true;
for (var i = 0; i < excludedUrls.length; i++) {
// The user can add "*" to the URL which means ".*"
var regexp = new RegExp("^" + excludedUrls[i].replace(/\*/g, ".*") + "$");
- if (args.url.match(regexp))
+ if (request.url.match(regexp))
isEnabled = false;
}
- returnPort.postMessage({ isEnabledForUrl: isEnabled });
+ return { isEnabledForUrl: isEnabled };
}
/*
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 77580a29..b108d141 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -47,8 +47,7 @@ function setSetting(args) { settings[args.key] = args.value; }
function initializePreDomReady() {
for (var i in settingsToLoad) { getSetting(settingsToLoad[i]); }
- var isEnabledForUrlPort = chrome.extension.connect({ name: "isEnabledForUrl" });
- isEnabledForUrlPort.postMessage({ url: window.location.toString() });
+ checkIfEnabledForUrl();
var getZoomLevelPort = chrome.extension.connect({ name: "getZoomLevel" });
getZoomLevelPort.postMessage({ domain: window.location.host });
@@ -117,15 +116,6 @@ function initializePreDomReady() {
if (isEnabledForUrl)
setPageZoomLevel(currentZoomLevel);
});
- } else if (port.name == "returnIsEnabledForUrl") {
- port.onMessage.addListener(function(args) {
- isEnabledForUrl = args.isEnabledForUrl;
- if (isEnabledForUrl)
- initializeWhenEnabled();
- else if (HUD.isReady())
- // Quickly hide any HUD we might already be showing, e.g. if we entered insertMode on page load.
- HUD.hide();
- });
} else if (port.name == "returnSetting") {
port.onMessage.addListener(setSetting);
} else if (port.name == "refreshCompletionKeys") {
@@ -434,6 +424,19 @@ function onKeydown(event) {
event.stopPropagation();
}
+function checkIfEnabledForUrl() {
+ var url = window.location.toString();
+
+ chrome.extension.sendRequest({ handler: "isEnabledForUrl", url: url }, function (response) {
+ isEnabledForUrl = response.isEnabledForUrl;
+ if (isEnabledForUrl)
+ initializeWhenEnabled();
+ else if (HUD.isReady())
+ // Quickly hide any HUD we might already be showing, e.g. if we entered insertMode on page load.
+ HUD.hide();
+ });
+}
+
function refreshCompletionKeys(completionKeys) {
if (completionKeys)
currentCompletionKeys = completionKeys;