提交 4d9fe432 编写于 作者: J Joao Moreno

send gallery requests for all URLs

fixes #14139
上级 657070a0
......@@ -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);
......
......@@ -191,6 +191,7 @@ export interface IQueryOptions {
export interface IExtensionGalleryService {
_serviceBrand: any;
isEnabled(): boolean;
getRequestHeaders(): TPromise<{ [key: string]: string; }>;
query(options?: IQueryOptions): TPromise<IPager<IGalleryExtension>>;
download(extension: IGalleryExtension): TPromise<string>;
getAsset(url: string): TPromise<IRequestContext>;
......
......@@ -293,6 +293,10 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
return !!this.extensionsGalleryUrl;
}
getRequestHeaders(): TPromise<{ [key: string]: string; }> {
return this.commonHeaders;
}
query(options: IQueryOptions = {}): TPromise<IPager<IGalleryExtension>> {
if (!this.isEnabled()) {
return TPromise.wrapError(new Error('No extension gallery service configured.'));
......
......@@ -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; }[]> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册