aboutsummaryrefslogtreecommitdiff
path: root/src/background/presenters
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-07-22 17:09:14 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-07-22 17:09:14 +0900
commit0846587baf8ff04d2183985a61f14ccdea7263d3 (patch)
tree828223c0aa96d1e7323d67fdda148aade5022f0f /src/background/presenters
parent42d902982a1d2edbca8ca2edb5fb25e642794e2a (diff)
Open link as Clean Architecture
Diffstat (limited to 'src/background/presenters')
-rw-r--r--src/background/presenters/tab.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/background/presenters/tab.js b/src/background/presenters/tab.js
index 6120f6e..66a207f 100644
--- a/src/background/presenters/tab.js
+++ b/src/background/presenters/tab.js
@@ -1,6 +1,22 @@
export default class TabPresenter {
- create(url) {
- browser.tabs.create({ url, });
+ open(url, tabId) {
+ return browser.tabs.update(tabId, { url });
+ }
+
+ create(url, { openerTabId, active }) {
+ return browser.tabs.create({ url, openerTabId, active });
+ }
+
+ async createAdjacent(url, { openerTabId, active }) {
+ let tabs = await browser.tabs.query({
+ active: true, currentWindow: true
+ });
+ return browser.tabs.create({
+ url,
+ openerTabId,
+ active,
+ index: tabs[0].index + 1
+ });
}
onSelected(listener) {