Skip to content

Commit d5f0784

Browse files
committed
Remove homeIndicator and use mainWindow
Tool: gitpod/catfood.gitpod.cloud
1 parent 70b10b8 commit d5f0784

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

src/vs/gitpod/browser/workbench/workbench.ts

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { Disposable, DisposableStore, IDisposable } from '../../../base/common/l
1515
import { FileAccess, Schemas } from '../../../base/common/network.js';
1616
import { isEqual } from '../../../base/common/resources.js';
1717
import { URI, UriComponents } from '../../../base/common/uri.js';
18-
import { localize } from '../../../nls.js';
1918
import product from '../../../platform/product/common/product.js';
2019
import { isFolderToOpen, isWorkspaceToOpen } from '../../../platform/window/common/window.js';
2120
import * as vscode from '../../../workbench/workbench.web.main.internal.js';
@@ -31,6 +30,7 @@ import { extractLocalHostUriMetaDataForPortMapping, isLocalhost, TunnelPrivacyId
3130
import { ColorScheme } from '../../../platform/theme/common/theme.js';
3231
import type { TunnelOptions } from 'vscode';
3332
import { importAMDNodeModule } from '../../../amdX.js';
33+
import { mainWindow } from '../../../base/browser/window.js';
3434

3535
const loadingGrpc = importAMDNodeModule<typeof import('@improbable-eng/grpc-web')>('@improbable-eng/grpc-web', 'dist/grpc-web-client.umd.js');
3636

@@ -46,14 +46,14 @@ export class LocalStorageSecretStorageProvider implements ISecretStorageProvider
4646
private async load(): Promise<Record<string, string>> {
4747
const record = this.loadAuthSessionFromElement();
4848
// Get the secrets from localStorage
49-
const encrypted = window.localStorage.getItem(this._storageKey);
49+
const encrypted = mainWindow.localStorage.getItem(this._storageKey);
5050
if (encrypted) {
5151
try {
52-
const decrypted = JSON.parse(window.gitpod.decrypt(encrypted));
52+
const decrypted = JSON.parse(mainWindow.gitpod.decrypt(encrypted));
5353
return { ...record, ...decrypted };
5454
} catch (err) {
5555
console.error('Failed to decrypt secrets from localStorage', err);
56-
window.localStorage.removeItem(this._storageKey);
56+
mainWindow.localStorage.removeItem(this._storageKey);
5757
}
5858
}
5959

@@ -62,7 +62,7 @@ export class LocalStorageSecretStorageProvider implements ISecretStorageProvider
6262

6363
private loadAuthSessionFromElement(): Record<string, string> {
6464
let authSessionInfo: (AuthenticationSessionInfo & { scopes: string[][] }) | undefined;
65-
const authSessionElement = document.getElementById('vscode-workbench-auth-session');
65+
const authSessionElement = mainWindow.document.getElementById('vscode-workbench-auth-session');
6666
const authSessionElementAttribute = authSessionElement ? authSessionElement.getAttribute('data-settings') : undefined;
6767
if (authSessionElementAttribute) {
6868
try {
@@ -114,8 +114,8 @@ export class LocalStorageSecretStorageProvider implements ISecretStorageProvider
114114

115115
private async save(): Promise<void> {
116116
try {
117-
const encrypted = window.gitpod.encrypt(JSON.stringify(await this._secretsPromise));
118-
window.localStorage.setItem(this._storageKey, encrypted);
117+
const encrypted = mainWindow.gitpod.encrypt(JSON.stringify(await this._secretsPromise));
118+
mainWindow.localStorage.setItem(this._storageKey, encrypted);
119119
} catch (err) {
120120
console.error(err);
121121
}
@@ -163,13 +163,13 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
163163
// https://github.com/microsoft/vscode/blob/159479eb5ae451a66b5dac3c12d564f32f454796/extensions/github-authentication/src/githubServer.ts#L50-L50
164164
if (!(options.authority === 'vscode.github-authentication' && options.path === '/dummy')) {
165165
const key = `vscode-web.url-callbacks[${id}]`;
166-
window.localStorage.removeItem(key);
166+
mainWindow.localStorage.removeItem(key);
167167

168168
this.pendingCallbacks.add(id);
169169
this.startListening();
170170
}
171171

172-
return URI.parse(window.location.href).with({ path: this._callbackRoute, query: queryParams.join('&') });
172+
return URI.parse(mainWindow.location.href).with({ path: this._callbackRoute, query: queryParams.join('&') });
173173
}
174174

175175
private startListening(): void {
@@ -178,8 +178,8 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
178178
}
179179

180180
const fn = () => this.onDidChangeLocalStorage();
181-
window.addEventListener('storage', fn);
182-
this.onDidChangeLocalStorageDisposable = { dispose: () => window.removeEventListener('storage', fn) };
181+
mainWindow.addEventListener('storage', fn);
182+
this.onDidChangeLocalStorageDisposable = { dispose: () => mainWindow.removeEventListener('storage', fn) };
183183
}
184184

185185
private stopListening(): void {
@@ -207,7 +207,7 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
207207

208208
for (const id of this.pendingCallbacks) {
209209
const key = `vscode-web.url-callbacks[${id}]`;
210-
const result = window.localStorage.getItem(key);
210+
const result = mainWindow.localStorage.getItem(key);
211211

212212
if (result !== null) {
213213
try {
@@ -218,7 +218,7 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
218218

219219
pendingCallbacks = pendingCallbacks ?? new Set(this.pendingCallbacks);
220220
pendingCallbacks.delete(id);
221-
window.localStorage.removeItem(key);
221+
mainWindow.localStorage.removeItem(key);
222222
}
223223
}
224224

@@ -325,14 +325,14 @@ class WorkspaceProvider implements IWorkspaceProvider {
325325
const targetHref = this.createTargetUrl(workspace, options);
326326
if (targetHref) {
327327
if (options?.reuse) {
328-
window.location.href = targetHref;
328+
mainWindow.location.href = targetHref;
329329
return true;
330330
} else {
331331
let result;
332332
if (isStandalone()) {
333-
result = window.open(targetHref, '_blank', 'toolbar=no'); // ensures to open another 'standalone' window!
333+
result = mainWindow.open(targetHref, '_blank', 'toolbar=no'); // ensures to open another 'standalone' window!
334334
} else {
335-
result = window.open(targetHref);
335+
result = mainWindow.open(targetHref);
336336
}
337337

338338
return !!result;
@@ -461,8 +461,8 @@ interface WorkspaceInfoResponse {
461461
}
462462

463463
async function doStart(): Promise<IDisposable> {
464-
let supervisorHost = window.location.host;
465-
const infoResponse = await fetch(window.location.protocol + '//' + supervisorHost + '/_supervisor/v1/info/workspace', {
464+
const supervisorHost = mainWindow.location.host;
465+
const infoResponse = await fetch(mainWindow.location.protocol + '//' + supervisorHost + '/_supervisor/v1/info/workspace', {
466466
credentials: 'include'
467467
});
468468
if (!infoResponse.ok) {
@@ -479,7 +479,7 @@ async function doStart(): Promise<IDisposable> {
479479
return Disposable.None;
480480
}
481481

482-
const remoteAuthority = window.location.host;
482+
const remoteAuthority = mainWindow.location.host;
483483

484484
// To make webviews work in development, go to file src/vs/workbench/contrib/webview/browser/pre/main.js
485485
// and update `signalReady` method to bypass hostname check
@@ -520,7 +520,7 @@ async function doStart(): Promise<IDisposable> {
520520
const scopes = [
521521
'function:accessCodeSyncStorage'
522522
];
523-
const tokenResponse = await fetch(window.location.protocol + '//' + supervisorHost + '/_supervisor/v1/token/gitpod/' + info.gitpodApi.host + '/' + scopes.join(','), {
523+
const tokenResponse = await fetch(mainWindow.location.protocol + '//' + supervisorHost + '/_supervisor/v1/token/gitpod/' + info.gitpodApi.host + '/' + scopes.join(','), {
524524
credentials: 'include'
525525
});
526526
if (_state as any === 'terminated') {
@@ -637,11 +637,12 @@ async function doStart(): Promise<IDisposable> {
637637
if (!existing || existing.privacy !== tunnel.privacy) {
638638
existing?.dispose(false);
639639
tunnels.set(status.getRemotePort(), tunnel);
640-
vscode.commands.executeCommand('gitpod.vscode.workspace.openTunnel', {
640+
const openTunnelOptions: TunnelOptions = {
641641
remoteAddress: tunnel.remoteAddress,
642642
localAddressPort: tunnel.remoteAddress.port,
643643
privacy: tunnel.privacy
644-
} as TunnelOptions);
644+
};
645+
vscode.commands.executeCommand('gitpod.vscode.workspace.openTunnel', openTunnelOptions);
645646
notify = true;
646647
}
647648
}
@@ -778,7 +779,7 @@ async function doStart(): Promise<IDisposable> {
778779
if (devMode) {
779780
throw new Error('not supported in dev mode');
780781
}
781-
return window.gitpod.loggedUserID;
782+
return mainWindow.gitpod.loggedUserID;
782783
}
783784
};
784785

@@ -788,7 +789,7 @@ async function doStart(): Promise<IDisposable> {
788789
if (!url || url.length === 0) {
789790
return;
790791
}
791-
return window.gitpod.openDesktopIDE(url);
792+
return mainWindow.gitpod.openDesktopIDE(url);
792793
}
793794
};
794795

@@ -800,7 +801,7 @@ async function doStart(): Promise<IDisposable> {
800801

801802
// Use another element other than window.body, workaround for ipad white bar
802803
// https://github.com/microsoft/vscode/issues/149048
803-
const workbenchElement = document.getElementById('gp-code-workbench')!;
804+
const workbenchElement = mainWindow.document.getElementById('gp-code-workbench')!;
804805
subscriptions.add(vscode.create(workbenchElement, {
805806
// subscriptions.add(vscode.create(document.body, {
806807
remoteAuthority,
@@ -861,11 +862,6 @@ async function doStart(): Promise<IDisposable> {
861862
uri.query.split('&').map(s => s.split(/=(.*)/s)).forEach(([k, v]) => !!k && externalEndpoint.searchParams.append(k.replaceAll('+', ' '), v?.replaceAll('+', ' ') || ''));
862863
return externalEndpoint;
863864
},
864-
homeIndicator: {
865-
href: info.gitpodHost,
866-
icon: 'code',
867-
title: localize('home', "Home")
868-
},
869865
windowIndicator: {
870866
onDidChange: Event.None,
871867
label: `$(gitpod) Gitpod`,
@@ -934,7 +930,7 @@ async function doStart(): Promise<IDisposable> {
934930
if (devMode) {
935931
doStart();
936932
} else {
937-
window.gitpod.ideService = {
933+
mainWindow.gitpod.ideService = {
938934
get state() {
939935
return _state;
940936
},

0 commit comments

Comments
 (0)