aboutsummaryrefslogtreecommitdiff
path: root/src/content/client/OperationClient.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/client/OperationClient.ts')
-rw-r--r--src/content/client/OperationClient.ts33
1 files changed, 33 insertions, 0 deletions
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,
+ },
+ });
+ }
+}