aboutsummaryrefslogtreecommitdiff
path: root/src/background/presenters/IndicatorPresenter.ts
blob: 99f92b5d6647b3ad7eca4fd88a9aaf79b4b1743f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { injectable } from 'tsyringe';

@injectable()
export default class IndicatorPresenter {
  indicate(enabled: boolean): Promise<void> {
    let path = enabled
      ? 'resources/enabled_32x32.png'
      : 'resources/disabled_32x32.png';
    if (typeof browser.browserAction.setIcon === 'function') {
      return browser.browserAction.setIcon({ path });
    }

    // setIcon not supported on Android
    return Promise.resolve();

  }

  onClick(listener: (arg: browser.tabs.Tab) => void): void {
    browser.browserAction.onClicked.addListener(listener);
  }
}