diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 2171303a5ebeb26f651191d219a1f315d8735617..aabf064105faccce4c5d164130fa8cdcf890891c 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -422,6 +422,20 @@ export class WindowsManager implements IWindowsService { } }); + ipc.on('vscode:setHeaders', (event, windowId: number, urls: string[], headers: any) => { + this.logService.log('IPC#vscode:setHeaders'); + + const vscodeWindow = this.getWindowById(windowId); + + if (!vscodeWindow || !urls || !urls.length || !headers) { + return; + } + + vscodeWindow.win.webContents.session.webRequest.onBeforeSendHeaders({ urls }, (details, cb) => { + cb({ cancel: false, requestHeaders: assign(details.requestHeaders, headers) }); + }); + }); + ipc.on('vscode:broadcast', (event, windowId: number, target: string, broadcast: { channel: string; payload: any; }) => { if (broadcast.channel && !types.isUndefinedOrNull(broadcast.payload)) { this.logService.log('IPC#vscode:broadcast', target, broadcast.channel, broadcast.payload); diff --git a/src/vs/platform/extensionManagement/common/extensionManagement.ts b/src/vs/platform/extensionManagement/common/extensionManagement.ts index 71a9017860989d52cc1444da66566c13c02013b1..96bbe6beb8518bae325d83c3cf474735b25433c4 100644 --- a/src/vs/platform/extensionManagement/common/extensionManagement.ts +++ b/src/vs/platform/extensionManagement/common/extensionManagement.ts @@ -191,6 +191,7 @@ export interface IQueryOptions { export interface IExtensionGalleryService { _serviceBrand: any; isEnabled(): boolean; + getRequestHeaders(): TPromise<{ [key: string]: string; }>; query(options?: IQueryOptions): TPromise>; download(extension: IGalleryExtension): TPromise; getAsset(url: string): TPromise; diff --git a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts index 32bfbca9b20710456cd39dbbf26ec0ea5524b5ef..3c7e702fef89d9ff9bc82d93bd9aa4b7b8748bde 100644 --- a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts +++ b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts @@ -293,6 +293,10 @@ export class ExtensionGalleryService implements IExtensionGalleryService { return !!this.extensionsGalleryUrl; } + getRequestHeaders(): TPromise<{ [key: string]: string; }> { + return this.commonHeaders; + } + query(options: IQueryOptions = {}): TPromise> { if (!this.isEnabled()) { return TPromise.wrapError(new Error('No extension gallery service configured.')); diff --git a/src/vs/workbench/electron-browser/integration.ts b/src/vs/workbench/electron-browser/integration.ts index c5b11e1d9ad9f6fa8fc90cba15f629bfaa9760fa..b23d999bd56303f12207fa1ae9db04139ecbd287 100644 --- a/src/vs/workbench/electron-browser/integration.ts +++ b/src/vs/workbench/electron-browser/integration.ts @@ -34,6 +34,7 @@ import { IPath, IOpenFileRequest, IWindowConfiguration } from 'vs/workbench/elec import { IResourceInput } from 'vs/platform/editor/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; +import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement'; import URI from 'vs/base/common/uri'; import { ipcRenderer as ipc, webFrame, remote } from 'electron'; @@ -68,6 +69,7 @@ export class ElectronIntegration { @IMessageService private messageService: IMessageService, @IContextMenuService private contextMenuService: IContextMenuService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, + @IExtensionGalleryService private extensionGalleryService: IExtensionGalleryService, @IUntitledEditorService private untitledEditorService: IUntitledEditorService ) { } @@ -192,6 +194,11 @@ export class ElectronIntegration { } } }); + + this.extensionGalleryService.getRequestHeaders().done(headers => { + const urls = ['https://marketplace.visualstudio.com/*', 'https://*.vsassets.io/*']; + ipc.send('vscode:setHeaders', this.windowService.getWindowId(), urls, headers); + }); } private resolveKeybindings(actionIds: string[]): TPromise<{ id: string; binding: number; }[]> {