From 0846587baf8ff04d2183985a61f14ccdea7263d3 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 22 Jul 2018 17:09:14 +0900 Subject: Open link as Clean Architecture --- src/background/presenters/tab.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/background/presenters') 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) { -- cgit v1.2.3