diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-02-24 22:20:37 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-02-24 22:39:46 +0900 |
commit | f707f4da75652b4c344df9346a34e8010a044006 (patch) | |
tree | c0f821c79bdc00bec730e853e1cea2a696a1f74f /src/background/usecases/ConsoleUseCase.js | |
parent | a880d5684b35235436f571e5fd8e9f857bf30434 (diff) |
Clean classes and repository
Diffstat (limited to 'src/background/usecases/ConsoleUseCase.js')
-rw-r--r-- | src/background/usecases/ConsoleUseCase.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/background/usecases/ConsoleUseCase.js b/src/background/usecases/ConsoleUseCase.js new file mode 100644 index 0000000..e8e5d4a --- /dev/null +++ b/src/background/usecases/ConsoleUseCase.js @@ -0,0 +1,61 @@ +import TabPresenter from '../presenters/TabPresenter'; +import ConsoleClient from '../infrastructures/ConsoleClient'; + +export default class ConsoleUseCase { + constructor() { + this.tabPresenter = new TabPresenter(); + this.consoleClient = new ConsoleClient(); + } + + async showCommand() { + let tab = await this.tabPresenter.getCurrent(); + return this.consoleClient.showCommand(tab.id, ''); + } + + async showOpenCommand(alter) { + let tab = await this.tabPresenter.getCurrent(); + let command = 'open '; + if (alter) { + command += tab.url; + } + return this.consoleClient.showCommand(tab.id, command); + } + + async showTabopenCommand(alter) { + let tab = await this.tabPresenter.getCurrent(); + let command = 'tabopen '; + if (alter) { + command += tab.url; + } + return this.consoleClient.showCommand(tab.id, command); + } + + async showWinopenCommand(alter) { + let tab = await this.tabPresenter.getCurrent(); + let command = 'winopen '; + if (alter) { + command += tab.url; + } + return this.consoleClient.showCommand(tab.id, command); + } + + async showBufferCommand() { + let tab = await this.tabPresenter.getCurrent(); + let command = 'buffer '; + return this.consoleClient.showCommand(tab.id, command); + } + + async showAddbookmarkCommand(alter) { + let tab = await this.tabPresenter.getCurrent(); + let command = 'addbookmark '; + if (alter) { + command += tab.title; + } + return this.consoleClient.showCommand(tab.id, command); + } + + async hideConsole() { + let tab = await this.tabPresenter.getCurrent(); + return this.consoleClient.hide(tab.id); + } +} |