aboutsummaryrefslogtreecommitdiff
path: root/src/background/index.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-08-12 12:55:37 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-08-12 12:55:37 +0900
commit8e5ceebf61088727fdca524d062162fbdfc86155 (patch)
tree90fb9ed24018ecf204a791a35ad4cc572bb81bb0 /src/background/index.js
parentf1d4bb8c3790d30b4db112b2c185054c119d36b5 (diff)
implement simple tab switch
Diffstat (limited to 'src/background/index.js')
-rw-r--r--src/background/index.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/background/index.js b/src/background/index.js
index ee02f63..d4e0098 100644
--- a/src/background/index.js
+++ b/src/background/index.js
@@ -1,4 +1,18 @@
+import * as tabs from './tabs';
+
+const KEY_MAP = {
+ 'tabs.prev': 104,
+ 'tabs.next': 108
+};
+
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
- console.log("Pressed " + request.which);
- sendResponse({ response: "Response from background script" });
+ switch (request.key) {
+ case KEY_MAP['tabs.prev']:
+ tabs.selectPrevTab(sender.tab.index);
+ break;
+ case KEY_MAP['tabs.next']:
+ tabs.selectNextTab(sender.tab.index);
+ break;
+ }
+ sendResponse();
});