diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-07-22 15:39:23 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-07-22 15:39:23 +0900 |
commit | 42d902982a1d2edbca8ca2edb5fb25e642794e2a (patch) | |
tree | bf7bfe93335458269b251e5a12be32b1c84cb77c /src/background/presenters | |
parent | b130fd52681a4e3f381d3d09a48589fc42996a8b (diff) |
Indicator as Clean Architecture
Diffstat (limited to 'src/background/presenters')
-rw-r--r-- | src/background/presenters/indicator.js | 12 | ||||
-rw-r--r-- | src/background/presenters/tab.js | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/background/presenters/indicator.js b/src/background/presenters/indicator.js new file mode 100644 index 0000000..5737519 --- /dev/null +++ b/src/background/presenters/indicator.js @@ -0,0 +1,12 @@ +export default class IndicatorPresenter { + indicate(enabled) { + let path = enabled + ? 'resources/enabled_32x32.png' + : 'resources/disabled_32x32.png'; + return browser.browserAction.setIcon({ path }); + } + + onClick(listener) { + browser.browserAction.onClicked.addListener(listener); + } +} diff --git a/src/background/presenters/tab.js b/src/background/presenters/tab.js index 8f60535..6120f6e 100644 --- a/src/background/presenters/tab.js +++ b/src/background/presenters/tab.js @@ -2,4 +2,8 @@ export default class TabPresenter { create(url) { browser.tabs.create({ url, }); } + + onSelected(listener) { + browser.tabs.onActivated.addListener(listener); + } } |