aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases/LinkUseCase.ts
blob: 480f6b5f9803b39eaa05095ebc6b13a9e5eaa8b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import TabPresenter from '../presenters/TabPresenter';

export default class LinkUseCase {
  private tabPresenter: TabPresenter;

  constructor() {
    this.tabPresenter = new TabPresenter();
  }

  openToTab(url: string, tabId: number): Promise<any> {
    return this.tabPresenter.open(url, tabId);
  }

  async openNewTab(
    url: string, openerId: number, background: boolean,
  ): Promise<any> {
    let properties: any = { active: !background };

    let platform = await browser.runtime.getPlatformInfo();
    if (platform.os !== 'android') {
      // openerTabId not supported on Android
      properties.openerTabId = openerId;
    }

    return this.tabPresenter.create(url, properties);
  }
}