aboutsummaryrefslogtreecommitdiff
path: root/src/content/client
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-05-26 16:24:14 +0900
committerGitHub <noreply@github.com>2019-05-26 16:24:14 +0900
commitcd584c8e243bafa8fc284279f716e8113607cd65 (patch)
treebc39bc30369f149e4ba4b6dc9c353b2906c4ef90 /src/content/client
parent07897df636ca3e732490d53fd2acf947738bf16e (diff)
parent34a96cdc9c5d7c8a11c6f1ae512fbc97724f61c4 (diff)
Merge pull request #592 from ueokande/repeat-last-operation
Add "repeat last operation" command
Diffstat (limited to 'src/content/client')
-rw-r--r--src/content/client/BackgroundClient.ts13
-rw-r--r--src/content/client/OperationClient.ts33
2 files changed, 33 insertions, 13 deletions
diff --git a/src/content/client/BackgroundClient.ts b/src/content/client/BackgroundClient.ts
deleted file mode 100644
index 4a41184..0000000
--- a/src/content/client/BackgroundClient.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { injectable } from 'tsyringe';
-import * as operations from '../../shared/operations';
-import * as messages from '../../shared/messages';
-
-@injectable()
-export default class BackgroundClient {
- execBackgroundOp(op: operations.Operation): Promise<void> {
- return browser.runtime.sendMessage({
- type: messages.BACKGROUND_OPERATION,
- operation: op,
- });
- }
-}
diff --git a/src/content/client/OperationClient.ts b/src/content/client/OperationClient.ts
new file mode 100644
index 0000000..5dbe555
--- /dev/null
+++ b/src/content/client/OperationClient.ts
@@ -0,0 +1,33 @@
+import * as operations from '../../shared/operations';
+import * as messages from '../../shared/messages';
+
+export default interface OperationClient {
+ execBackgroundOp(op: operations.Operation): Promise<void>;
+
+ internalOpenUrl(
+ url: string, newTab?: boolean, background?: boolean,
+ ): Promise<void>;
+}
+
+export class OperationClientImpl implements OperationClient {
+ execBackgroundOp(op: operations.Operation): Promise<void> {
+ return browser.runtime.sendMessage({
+ type: messages.BACKGROUND_OPERATION,
+ operation: op,
+ });
+ }
+
+ internalOpenUrl(
+ url: string, newTab?: boolean, background?: boolean,
+ ): Promise<void> {
+ return browser.runtime.sendMessage({
+ type: messages.BACKGROUND_OPERATION,
+ operation: {
+ type: operations.INTERNAL_OPEN_URL,
+ url,
+ newTab,
+ background,
+ },
+ });
+ }
+}