Skip to content

Commit

Permalink
WebView Extensions asset load 403 Forbidden #13373 (#13382)
Browse files Browse the repository at this point in the history
* fix regression where webview based editors were using the new more stable origin URL from regular web views
* add doc
  • Loading branch information
jfaltermeier authored Feb 13, 2024
1 parent fba46c6 commit ef486bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/custom-editors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class CustomEditorsExtImpl implements CustomEditorsExt {
if (!entry) {
throw new Error(`No provider found for '${viewType}'`);
}
const panel = this.webviewExt.createWebviewPanel(viewType, title, {}, options, entry.plugin, handler);
const panel = this.webviewExt.createWebviewPanel(viewType, title, {}, options, entry.plugin, handler, false);
const webviewOptions = WebviewImpl.toWebviewOptions(options, this.workspace, entry.plugin);
await this.proxy.$createCustomEditorPanel(handler, title, widgetOpenerOptions, webviewOptions);

Expand Down
18 changes: 16 additions & 2 deletions packages/plugin-ext/src/plugin/webviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,33 @@ export class WebviewsExtImpl implements WebviewsExt {
return panel;
}

/**
* Creates a new webview panel.
*
* @param viewType Identifies the type of the webview panel.
* @param title Title of the panel.
* @param showOptions Where webview panel will be reside.
* @param options Settings for the new panel.
* @param plugin The plugin contributing the webview.
* @param viewId The identifier of the webview instance.
* @param originBasedOnType true if a stable origin based on the viewType shall be used, false if the viewId should be used.
* @returns The new webview panel.
*/
createWebviewPanel(
viewType: string,
title: string,
showOptions: theia.ViewColumn | theia.WebviewPanelShowOptions,
options: theia.WebviewPanelOptions & theia.WebviewOptions,
plugin: Plugin,
viewId: string
viewId: string,
originBasedOnType = true
): WebviewPanelImpl {
if (!this.initData) {
throw new Error('Webviews are not initialized');
}
const webviewShowOptions = toWebviewPanelShowOptions(showOptions);
const webview = new WebviewImpl(viewId, this.proxy, options, this.initData, this.workspace, plugin, hashValue(viewType));
const origin = originBasedOnType ? hashValue(viewType) : undefined;
const webview = new WebviewImpl(viewId, this.proxy, options, this.initData, this.workspace, plugin, origin);
const panel = new WebviewPanelImpl(viewId, this.proxy, viewType, title, webviewShowOptions, options, webview);
this.webviewPanels.set(viewId, panel);
return panel;
Expand Down

0 comments on commit ef486bd

Please sign in to comment.