aboutsummaryrefslogtreecommitdiff
path: root/src/background/controllers
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-05-02 17:25:56 +0900
committerGitHub <noreply@github.com>2020-05-02 17:25:56 +0900
commit5df0537bcf65a341e79852b1b30379c73318529c (patch)
treeaee5efe52412855f620cb514a13a2c14373f27b7 /src/background/controllers
parent685f2b7b69218b06b5bb676069e35f79c5048c9b (diff)
parent75abd90ecb8201ad845b266f96220d8adfe19b2d (diff)
Merge pull request #749 from ueokande/qa-0.28
QA 0.28
Diffstat (limited to 'src/background/controllers')
-rw-r--r--src/background/controllers/AddonEnabledController.ts10
-rw-r--r--src/background/controllers/CommandController.ts87
-rw-r--r--src/background/controllers/CompletionController.ts26
-rw-r--r--src/background/controllers/FindController.ts9
-rw-r--r--src/background/controllers/LinkController.ts13
-rw-r--r--src/background/controllers/MarkController.ts9
-rw-r--r--src/background/controllers/OperationController.ts191
-rw-r--r--src/background/controllers/SettingController.ts13
-rw-r--r--src/background/controllers/VersionController.ts9
9 files changed, 179 insertions, 188 deletions
diff --git a/src/background/controllers/AddonEnabledController.ts b/src/background/controllers/AddonEnabledController.ts
index 903df40..170abdf 100644
--- a/src/background/controllers/AddonEnabledController.ts
+++ b/src/background/controllers/AddonEnabledController.ts
@@ -1,13 +1,9 @@
-import { injectable } from 'tsyringe';
-import AddonEnabledUseCase from '../usecases/AddonEnabledUseCase';
+import { injectable } from "tsyringe";
+import AddonEnabledUseCase from "../usecases/AddonEnabledUseCase";
@injectable()
export default class AddonEnabledController {
-
- constructor(
- private addonEnabledUseCase: AddonEnabledUseCase,
- ) {
- }
+ constructor(private addonEnabledUseCase: AddonEnabledUseCase) {}
indicate(enabled: boolean): Promise<any> {
return this.addonEnabledUseCase.indicate(enabled);
diff --git a/src/background/controllers/CommandController.ts b/src/background/controllers/CommandController.ts
index 16aa6e8..f19303f 100644
--- a/src/background/controllers/CommandController.ts
+++ b/src/background/controllers/CommandController.ts
@@ -1,17 +1,14 @@
-import { injectable } from 'tsyringe';
-import CommandUseCase from '../usecases/CommandUseCase';
+import { injectable } from "tsyringe";
+import CommandUseCase from "../usecases/CommandUseCase";
const trimStart = (str: string): string => {
// NOTE String.trimStart is available on Firefox 61
- return str.replace(/^\s+/, '');
+ return str.replace(/^\s+/, "");
};
@injectable()
export default class CommandController {
- constructor(
- private commandIndicator: CommandUseCase,
- ) {
- }
+ constructor(private commandIndicator: CommandUseCase) {}
// eslint-disable-next-line complexity
exec(line: string): Promise<any> {
@@ -24,44 +21,44 @@ export default class CommandController {
const keywords = trimStart(trimmed.slice(name.length));
switch (words[0]) {
- case 'o':
- case 'open':
- return this.commandIndicator.open(keywords);
- case 't':
- case 'tabopen':
- return this.commandIndicator.tabopen(keywords);
- case 'w':
- case 'winopen':
- return this.commandIndicator.winopen(keywords);
- case 'b':
- case 'buffer':
- return this.commandIndicator.buffer(keywords);
- case 'bd':
- case 'bdel':
- case 'bdelete':
- return this.commandIndicator.bdelete(false, keywords);
- case 'bd!':
- case 'bdel!':
- case 'bdelete!':
- return this.commandIndicator.bdelete(true, keywords);
- case 'bdeletes':
- return this.commandIndicator.bdeletes(false, keywords);
- case 'bdeletes!':
- return this.commandIndicator.bdeletes(true, keywords);
- case 'addbookmark':
- return this.commandIndicator.addbookmark(keywords);
- case 'q':
- case 'quit':
- return this.commandIndicator.quit();
- case 'qa':
- case 'quitall':
- return this.commandIndicator.quitAll();
- case 'set':
- return this.commandIndicator.set(keywords);
- case 'h':
- case 'help':
- return this.commandIndicator.help();
+ case "o":
+ case "open":
+ return this.commandIndicator.open(keywords);
+ case "t":
+ case "tabopen":
+ return this.commandIndicator.tabopen(keywords);
+ case "w":
+ case "winopen":
+ return this.commandIndicator.winopen(keywords);
+ case "b":
+ case "buffer":
+ return this.commandIndicator.buffer(keywords);
+ case "bd":
+ case "bdel":
+ case "bdelete":
+ return this.commandIndicator.bdelete(false, keywords);
+ case "bd!":
+ case "bdel!":
+ case "bdelete!":
+ return this.commandIndicator.bdelete(true, keywords);
+ case "bdeletes":
+ return this.commandIndicator.bdeletes(false, keywords);
+ case "bdeletes!":
+ return this.commandIndicator.bdeletes(true, keywords);
+ case "addbookmark":
+ return this.commandIndicator.addbookmark(keywords);
+ case "q":
+ case "quit":
+ return this.commandIndicator.quit();
+ case "qa":
+ case "quitall":
+ return this.commandIndicator.quitAll();
+ case "set":
+ return this.commandIndicator.set(keywords);
+ case "h":
+ case "help":
+ return this.commandIndicator.help();
}
- throw new Error(words[0] + ' command is not defined');
+ throw new Error(words[0] + " command is not defined");
}
}
diff --git a/src/background/controllers/CompletionController.ts b/src/background/controllers/CompletionController.ts
index fb6137c..35538be 100644
--- a/src/background/controllers/CompletionController.ts
+++ b/src/background/controllers/CompletionController.ts
@@ -4,7 +4,7 @@ import {
ConsoleRequestBookmarksResponse,
ConsoleRequestHistoryResponse,
ConsoleRequestSearchEnginesResponse,
- ConsoleRequesttabsResponse
+ ConsoleRequesttabsResponse,
} from "../../shared/messages";
import { injectable } from "tsyringe";
import OpenCompletionUseCase from "../completion/OpenCompletionUseCase";
@@ -16,20 +16,23 @@ export default class CompletionController {
constructor(
private completionUseCase: OpenCompletionUseCase,
private tabCompletionUseCase: TabCompletionUseCase,
- private propertyCompletionUseCase: PropertyCompletionUseCase,
- ) {
- }
+ private propertyCompletionUseCase: PropertyCompletionUseCase
+ ) {}
async getCompletionTypes(): Promise<ConsoleGetCompletionTypesResponse> {
return this.completionUseCase.getCompletionTypes();
}
- async requestSearchEngines(query: string): Promise<ConsoleRequestSearchEnginesResponse> {
+ async requestSearchEngines(
+ query: string
+ ): Promise<ConsoleRequestSearchEnginesResponse> {
const items = await this.completionUseCase.requestSearchEngines(query);
- return items.map(name => ({ title: name }));
+ return items.map((name) => ({ title: name }));
}
- async requestBookmarks(query: string): Promise<ConsoleRequestBookmarksResponse> {
+ async requestBookmarks(
+ query: string
+ ): Promise<ConsoleRequestBookmarksResponse> {
return this.completionUseCase.requestBookmarks(query);
}
@@ -37,11 +40,14 @@ export default class CompletionController {
return this.completionUseCase.requestHistory(query);
}
- async queryTabs(query: string, excludePinned: boolean): Promise<ConsoleRequesttabsResponse> {
+ async queryTabs(
+ query: string,
+ excludePinned: boolean
+ ): Promise<ConsoleRequesttabsResponse> {
return this.tabCompletionUseCase.queryTabs(query, excludePinned);
}
async getProperties(): Promise<ConsoleGetPropertiesResponse> {
- return this.propertyCompletionUseCase.getProperties();
+ return this.propertyCompletionUseCase.getProperties();
}
-} \ No newline at end of file
+}
diff --git a/src/background/controllers/FindController.ts b/src/background/controllers/FindController.ts
index 1cec962..92dfeb0 100644
--- a/src/background/controllers/FindController.ts
+++ b/src/background/controllers/FindController.ts
@@ -1,12 +1,9 @@
-import { injectable } from 'tsyringe';
-import FindUseCase from '../usecases/FindUseCase';
+import { injectable } from "tsyringe";
+import FindUseCase from "../usecases/FindUseCase";
@injectable()
export default class FindController {
- constructor(
- private findUseCase: FindUseCase,
- ) {
- }
+ constructor(private findUseCase: FindUseCase) {}
getKeyword(): Promise<string> {
return this.findUseCase.getKeyword();
diff --git a/src/background/controllers/LinkController.ts b/src/background/controllers/LinkController.ts
index af6148e..a410bc7 100644
--- a/src/background/controllers/LinkController.ts
+++ b/src/background/controllers/LinkController.ts
@@ -1,19 +1,18 @@
-import { injectable } from 'tsyringe';
-import LinkUseCase from '../usecases/LinkUseCase';
+import { injectable } from "tsyringe";
+import LinkUseCase from "../usecases/LinkUseCase";
@injectable()
export default class LinkController {
- constructor(
- private linkUseCase: LinkUseCase,
- ) {
- }
+ constructor(private linkUseCase: LinkUseCase) {}
openToTab(url: string, tabId: number): Promise<void> {
return this.linkUseCase.openToTab(url, tabId);
}
openNewTab(
- url: string, openerId: number, background: boolean,
+ url: string,
+ openerId: number,
+ background: boolean
): Promise<void> {
return this.linkUseCase.openNewTab(url, openerId, background);
}
diff --git a/src/background/controllers/MarkController.ts b/src/background/controllers/MarkController.ts
index 4726fbc..0d468f2 100644
--- a/src/background/controllers/MarkController.ts
+++ b/src/background/controllers/MarkController.ts
@@ -1,12 +1,9 @@
-import { injectable } from 'tsyringe';
-import MarkUseCase from '../usecases/MarkUseCase';
+import { injectable } from "tsyringe";
+import MarkUseCase from "../usecases/MarkUseCase";
@injectable()
export default class MarkController {
- constructor(
- private markUseCase: MarkUseCase,
- ) {
- }
+ constructor(private markUseCase: MarkUseCase) {}
setGlobal(key: string, x: number, y: number): Promise<any> {
return this.markUseCase.setGlobal(key, x, y);
diff --git a/src/background/controllers/OperationController.ts b/src/background/controllers/OperationController.ts
index 181dd19..5a7047d 100644
--- a/src/background/controllers/OperationController.ts
+++ b/src/background/controllers/OperationController.ts
@@ -1,12 +1,12 @@
-import { injectable } from 'tsyringe';
-import * as operations from '../../shared/operations';
-import FindUseCase from '../usecases/FindUseCase';
-import ConsoleUseCase from '../usecases/ConsoleUseCase';
-import TabUseCase from '../usecases/TabUseCase';
-import TabSelectUseCase from '../usecases/TabSelectUseCase';
-import ZoomUseCase from '../usecases/ZoomUseCase';
-import NavigateUseCase from '../usecases/NavigateUseCase';
-import RepeatUseCase from '../usecases/RepeatUseCase';
+import { injectable } from "tsyringe";
+import * as operations from "../../shared/operations";
+import FindUseCase from "../usecases/FindUseCase";
+import ConsoleUseCase from "../usecases/ConsoleUseCase";
+import TabUseCase from "../usecases/TabUseCase";
+import TabSelectUseCase from "../usecases/TabSelectUseCase";
+import ZoomUseCase from "../usecases/ZoomUseCase";
+import NavigateUseCase from "../usecases/NavigateUseCase";
+import RepeatUseCase from "../usecases/RepeatUseCase";
@injectable()
export default class OperationController {
@@ -17,9 +17,8 @@ export default class OperationController {
private tabSelectUseCase: TabSelectUseCase,
private zoomUseCase: ZoomUseCase,
private navigateUseCase: NavigateUseCase,
- private repeatUseCase: RepeatUseCase,
- ) {
- }
+ private repeatUseCase: RepeatUseCase
+ ) {}
async exec(repeat: number, op: operations.Operation): Promise<any> {
await this.doOperation(repeat, op);
@@ -31,91 +30,96 @@ export default class OperationController {
// eslint-disable-next-line complexity, max-lines-per-function
async doOperation(
repeat: number,
- operation: operations.Operation,
+ operation: operations.Operation
): Promise<any> {
// eslint-disable-next-line complexity, max-lines-per-function
const opFunc = (() => {
switch (operation.type) {
- case operations.TAB_CLOSE:
- return () => this.tabUseCase.close(false, operation.select === 'left');
- case operations.TAB_CLOSE_RIGHT:
- return () => this.tabUseCase.closeRight();
- case operations.TAB_CLOSE_FORCE:
- return () => this.tabUseCase.close(true);
- case operations.TAB_REOPEN:
- return () => this.tabUseCase.reopen();
- case operations.TAB_PREV:
- return () => this.tabSelectUseCase.selectPrev(1);
- case operations.TAB_NEXT:
- return () => this.tabSelectUseCase.selectNext(1);
- case operations.TAB_FIRST:
- return () => this.tabSelectUseCase.selectFirst();
- case operations.TAB_LAST:
- return () => this.tabSelectUseCase.selectLast();
- case operations.TAB_PREV_SEL:
- return () => this.tabSelectUseCase.selectPrevSelected();
- case operations.TAB_RELOAD:
- return () => this.tabUseCase.reload(operation.cache);
- case operations.TAB_PIN:
- return () => this.tabUseCase.setPinned(true);
- case operations.TAB_UNPIN:
- return () => this.tabUseCase.setPinned(false);
- case operations.TAB_TOGGLE_PINNED:
- return () => this.tabUseCase.togglePinned();
- case operations.TAB_DUPLICATE:
- return () => this.tabUseCase.duplicate();
- case operations.PAGE_SOURCE:
- return () => this.tabUseCase.openPageSource();
- case operations.PAGE_HOME:
- return () => this.tabUseCase.openHome(operation.newTab);
- case operations.ZOOM_IN:
- return () => this.zoomUseCase.zoomIn();
- case operations.ZOOM_OUT:
- return () => this.zoomUseCase.zoomOut();
- case operations.ZOOM_NEUTRAL:
- return () => this.zoomUseCase.zoomNutoral();
- case operations.COMMAND_SHOW:
- return () => this.consoleUseCase.showCommand();
- case operations.COMMAND_SHOW_OPEN:
- return () => this.consoleUseCase.showOpenCommand(operation.alter);
- case operations.COMMAND_SHOW_TABOPEN:
- return () => this.consoleUseCase.showTabopenCommand(operation.alter);
- case operations.COMMAND_SHOW_WINOPEN:
- return () => this.consoleUseCase.showWinopenCommand(operation.alter);
- case operations.COMMAND_SHOW_BUFFER:
- return () => this.consoleUseCase.showBufferCommand();
- case operations.COMMAND_SHOW_ADDBOOKMARK:
- return () => this.consoleUseCase.showAddbookmarkCommand(
- operation.alter);
- case operations.FIND_START:
- return () => this.findUseCase.findStart();
- case operations.CANCEL:
- return () => this.consoleUseCase.hideConsole();
- case operations.NAVIGATE_HISTORY_PREV:
- return () => this.navigateUseCase.openHistoryPrev();
- case operations.NAVIGATE_HISTORY_NEXT:
- return () => this.navigateUseCase.openHistoryNext();
- case operations.NAVIGATE_LINK_PREV:
- return () => this.navigateUseCase.openLinkPrev();
- case operations.NAVIGATE_LINK_NEXT:
- return () => this.navigateUseCase.openLinkNext();
- case operations.NAVIGATE_PARENT:
- return () => this.navigateUseCase.openParent();
- case operations.NAVIGATE_ROOT:
- return () => this.navigateUseCase.openRoot();
- case operations.REPEAT_LAST:
- return () => {
- const last = this.repeatUseCase.getLastOperation();
- if (typeof last !== 'undefined') {
- return this.doOperation(1, last);
- }
- return Promise.resolve();
- };
- case operations.INTERNAL_OPEN_URL:
- return () => this.tabUseCase.openURL(
- operation.url, operation.newTab, operation.newWindow);
- default:
- throw new Error('unknown operation: ' + operation.type);
+ case operations.TAB_CLOSE:
+ return () =>
+ this.tabUseCase.close(false, operation.select === "left");
+ case operations.TAB_CLOSE_RIGHT:
+ return () => this.tabUseCase.closeRight();
+ case operations.TAB_CLOSE_FORCE:
+ return () => this.tabUseCase.close(true);
+ case operations.TAB_REOPEN:
+ return () => this.tabUseCase.reopen();
+ case operations.TAB_PREV:
+ return () => this.tabSelectUseCase.selectPrev(1);
+ case operations.TAB_NEXT:
+ return () => this.tabSelectUseCase.selectNext(1);
+ case operations.TAB_FIRST:
+ return () => this.tabSelectUseCase.selectFirst();
+ case operations.TAB_LAST:
+ return () => this.tabSelectUseCase.selectLast();
+ case operations.TAB_PREV_SEL:
+ return () => this.tabSelectUseCase.selectPrevSelected();
+ case operations.TAB_RELOAD:
+ return () => this.tabUseCase.reload(operation.cache);
+ case operations.TAB_PIN:
+ return () => this.tabUseCase.setPinned(true);
+ case operations.TAB_UNPIN:
+ return () => this.tabUseCase.setPinned(false);
+ case operations.TAB_TOGGLE_PINNED:
+ return () => this.tabUseCase.togglePinned();
+ case operations.TAB_DUPLICATE:
+ return () => this.tabUseCase.duplicate();
+ case operations.PAGE_SOURCE:
+ return () => this.tabUseCase.openPageSource();
+ case operations.PAGE_HOME:
+ return () => this.tabUseCase.openHome(operation.newTab);
+ case operations.ZOOM_IN:
+ return () => this.zoomUseCase.zoomIn();
+ case operations.ZOOM_OUT:
+ return () => this.zoomUseCase.zoomOut();
+ case operations.ZOOM_NEUTRAL:
+ return () => this.zoomUseCase.zoomNutoral();
+ case operations.COMMAND_SHOW:
+ return () => this.consoleUseCase.showCommand();
+ case operations.COMMAND_SHOW_OPEN:
+ return () => this.consoleUseCase.showOpenCommand(operation.alter);
+ case operations.COMMAND_SHOW_TABOPEN:
+ return () => this.consoleUseCase.showTabopenCommand(operation.alter);
+ case operations.COMMAND_SHOW_WINOPEN:
+ return () => this.consoleUseCase.showWinopenCommand(operation.alter);
+ case operations.COMMAND_SHOW_BUFFER:
+ return () => this.consoleUseCase.showBufferCommand();
+ case operations.COMMAND_SHOW_ADDBOOKMARK:
+ return () =>
+ this.consoleUseCase.showAddbookmarkCommand(operation.alter);
+ case operations.FIND_START:
+ return () => this.findUseCase.findStart();
+ case operations.CANCEL:
+ return () => this.consoleUseCase.hideConsole();
+ case operations.NAVIGATE_HISTORY_PREV:
+ return () => this.navigateUseCase.openHistoryPrev();
+ case operations.NAVIGATE_HISTORY_NEXT:
+ return () => this.navigateUseCase.openHistoryNext();
+ case operations.NAVIGATE_LINK_PREV:
+ return () => this.navigateUseCase.openLinkPrev();
+ case operations.NAVIGATE_LINK_NEXT:
+ return () => this.navigateUseCase.openLinkNext();
+ case operations.NAVIGATE_PARENT:
+ return () => this.navigateUseCase.openParent();
+ case operations.NAVIGATE_ROOT:
+ return () => this.navigateUseCase.openRoot();
+ case operations.REPEAT_LAST:
+ return () => {
+ const last = this.repeatUseCase.getLastOperation();
+ if (typeof last !== "undefined") {
+ return this.doOperation(1, last);
+ }
+ return Promise.resolve();
+ };
+ case operations.INTERNAL_OPEN_URL:
+ return () =>
+ this.tabUseCase.openURL(
+ operation.url,
+ operation.newTab,
+ operation.newWindow
+ );
+ default:
+ throw new Error("unknown operation: " + operation.type);
}
})();
@@ -125,4 +129,3 @@ export default class OperationController {
}
}
}
-
diff --git a/src/background/controllers/SettingController.ts b/src/background/controllers/SettingController.ts
index 26edc07..4248746 100644
--- a/src/background/controllers/SettingController.ts
+++ b/src/background/controllers/SettingController.ts
@@ -1,15 +1,14 @@
-import { injectable } from 'tsyringe';
-import SettingUseCase from '../usecases/SettingUseCase';
-import ContentMessageClient from '../infrastructures/ContentMessageClient';
-import Settings from '../../shared/settings/Settings';
+import { injectable } from "tsyringe";
+import SettingUseCase from "../usecases/SettingUseCase";
+import ContentMessageClient from "../infrastructures/ContentMessageClient";
+import Settings from "../../shared/settings/Settings";
@injectable()
export default class SettingController {
constructor(
private settingUseCase: SettingUseCase,
- private contentMessageClient: ContentMessageClient,
- ) {
- }
+ private contentMessageClient: ContentMessageClient
+ ) {}
getSetting(): Promise<Settings> {
return this.settingUseCase.getCached();
diff --git a/src/background/controllers/VersionController.ts b/src/background/controllers/VersionController.ts
index b00185a..92fca9e 100644
--- a/src/background/controllers/VersionController.ts
+++ b/src/background/controllers/VersionController.ts
@@ -1,12 +1,9 @@
-import { injectable } from 'tsyringe';
-import VersionUseCase from '../usecases/VersionUseCase';
+import { injectable } from "tsyringe";
+import VersionUseCase from "../usecases/VersionUseCase";
@injectable()
export default class VersionController {
- constructor(
- private versionUseCase: VersionUseCase,
- ) {
- }
+ constructor(private versionUseCase: VersionUseCase) {}
notify(): Promise<void> {
return this.versionUseCase.notify();