diff --git a/src/main.js b/src/main.js index de5c7dfbcb8..90de17b278b 100644 --- a/src/main.js +++ b/src/main.js @@ -233,25 +233,25 @@ function configureCommandlineSwitchesSync(cliArgs) { // Append Electron flags to Electron if (SUPPORTED_ELECTRON_SWITCHES.indexOf(argvKey) !== -1) { - - if ( - // Color profile - argvKey === 'force-color-profile' || - // Password store - argvKey === 'password-store' - ) { - if (argvValue) { - app.commandLine.appendSwitch(argvKey, argvValue); - } - } - - // Others - else if (argvValue === true || argvValue === 'true') { + if (argvValue === true || argvValue === 'true') { if (argvKey === 'disable-hardware-acceleration') { app.disableHardwareAcceleration(); // needs to be called explicitly } else { app.commandLine.appendSwitch(argvKey); } + } else if (argvValue) { + if (argvKey === 'force-color-profile') { + // Color profile + app.commandLine.appendSwitch(argvKey, argvValue); + } else if (argvKey === 'password-store') { + // Password store + // TODO@TylerLeonhardt: Remove this migration in 3 months + let migratedArgvValue = argvValue; + if (argvValue === 'gnome' || argvValue === 'gnome-keyring') { + migratedArgvValue = 'gnome-libsecret'; + } + app.commandLine.appendSwitch(argvKey, migratedArgvValue); + } } } diff --git a/src/vs/platform/encryption/common/encryptionService.ts b/src/vs/platform/encryption/common/encryptionService.ts index c00a32a663e..b36ef5724a6 100644 --- a/src/vs/platform/encryption/common/encryptionService.ts +++ b/src/vs/platform/encryption/common/encryptionService.ts @@ -31,8 +31,6 @@ export interface ICommonEncryptionService { export const enum PasswordStoreCLIOption { kwallet = 'kwallet', kwallet5 = 'kwallet5', - gnome = 'gnome', - gnomeKeyring = 'gnome-keyring', gnomeLibsecret = 'gnome-libsecret', basic = 'basic' } diff --git a/src/vs/workbench/contrib/encryption/electron-sandbox/encryption.contribution.ts b/src/vs/workbench/contrib/encryption/electron-sandbox/encryption.contribution.ts new file mode 100644 index 00000000000..9969928a2b5 --- /dev/null +++ b/src/vs/workbench/contrib/encryption/electron-sandbox/encryption.contribution.ts @@ -0,0 +1,48 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { isLinux } from 'vs/base/common/platform'; +import { stripComments } from 'vs/base/common/stripComments'; +import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IFileService } from 'vs/platform/files/common/files'; +import { Registry } from 'vs/platform/registry/common/platform'; +import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; +import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; +import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing'; +import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; + +class EncryptionContribution implements IWorkbenchContribution { + constructor( + @IJSONEditingService private readonly jsonEditingService: IJSONEditingService, + @IEnvironmentService private readonly environmentService: IEnvironmentService, + @IFileService private readonly fileService: IFileService, + @IStorageService private readonly storageService: IStorageService + ) { + this.migrateToGnomeLibsecret(); + } + + /** + * Migrate the user from using the gnome or gnome-keyring password-store to gnome-libsecret. + * TODO@TylerLeonhardt: This migration can be removed in 3 months or so and then storage + * can be cleaned up. + */ + private async migrateToGnomeLibsecret(): Promise { + if (!isLinux || this.storageService.getBoolean('encryption.migratedToGnomeLibsecret', StorageScope.APPLICATION, false)) { + return; + } + try { + const content = await this.fileService.readFile(this.environmentService.argvResource); + const argv = JSON.parse(stripComments(content.value.toString())); + if (argv['password-store'] === 'gnome' || argv['password-store'] === 'gnome-keyring') { + this.jsonEditingService.write(this.environmentService.argvResource, [{ path: ['password-store'], value: 'gnome-libsecret' }], true); + } + this.storageService.store('encryption.migratedToGnomeLibsecret', true, StorageScope.APPLICATION, StorageTarget.USER); + } catch (error) { + console.error(error); + } + } +} + +Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EncryptionContribution, LifecyclePhase.Eventually); diff --git a/src/vs/workbench/workbench.desktop.main.ts b/src/vs/workbench/workbench.desktop.main.ts index 4e56e19903c..bb6d118d460 100644 --- a/src/vs/workbench/workbench.desktop.main.ts +++ b/src/vs/workbench/workbench.desktop.main.ts @@ -173,6 +173,8 @@ import 'vs/workbench/contrib/remoteTunnel/electron-sandbox/remoteTunnel.contribu import 'vs/workbench/contrib/chat/electron-sandbox/chat.contribution'; import 'vs/workbench/contrib/inlineChat/electron-sandbox/inlineChat.contribution'; +// Encryption +import 'vs/workbench/contrib/encryption/electron-sandbox/encryption.contribution'; //#endregion