diff options
Diffstat (limited to 'background_page.html')
| -rw-r--r-- | background_page.html | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/background_page.html b/background_page.html index e0c1f3ce..c3c9f952 100644 --- a/background_page.html +++ b/background_page.html @@ -1,6 +1,7 @@ <html> <head> <script type="text/javascript" src="commands.js"></script> +<script type="text/javascript" src="lib/clipboard.js"></script> <script type="text/javascript" charset="utf-8"> // Chromium #15242 will make this XHR request to access the manifest unnecessary. var manifestRequest = new XMLHttpRequest(); @@ -58,7 +59,6 @@ var portHandlers = { keyDown: handleKeyDown, returnScrollPosition: handleReturnScrollPosition, - isEnabledForUrl: isEnabledForUrl, getCurrentTabUrl: getCurrentTabUrl, getZoomLevel: getZoomLevel, saveZoomLevel: saveZoomLevel, @@ -74,7 +74,9 @@ registerFrame: registerFrame, frameFocused: handleFrameFocused, upgradeNotificationClosed: upgradeNotificationClosed, - updateScrollPosition: handleUpdateScrollPosition + updateScrollPosition: handleUpdateScrollPosition, + copyToClipboard: copyToClipboard, + isEnabledForUrl: isEnabledForUrl }; // Event handlers @@ -133,18 +135,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 }; } /* @@ -252,6 +253,13 @@ } /* + * Copies some data (request.data) to the clipboard. + */ + function copyToClipboard(request) { + Clipboard.copy(request.data); + } + + /* * Used by the content scripts to get settings from the local storage. */ function getSetting(args, port) { |
