src/vs/platform/policy/common/nativeManagedSettingsIpc.ts
79 LOC · 64 covered · 15 uncovered · 16 ranges · 12 concepts · 4 introducers · 7 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
/*---------------------------------------------------------------------------------------------
nativeManagedSettingsIpc.ts ×7
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Emitter, Event } from '../../../base/common/event.js';
import { IStringDictionary } from '../../../base/common/collections.js';
import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js';
import { equals } from '../../../base/common/objects.js';
import { IChannel, IServerChannel } from '../../../base/parts/ipc/common/ipc.js';
import { INativeManagedSettingsService, ManagedSettingsData } from './copilotManagedSettings.js';
import { PolicyDefinition } from './policy.js';
export class NativeManagedSettingsChannel implements IServerChannel {
private readonly disposables = new DisposableStore();
constructor(private readonly service: INativeManagedSettingsService) { }
listen<T>(_: unknown, event: string): Event<T> {
switch (event) {
case 'onDidChangeManagedSettings': return this.service.onDidChangeManagedSettings as Event<T>;
}
throw new Error(`Event not found: ${event}`);
}
call<T>(_: unknown, command: string, arg?: unknown): Promise<T> {
switch (command) {
case 'getManagedSettings': return Promise.resolve(this.service.managedSettings as T);
case 'updatePolicyDefinitions': return this.service.updatePolicyDefinitions(arg as IStringDictionary<PolicyDefinition>) as Promise<T>;
}
throw new Error(`Call not found: ${command}`);
}
dispose(): void {
this.disposables.dispose();
}
export class NativeManagedSettingsChannelClient extends Disposable implements INativeManagedSettingsService {
readonly _serviceBrand: undefined;
private _managedSettings: ManagedSettingsData = {};
get managedSettings(): ManagedSettingsData { return this._managedSettings; }
private hasReceivedManagedSettings = false;
private readonly _onDidChangeManagedSettings = this._register(new Emitter<ManagedSettingsData>());
readonly onDidChangeManagedSettings = this._onDidChangeManagedSettings.event;
constructor(private readonly channel: IChannel) {
this._register(this.channel.listen<ManagedSettingsData>('onDidChangeManagedSettings')(managedSettings => this.updateManagedSettings(managedSettings, true)));
this.channel.call<ManagedSettingsData>('getManagedSettings').then(managedSettings => {
if (!this.hasReceivedManagedSettings) {
}
}
async updatePolicyDefinitions(policyDefinitions: IStringDictionary<PolicyDefinition>): Promise<ManagedSettingsData> {
this.updateManagedSettings(await this.channel.call<ManagedSettingsData>('updatePolicyDefinitions', policyDefinitions), false);
nativeManagedSettingsIpc.ts ×3
return this._managedSettings;
}
private updateManagedSettings(managedSettings: ManagedSettingsData, fireEvent: boolean): void {
if (equals(this._managedSettings, managedSettings)) {
}
this._managedSettings = managedSettings;
if (fireEvent) {
}