diff options
| author | Jez Ng | 2012-01-17 23:05:26 +0800 |
|---|---|---|
| committer | Jez Ng | 2012-01-25 23:47:55 -0500 |
| commit | 670af66d2d3537c58a42278318ea18bec4a90cdc (patch) | |
| tree | a1fe2c79ec28da95cd3bf595030a0cf2501ba74c /background_page.html | |
| parent | b06787cfccd129c1cbb55d209bcd10ae0def575d (diff) | |
| download | vimium-670af66d2d3537c58a42278318ea18bec4a90cdc.tar.bz2 | |
Allow content scripts to both read and write settings.
Diffstat (limited to 'background_page.html')
| -rw-r--r-- | background_page.html | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/background_page.html b/background_page.html index 3a8e5b64..95765e2a 100644 --- a/background_page.html +++ b/background_page.html @@ -63,7 +63,7 @@ keyDown: handleKeyDown, returnScrollPosition: handleReturnScrollPosition, getCurrentTabUrl: getCurrentTabUrl, - getSetting: getSetting, + settings: handleSettings, getBookmarks: getBookmarks }; @@ -290,10 +290,14 @@ /* * Used by the content scripts to get settings from the local storage. */ - function getSetting(args, port) { - var value = getSettingFromLocalStorage(args.key); - var returnPort = chrome.tabs.connect(port.tab.id, { name: "returnSetting" }); - returnPort.postMessage({ key: args.key, value: value }); + function handleSettings(args, port) { + if (args.operation == "get") { + var value = getSettingFromLocalStorage(args.key); + port.postMessage({ key: args.key, value: value }); + } + else { // operation == "set" + localStorage[args.key] = args.value; + } } function getBookmarks(args, port) { |
