aboutsummaryrefslogtreecommitdiff
path: root/src/background/controllers/OperationController.js
blob: 609599e2ed70324358879906d28a10f491e7c0fd (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import operations from '../../shared/operations';
import OperationUseCase from '../usecases/OperationUseCase';

export default class OperationController {
  constructor() {
    this.operationUseCase = new OperationUseCase();
  }

  // eslint-disable-next-line complexity, max-lines-per-function
  exec(operation) {
    switch (operation.type) {
    case operations.TAB_CLOSE:
      return this.operationUseCase.close(false);
    case operations.TAB_CLOSE_RIGHT:
      return this.operationUseCase.closeRight();
    case operations.TAB_CLOSE_FORCE:
      return this.operationUseCase.close(true);
    case operations.TAB_REOPEN:
      return this.operationUseCase.reopen();
    case operations.TAB_PREV:
      return this.operationUseCase.selectPrev(1);
    case operations.TAB_NEXT:
      return this.operationUseCase.selectNext(1);
    case operations.TAB_FIRST:
      return this.operationUseCase.selectFirst();
    case operations.TAB_LAST:
      return this.operationUseCase.selectLast();
    case operations.TAB_PREV_SEL:
      return this.operationUseCase.selectPrevSelected();
    case operations.TAB_RELOAD:
      return this.operationUseCase.reload(operation.cache);
    case operations.TAB_PIN:
      return this.operationUseCase.setPinned(true);
    case operations.TAB_UNPIN:
      return this.operationUseCase.setPinned(false);
    case operations.TAB_TOGGLE_PINNED:
      return this.operationUseCase.togglePinned();
    case operations.TAB_DUPLICATE:
      return this.operationUseCase.duplicate();
    case operations.PAGE_SOURCE:
      return this.operationUseCase.openPageSource();
    case operations.PAGE_HOME:
      return this.operationUseCase.openHome(operation.newTab);
    case operations.ZOOM_IN:
      return this.operationUseCase.zoomIn();
    case operations.ZOOM_OUT:
      return this.operationUseCase.zoomOut();
    case operations.ZOOM_NEUTRAL:
      return this.operationUseCase.zoomNutoral();
    case operations.COMMAND_SHOW:
      return this.operationUseCase.showCommand();
    case operations.COMMAND_SHOW_OPEN:
      return this.operationUseCase.showOpenCommand(operation.alter);
    case operations.COMMAND_SHOW_TABOPEN:
      return this.operationUseCase.showTabopenCommand(operation.alter);
    case operations.COMMAND_SHOW_WINOPEN:
      return this.operationUseCase.showWinopenCommand(operation.alter);
    case operations.COMMAND_SHOW_BUFFER:
      return this.operationUseCase.showBufferCommand();
    case operations.COMMAND_SHOW_ADDBOOKMARK:
      return this.operationUseCase.showAddbookmarkCommand(operation.alter);
    case operations.FIND_START:
      return this.operationUseCase.findStart();
    case operations.CANCEL:
      return this.operationUseCase.hideConsole();
    }
  }
}