-
Notifications
You must be signed in to change notification settings - Fork 56
/
inlineExtension.ts
69 lines (52 loc) · 2.06 KB
/
inlineExtension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import {ClientType} from "../../clientType";
import {TooltipType} from "../../clipperUI/tooltipType";
import {InlineMessageHandler} from "../../communicator/inlineMessageHandler";
import {ClipperData} from "../../storage/clipperData";
import {LocalStorage} from "../../storage/localStorage";
import {ExtensionBase} from "../extensionBase";
import {InlineWorker} from "./inlineWorker";
/**
* This class is used for the cases where we don't really have an extension running in the background
* for us to talk to. For example, when the clipper is invoked via bookmarklet. There is still
* functionality that we need from the "background" that we can provide within the clipper ui itself.
* To simplify and hide that distinction away from the rest of the code, we create this "inlined" extension
* to provide the functionality we need.
*
* Due to the 'uniqueness' of the inline extension, stub method implementations are treated as scenarios
* that don't make sense, and are assumed to be intentional.
*
* Note: this is determined by the InjectOptions.useInlineBackgroundWorker flag
*/
export class InlineExtension extends ExtensionBase<InlineWorker, any, any> {
private worker: InlineWorker;
constructor() {
super(ClientType.Bookmarklet, new ClipperData(new LocalStorage()));
this.worker = new InlineWorker(this.clientInfo, this.auth);
this.addWorker(this.worker);
}
getIdFromTab(tab: any): any {
return undefined;
}
public getInlineMessageHandler(): InlineMessageHandler {
return this.worker.getUiMessageHandler();
}
public getUniqueId(): SafariBrowserTab {
return undefined;
}
protected addPageNavListener(callback: (tab: any) => void) {
}
protected checkIfTabMatchesATooltipType(tab: SafariBrowserTab, tooltipTypes: TooltipType[]): TooltipType {
return undefined;
}
protected async checkIfTabIsAVideoDomain(tab: SafariBrowserTab): Promise<boolean> {
return false;
}
protected checkIfTabIsOnWhitelistedUrl(tab: any): boolean {
return false;
}
protected createWorker(tab: any): InlineWorker {
return undefined;
}
protected onFirstRun() {
}
}