aboutsummaryrefslogtreecommitdiff
path: root/src/background/clients/FindClient.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/clients/FindClient.ts')
-rw-r--r--src/background/clients/FindClient.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/background/clients/FindClient.ts b/src/background/clients/FindClient.ts
new file mode 100644
index 0000000..863c5ad
--- /dev/null
+++ b/src/background/clients/FindClient.ts
@@ -0,0 +1,30 @@
+import * as messages from "../../shared/messages";
+
+export default interface FindClient {
+ findNext(tabId: number, frameId: number, keyword: string): Promise<boolean>;
+
+ clearSelection(tabId: number, frameId: number): Promise<void>;
+}
+
+export class FindClientImpl implements FindClient {
+ async findNext(
+ tabId: number,
+ frameId: number,
+ keyword: string
+ ): Promise<boolean> {
+ const found = (await browser.tabs.sendMessage(
+ tabId,
+ { type: messages.FIND_NEXT, keyword },
+ { frameId }
+ )) as boolean;
+ return found;
+ }
+
+ clearSelection(tabId: number, frameId: number): Promise<void> {
+ return browser.tabs.sendMessage(
+ tabId,
+ { type: messages.FIND_CLEAR_SELECTION },
+ { frameId }
+ );
+ }
+}