This commit is contained in:
Sandeep Somavarapu 2021-12-08 11:47:23 +01:00
parent 322a4c631b
commit 258ca4f8a2
No known key found for this signature in database
GPG key ID: 1FED25EC4646638B

View file

@ -137,7 +137,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private readonly touchBarGroups: TouchBarSegmentedControl[] = [];
private marketplaceHeadersPromise: Promise<object>;
private currentHttpProxy: string | undefined = undefined;
private currentNoProxy: string | undefined = undefined;
@ -150,7 +149,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
@ILogService private readonly logService: ILogService,
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
@IFileService private readonly fileService: IFileService,
@IStorageMainService storageMainService: IStorageMainService,
@IStorageMainService private readonly storageMainService: IStorageMainService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IThemeMainService private readonly themeMainService: IThemeMainService,
@IWorkspacesManagementMainService private readonly workspacesManagementMainService: IWorkspacesManagementMainService,
@ -303,12 +302,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// macOS: touch bar support
this.createTouchBar();
// Request handling
this.marketplaceHeadersPromise = resolveMarketplaceHeaders(this.productService.version, this.productService, this.environmentMainService, this.configurationService, this.fileService, {
get: key => storageMainService.globalStorage.get(key),
store: (key, value) => storageMainService.globalStorage.set(key, value)
});
// Eventing
this.registerListeners();
}
@ -542,12 +535,23 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// Inject headers when requests are incoming
const urls = ['https://marketplace.visualstudio.com/*', 'https://*.vsassets.io/*'];
this._win.webContents.session.webRequest.onBeforeSendHeaders({ urls }, async (details, cb) => {
const headers = await this.marketplaceHeadersPromise;
const headers = await this.getMarketplaceHeaders();
cb({ cancel: false, requestHeaders: Object.assign(details.requestHeaders, headers) });
});
}
private marketplaceHeadersPromise: Promise<object> | undefined;
private getMarketplaceHeaders(): Promise<object> {
if (!this.marketplaceHeadersPromise) {
this.marketplaceHeadersPromise = resolveMarketplaceHeaders(this.productService.version, this.productService, this.environmentMainService, this.configurationService, this.fileService, {
get: key => this.storageMainService.globalStorage.get(key),
store: (key, value) => this.storageMainService.globalStorage.set(key, value)
});
}
return this.marketplaceHeadersPromise;
}
private async onWindowError(error: WindowError.UNRESPONSIVE): Promise<void>;
private async onWindowError(error: WindowError.CRASHED, details: { reason: string, exitCode: number }): Promise<void>;
private async onWindowError(error: WindowError.LOAD, details: { reason: string, exitCode: number }): Promise<void>;