aboutsummaryrefslogtreecommitdiff
path: root/src/background/presenters
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-07-28 10:42:32 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-07-28 10:42:32 +0900
commit66c23423f931bb66c59cd29cf9279a5de5d56535 (patch)
tree5c2b37cea2e93aa949d88bf12ac97c294aff2335 /src/background/presenters
parentab29706348ec9091d1d75c0418f24dfab849a2e5 (diff)
Background operation as Clean Architecture
Diffstat (limited to 'src/background/presenters')
-rw-r--r--src/background/presenters/bookmark.js0
-rw-r--r--src/background/presenters/console.js20
-rw-r--r--src/background/presenters/tab.js35
3 files changed, 55 insertions, 0 deletions
diff --git a/src/background/presenters/bookmark.js b/src/background/presenters/bookmark.js
deleted file mode 100644
index e69de29..0000000
--- a/src/background/presenters/bookmark.js
+++ /dev/null
diff --git a/src/background/presenters/console.js b/src/background/presenters/console.js
index f7d3777..8259238 100644
--- a/src/background/presenters/console.js
+++ b/src/background/presenters/console.js
@@ -1,16 +1,36 @@
import messages from '../../shared/messages';
export default class ConsolePresenter {
+ showCommand(tabId, command) {
+ return browser.tabs.sendMessage(tabId, {
+ type: messages.CONSOLE_SHOW_COMMAND,
+ command,
+ });
+ }
+
+ showFind(tabId) {
+ return browser.tabs.sendMessage(tabId, {
+ type: messages.CONSOLE_SHOW_FIND
+ });
+ }
+
showInfo(tabId, message) {
return browser.tabs.sendMessage(tabId, {
type: messages.CONSOLE_SHOW_INFO,
text: message,
});
}
+
showError(tabId, message) {
return browser.tabs.sendMessage(tabId, {
type: messages.CONSOLE_SHOW_ERROR,
text: message,
});
}
+
+ hide(tabId) {
+ return browser.tabs.sendMessage(tabId, {
+ type: messages.CONSOLE_HIDE,
+ });
+ }
}
diff --git a/src/background/presenters/tab.js b/src/background/presenters/tab.js
index be6955a..2a06a5a 100644
--- a/src/background/presenters/tab.js
+++ b/src/background/presenters/tab.js
@@ -48,6 +48,41 @@ export default class TabPresenter {
return browser.tabs.remove(ids);
}
+ async reopen() {
+ let window = await browser.windows.getCurrent();
+ let sessions = await browser.sessions.getRecentlyClosed();
+ let session = sessions.find((s) => {
+ return s.tab && s.tab.windowId === window.id;
+ });
+ if (!session) {
+ return;
+ }
+ if (session.tab) {
+ return browser.sessions.restore(session.tab.sessionId);
+ }
+ return browser.sessions.restore(session.window.sessionId);
+ }
+
+ reload(tabId, cache) {
+ return browser.tabs.reload(tabId, { bypassCache: cache });
+ }
+
+ setPinned(tabId, pinned) {
+ return browser.tabs.update(tabId, { pinned });
+ }
+
+ duplicate(id) {
+ return browser.tabs.duplicate(id);
+ }
+
+ getZoom(tabId) {
+ return browser.tabs.getZoom(tabId);
+ }
+
+ setZoom(tabId, factor) {
+ return browser.tabs.setZoom(tabId, factor);
+ }
+
async createAdjacent(url, { openerTabId, active }) {
let tabs = await browser.tabs.query({
active: true, currentWindow: true