Merge from vscode e558dc6ea73a75bd69d7a0b485f0e7e4194c66bf (#6864)

This commit is contained in:
Anthony Dresser
2019-08-21 20:44:59 -07:00
committed by GitHub
parent d2ae0f0154
commit 985bfae8a0
107 changed files with 2260 additions and 814 deletions

View File

@@ -62,11 +62,9 @@ export class BrowserWindowConfiguration implements IWindowConfiguration {
termProgram?: string;
}
export interface IBrowserWindowConfiguration {
interface IBrowserWorkbenchEnvironemntConstructionOptions extends IWorkbenchConstructionOptions {
workspaceId: string;
remoteAuthority?: string;
webviewEndpoint?: string;
connectionToken?: string;
logsPath: URI;
}
export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironmentService {
@@ -75,8 +73,10 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
readonly configuration: IWindowConfiguration = new BrowserWindowConfiguration();
constructor(workspaceId: string, public readonly options: IWorkbenchConstructionOptions) {
constructor(readonly options: IBrowserWorkbenchEnvironemntConstructionOptions) {
this.args = { _: [] };
this.logsPath = options.logsPath.path;
this.logFile = joinPath(options.logsPath, 'window.log');
this.appRoot = '/web/';
this.appNameLong = 'Visual Studio Code - Web';
@@ -88,10 +88,8 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
this.keyboardLayoutResource = joinPath(this.userRoamingDataHome, 'keyboardLayout.json');
this.localeResource = joinPath(this.userRoamingDataHome, 'locale.json');
this.backupHome = joinPath(this.userRoamingDataHome, BACKUPS);
this.configuration.backupWorkspaceResource = joinPath(this.backupHome, workspaceId);
this.configuration.connectionToken = options.connectionToken || this.getConnectionTokenFromLocation();
this.logsPath = '/web/logs';
this.configuration.backupWorkspaceResource = joinPath(this.backupHome, options.workspaceId);
this.configuration.connectionToken = options.connectionToken || getCookieValue('vscode-tkn');
this.debugExtensionHost = {
port: null,
@@ -183,6 +181,7 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
driverVerbose: boolean;
webviewEndpoint?: string;
galleryMachineIdResource?: URI;
readonly logFile: URI;
get webviewResourceRoot(): string {
return this.webviewEndpoint ? this.webviewEndpoint + '/vscode-resource{{resource}}' : 'vscode-resource:{{resource}}';
@@ -191,21 +190,12 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
get webviewCspSource(): string {
return this.webviewEndpoint ? this.webviewEndpoint : 'vscode-resource:';
}
private getConnectionTokenFromLocation(): string | undefined {
// TODO: Check with @alexd where the token will be: search or hash?
let connectionToken: string | undefined = undefined;
if (document.location.search) {
connectionToken = this.getConnectionToken(document.location.search);
}
if (!connectionToken && document.location.hash) {
connectionToken = this.getConnectionToken(document.location.hash);
}
return connectionToken;
}
private getConnectionToken(str: string): string | undefined {
const m = str.match(/[#&?]tkn=([^&]+)/);
return m ? m[1] : undefined;
}
}
/**
* See https://stackoverflow.com/a/25490531
*/
function getCookieValue(name: string): string | undefined {
const m = document.cookie.match('(^|[^;]+)\\s*' + name + '\\s*=\\s*([^;]+)');
return m ? m.pop() : undefined;
}