Allow tunnel providers to define port privacy options (#133677)

This commit is contained in:
Alex Ross
2021-09-23 16:24:51 +02:00
committed by GitHub
parent fd6adaf30a
commit a15378a9db
16 changed files with 254 additions and 143 deletions

View File

@@ -6,6 +6,7 @@
import { MainThreadTunnelServiceShape, MainContext, PortAttributesProviderSelector } from 'vs/workbench/api/common/extHost.protocol';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import type * as vscode from 'vscode';
import * as nls from 'vs/nls';
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { URI } from 'vs/base/common/uri';
@@ -295,9 +296,26 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
}
if (provider.tunnelFactory) {
this._forwardPortProvider = provider.tunnelFactory;
this._proxy.$setTunnelProvider(provider.tunnelFeatures ?? {
elevation: false,
public: false
let privacyOptions = provider.tunnelFeatures?.privacyOptions ?? [];
if (provider.tunnelFeatures?.public && (privacyOptions.length === 0)) {
privacyOptions = [
{
id: 'private',
label: nls.localize('tunnelPrivacy.private', "Private"),
themeIcon: 'lock'
},
{
id: 'public',
label: nls.localize('tunnelPrivacy.public', "Public"),
themeIcon: 'eye'
}
];
}
this._proxy.$setTunnelProvider({
elevation: !!provider.tunnelFeatures?.elevation,
public: !!provider.tunnelFeatures?.public,
privacyOptions
});
}
} else {