MCPcopy
hub / github.com/microsoft/vscode-js-debug / DefaultBrowserProvider

Class DefaultBrowserProvider

src/common/defaultBrowserProvider.ts:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29@injectable()
30export class DefaultBrowserProvider implements IDefaultBrowserProvider {
31 constructor(
32 @inject(ExtensionLocation) private readonly location: ExtensionLocation,
33 @optional() @inject(VSCodeApi) private readonly vscode?: typeof vscodeType,
34 ) {}
35
36 /**
37 * Cache the result of this function. This adds a few milliseconds
38 * (subprocesses out on all platforms) and people rarely change their
39 * default browser.
40 * @inheritdoc
41 */
42 public lookup = once(async () => {
43 let name: string;
44 if (this.location === 'remote' && this.vscode) {
45 name = await this.vscode.commands.executeCommand('js-debug-companion.defaultBrowser');
46 } else {
47 name = (await import('default-browser').then(d => d.default())).name;
48 }
49
50 const match = [DefaultBrowser.Chrome, DefaultBrowser.Edge].find(browser =>
51 name.toLowerCase().includes(browser)
52 );
53 return match ?? DefaultBrowser.Other;
54 });
55}

Callers

nothing calls this directly

Calls 2

onceFunction · 0.90
executeCommandMethod · 0.80

Tested by

no test coverage detected