提交 c4aa0108 编写于 作者: B Benjamin Pasero

sandbox - expose `vscode-windows-registry` from native host service

上级 e85114b2
......@@ -135,4 +135,7 @@ export interface ICommonNativeHostService {
// Connectivity
resolveProxy(url: string): Promise<string | undefined>;
// Registry (windows only)
windowsGetStringRegKey(hive: 'HKEY_CURRENT_USER' | 'HKEY_LOCAL_MACHINE' | 'HKEY_CLASSES_ROOT' | 'HKEY_USERS' | 'HKEY_CURRENT_CONFIG', path: string, name: string): Promise<string | undefined>;
}
......@@ -527,6 +527,21 @@ export class NativeHostMainService implements INativeHostMainService {
//#endregion
//#region Registry (windows)
async windowsGetStringRegKey(windowId: number | undefined, hive: 'HKEY_CURRENT_USER' | 'HKEY_LOCAL_MACHINE' | 'HKEY_CLASSES_ROOT' | 'HKEY_USERS' | 'HKEY_CURRENT_CONFIG', path: string, name: string): Promise<string | undefined> {
if (!isWindows) {
return undefined;
}
const Registry = await import('vscode-windows-registry');
try {
return Registry.GetStringRegKey(hive, path, name);
} catch {
return undefined;
}
}
private windowById(windowId: number | undefined): ICodeWindow | undefined {
if (typeof windowId !== 'number') {
return undefined;
......
......@@ -17,6 +17,7 @@ import { IRequestService } from 'vs/platform/request/common/request';
import { isWindows } from 'vs/base/common/platform';
import { getRemotes, AllowedSecondLevelDomains, getDomainsOfRemotes } from 'vs/platform/extensionManagement/common/configRemotes';
import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService';
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
export function getHashedRemotesFromConfig(text: string, stripEndingDotGit: boolean = false): string[] {
return getRemotes(text, stripEndingDotGit).map(r => {
......@@ -33,7 +34,8 @@ export class WorkspaceTags implements IWorkbenchContribution {
@IRequestService private readonly requestService: IRequestService,
@ITextFileService private readonly textFileService: ITextFileService,
@IWorkspaceTagsService private readonly workspaceTagsService: IWorkspaceTagsService,
@IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService
@IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService,
@INativeHostService private readonly nativeHostService: INativeHostService
) {
if (this.telemetryService.isOptedIn) {
this.report();
......@@ -61,13 +63,7 @@ export class WorkspaceTags implements IWorkbenchContribution {
return;
}
const Registry = await import('vscode-windows-registry');
let value;
try {
value = Registry.GetStringRegKey('HKEY_LOCAL_MACHINE', 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion', 'EditionID');
} catch { }
let value = await this.nativeHostService.windowsGetStringRegKey('HKEY_LOCAL_MACHINE', 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion', 'EditionID');
if (value === undefined) {
value = 'Unknown';
}
......
......@@ -15,6 +15,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing';
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
interface AccessibilityMetrics {
enabled: boolean;
......@@ -33,7 +34,8 @@ export class NativeAccessibilityService extends AccessibilityService implements
@INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IContextKeyService contextKeyService: IContextKeyService,
@IConfigurationService configurationService: IConfigurationService,
@ITelemetryService private readonly _telemetryService: ITelemetryService
@ITelemetryService private readonly _telemetryService: ITelemetryService,
@INativeHostService private readonly nativeHostService: INativeHostService
) {
super(contextKeyService, configurationService);
this.setAccessibilitySupport(environmentService.configuration.accessibilitySupport ? AccessibilitySupport.Enabled : AccessibilitySupport.Disabled);
......@@ -44,15 +46,7 @@ export class NativeAccessibilityService extends AccessibilityService implements
return false;
}
const Registry = await import('vscode-windows-registry');
let value: string | undefined = undefined;
try {
value = Registry.GetStringRegKey('HKEY_CURRENT_USER', 'Control Panel\\Accessibility\\Keyboard Preference', 'On');
} catch {
return false;
}
const value = await this.nativeHostService.windowsGetStringRegKey('HKEY_CURRENT_USER', 'Control Panel\\Accessibility\\Keyboard Preference', 'On');
return value === '1';
}
......
......@@ -230,6 +230,7 @@ export class TestNativeHostService implements INativeHostService {
async readClipboardBuffer(format: string): Promise<Uint8Array> { return Uint8Array.from([]); }
async hasClipboard(format: string, type?: 'selection' | 'clipboard' | undefined): Promise<boolean> { return false; }
async sendInputEvent(event: MouseInputEvent): Promise<void> { }
async windowsGetStringRegKey(hive: 'HKEY_CURRENT_USER' | 'HKEY_LOCAL_MACHINE' | 'HKEY_CLASSES_ROOT' | 'HKEY_USERS' | 'HKEY_CURRENT_CONFIG', path: string, name: string): Promise<string | undefined> { return undefined; }
}
export function workbenchInstantiationService(): ITestInstantiationService {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册