From 42d902982a1d2edbca8ca2edb5fb25e642794e2a Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 22 Jul 2018 15:39:23 +0900 Subject: Indicator as Clean Architecture --- src/background/presenters/indicator.js | 12 ++++++++++++ src/background/presenters/tab.js | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 src/background/presenters/indicator.js (limited to 'src/background/presenters') 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); + } } -- cgit v1.2.3