From 65cf6f0842d8d5933dc13b3767b1baf398d68cd5 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka <ueokande@i-beam.org> Date: Mon, 14 Jun 2021 23:14:51 +0900 Subject: Implement FindNextOperator --- src/background/clients/FindClient.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/background/clients/FindClient.ts (limited to 'src/background/clients') 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 } + ); + } +} -- cgit v1.2.3