aboutsummaryrefslogtreecommitdiff
path: root/src/background/tabs.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-08-16 20:33:53 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-08-16 20:33:53 +0900
commit13fb726332e9638cb3fafc477cf9fe641cb906ce (patch)
tree407ac0092fcb20c94e407bf1cbc8e5c4844b3bd6 /src/background/tabs.js
parent85e22063fe522518e70928255349fb1c16b7cb42 (diff)
parentdc860d32f50e2fc21a4f38663bfb0b9099a77513 (diff)
Merge branch 'command-line'
Diffstat (limited to 'src/background/tabs.js')
-rw-r--r--src/background/tabs.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/background/tabs.js b/src/background/tabs.js
index 000bd7d..899284d 100644
--- a/src/background/tabs.js
+++ b/src/background/tabs.js
@@ -1,3 +1,23 @@
+const closeTab = (id) => {
+ browser.tabs.remove(id);
+};
+
+const reopenTab = () => {
+ browser.sessions.getRecentlyClosed({
+ maxResults: 1
+ }).then((sessions) => {
+ if (sessions.length === 0) {
+ return;
+ }
+ let session = sessions[0];
+ if (session.tab) {
+ browser.sessions.restore(session.tab.sessionId);
+ } else {
+ browser.sessions.restore(session.window.sessionId);
+ }
+ });
+};
+
const selectPrevTab = (current, count) => {
chrome.tabs.query({ currentWindow: true }, (tabs) => {
if (tabs.length < 2) {
@@ -20,4 +40,4 @@ const selectNextTab = (current, count) => {
});
};
-export { selectNextTab, selectPrevTab };
+export { closeTab, reopenTab, selectNextTab, selectPrevTab };