提交 1bd34868 编写于 作者: S Sandeep Somavarapu

remove references to pkg and product and use productService

上级 27aebd40
...@@ -26,6 +26,7 @@ import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainServ ...@@ -26,6 +26,7 @@ import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainServ
import { endsWith } from 'vs/base/common/strings'; import { endsWith } from 'vs/base/common/strings';
import { RunOnceScheduler } from 'vs/base/common/async'; import { RunOnceScheduler } from 'vs/base/common/async';
import { IFileService } from 'vs/platform/files/common/files'; import { IFileService } from 'vs/platform/files/common/files';
import pkg from 'vs/platform/product/node/package';
const RUN_TEXTMATE_IN_WORKER = false; const RUN_TEXTMATE_IN_WORKER = false;
...@@ -309,7 +310,7 @@ export class CodeWindow extends Disposable implements ICodeWindow { ...@@ -309,7 +310,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private handleMarketplaceRequests(): void { private handleMarketplaceRequests(): void {
// Resolve marketplace headers // Resolve marketplace headers
this.marketplaceHeadersPromise = resolveMarketplaceHeaders(this.environmentService, this.fileService); this.marketplaceHeadersPromise = resolveMarketplaceHeaders(pkg.version, this.environmentService, this.fileService);
// Inject headers when requests are incoming // Inject headers when requests are incoming
const urls = ['https://marketplace.visualstudio.com/*', 'https://*.vsassets.io/*']; const urls = ['https://marketplace.visualstudio.com/*', 'https://*.vsassets.io/*'];
......
...@@ -11,8 +11,6 @@ import { assign, getOrDefault } from 'vs/base/common/objects'; ...@@ -11,8 +11,6 @@ import { assign, getOrDefault } from 'vs/base/common/objects';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPager } from 'vs/base/common/paging'; import { IPager } from 'vs/base/common/paging';
import { IRequestService, IRequestOptions, IRequestContext, asJson, asText } from 'vs/platform/request/common/request'; import { IRequestService, IRequestOptions, IRequestContext, asJson, asText } from 'vs/platform/request/common/request';
import pkg from 'vs/platform/product/node/package';
import product from 'vs/platform/product/node/product';
import { isEngineValid } from 'vs/platform/extensions/node/extensionValidator'; import { isEngineValid } from 'vs/platform/extensions/node/extensionValidator';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { generateUuid, isUUID } from 'vs/base/common/uuid'; import { generateUuid, isUUID } from 'vs/base/common/uuid';
...@@ -24,6 +22,7 @@ import { IFileService } from 'vs/platform/files/common/files'; ...@@ -24,6 +22,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { joinPath } from 'vs/base/common/resources'; import { joinPath } from 'vs/base/common/resources';
import { VSBuffer } from 'vs/base/common/buffer'; import { VSBuffer } from 'vs/base/common/buffer';
import { IProductService } from 'vs/platform/product/common/product';
interface IRawGalleryExtensionFile { interface IRawGalleryExtensionFile {
assetType: string; assetType: string;
...@@ -339,11 +338,12 @@ export class ExtensionGalleryService implements IExtensionGalleryService { ...@@ -339,11 +338,12 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
@IEnvironmentService private readonly environmentService: IEnvironmentService, @IEnvironmentService private readonly environmentService: IEnvironmentService,
@ITelemetryService private readonly telemetryService: ITelemetryService, @ITelemetryService private readonly telemetryService: ITelemetryService,
@IFileService private readonly fileService: IFileService, @IFileService private readonly fileService: IFileService,
@IProductService productService: IProductService,
) { ) {
const config = product.extensionsGallery; const config = productService.extensionsGallery;
this.extensionsGalleryUrl = config && config.serviceUrl; this.extensionsGalleryUrl = config && config.serviceUrl;
this.extensionsControlUrl = config && config.controlUrl; this.extensionsControlUrl = config && config.controlUrl;
this.commonHeadersPromise = resolveMarketplaceHeaders(this.environmentService, this.fileService); this.commonHeadersPromise = resolveMarketplaceHeaders(productService.version, this.environmentService, this.fileService);
} }
private api(path = ''): string { private api(path = ''): string {
...@@ -774,7 +774,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService { ...@@ -774,7 +774,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
} }
} }
export async function resolveMarketplaceHeaders(environmentService: IEnvironmentService, fileService: IFileService): Promise<{ [key: string]: string; }> { export async function resolveMarketplaceHeaders(version: string, environmentService: IEnvironmentService, fileService: IFileService): Promise<{ [key: string]: string; }> {
const marketplaceMachineIdFile = URI.file(path.join(environmentService.userDataPath, 'machineid')); const marketplaceMachineIdFile = URI.file(path.join(environmentService.userDataPath, 'machineid'));
let uuid: string | null = null; let uuid: string | null = null;
...@@ -796,8 +796,8 @@ export async function resolveMarketplaceHeaders(environmentService: IEnvironment ...@@ -796,8 +796,8 @@ export async function resolveMarketplaceHeaders(environmentService: IEnvironment
} }
} }
return { return {
'X-Market-Client-Id': `VSCode ${pkg.version}`, 'X-Market-Client-Id': `VSCode ${version}`,
'User-Agent': `VSCode ${pkg.version}`, 'User-Agent': `VSCode ${version}`,
'X-Market-User-Id': uuid 'X-Market-User-Id': uuid
}; };
} }
\ No newline at end of file
...@@ -18,6 +18,7 @@ import { FileService } from 'vs/platform/files/common/fileService'; ...@@ -18,6 +18,7 @@ import { FileService } from 'vs/platform/files/common/fileService';
import { NullLogService } from 'vs/platform/log/common/log'; import { NullLogService } from 'vs/platform/log/common/log';
import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider'; import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider';
import { Schemas } from 'vs/base/common/network'; import { Schemas } from 'vs/base/common/network';
import pkg from 'vs/platform/product/node/package';
suite('Extension Gallery Service', () => { suite('Extension Gallery Service', () => {
const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'extensiongalleryservice'); const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'extensiongalleryservice');
...@@ -52,10 +53,10 @@ suite('Extension Gallery Service', () => { ...@@ -52,10 +53,10 @@ suite('Extension Gallery Service', () => {
const args = ['--user-data-dir', marketplaceHome]; const args = ['--user-data-dir', marketplaceHome];
const environmentService = new EnvironmentService(parseArgs(args), process.execPath); const environmentService = new EnvironmentService(parseArgs(args), process.execPath);
return resolveMarketplaceHeaders(environmentService, fileService).then(headers => { return resolveMarketplaceHeaders(pkg.version, environmentService, fileService).then(headers => {
assert.ok(isUUID(headers['X-Market-User-Id'])); assert.ok(isUUID(headers['X-Market-User-Id']));
return resolveMarketplaceHeaders(environmentService, fileService).then(headers2 => { return resolveMarketplaceHeaders(pkg.version, environmentService, fileService).then(headers2 => {
assert.equal(headers['X-Market-User-Id'], headers2['X-Market-User-Id']); assert.equal(headers['X-Market-User-Id'], headers2['X-Market-User-Id']);
}); });
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册